[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [recommenders-dev] [snipmatch] headless API for generating code snippets?
|
Hi Stefan,
> I’ve managed to figure out how this could be done 😊 (I hope it’s a
> correct way).
> Using the SnipDSLFactory, we can create objects from the ecore model.
> For example, the following snippet would create a new attribute declaration:
>
> SnipDSLFactory factory=SnipDSLFactory./eINSTANCE/;
>
> attributeDeclaration var=factory.createattributeDeclaration();
>
> var.setName("myAttr");
>
> jFaceDeclarationType type= factory.createjFaceDeclarationType();
>
> type.setType("${array_type}");
>
> var.setJfaceType(type);
OK, that looks like you can construct an "AST" this way. Nice.
> System./out/.println(var.getVisible().getLiteral()+"
> "+var.getJfaceType().getType()+" "+var.getName());
This, however, I do not like. I would expect to be able to either call
just something like var.asString() or to have a visitor traversing the
AST and producing an output text.
Don't you get some pretty-printing / auto-formating for your DSL for
free? You might be able to use the pretty printer to produce the desired
output.
Hope this helps / points you in the right direction.
Andreas
--
Codetrails UG (haftungsbeschränkt)
The knowledge transfer company
Robert-Bosch-Str. 7, 64293 Darmstadt
Mobile: +49-170-811-3791
http://www.codetrails.com/
Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940