|
Re: A few small questions [message #742342 is a reply to message #742012] |
Thu, 20 October 2011 12:08 |
Moritz Eysholdt Messages: 161 Registered: July 2009 Location: Kiel, Germany |
Senior Member |
|
|
Hi adam,
> I am pretty new to XText though it looks quite interesting.
> However, I have three questions and do really hope for some help as I
> couldn't figure by myself:
>
> 1.) Is it possible to create an eclipse distribution with our own dsl
> _without_ any JDT / Java backend?
yes. All dependencies to JDT are supposed to be optional.
> 2.) Is and if, how, possible to generate code not by using templates but
> plain vanilla java code instead so that we could also do some
> optimization during the run?
The model created by Xtext is an EMF model, so you have Java Classes
with Getters/Setters and can easy access your model from within your own
Java code. Your Java code could then write a looong string to disk based
on the information it finds in the model and you may call it code
generator ;)
However, I'd recommend to use Xtend2 to implement code generator. Xtend2
code is compiled to Java code before execution and therefore I doubt
that you could implement a code generator in Java which is significantly
faster. The language Xtend2 is much betters suited for code generators
since it supports multi-line-strings, extension methods, closures, etc.
> Is it also possible, if so, how, to figure
> whether classes, variables etc. are used so that we could leave out
> things during code generation that are not used.
For things in the model that are not used myEObject.eIsSet(myFeature)
returns false. Please refer to the EMF documentation for details. Quite
often, a check for null is sufficient, though.
> 3.) I really can't figure that myself and would so hope for some help.
> I'd like to have a simple DSL that works like:
>
> entity Test
> {
> string property_1;
> integer property_2;
> }
>
> Test* list = Test(property_1 = "test" && |
>
> --> at | which is the cursor position I'd like to have help from the
> code editor showing me "property_1" and "property_2" within the given
> context. How would that be realized??
You'll have to implement scoping for your language:
http://www.eclipse.org/Xtext/documentation/2_0_0/080-scoping.php
regards,
Moritz
|
|
|
Powered by
FUDForum. Page generated in 0.02630 seconds