Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsXtendParser
https://www.eclipse.org/forums/index.php/mv/msg/170142/540542/#msg_540542
Anyone knows how we can get an AST by parsing an .ext file by using XtendFacade? I can only see that we could get an ExtensionFile object. I have tried to parse an .ext file to get an ExtensionFile object but not successful yet
ExtensionFile f = ParseFacade.file(new StringReader(expression), fileName);
expression is a string but I don't understand what should I assign for it
Please help! ]]>Macca18922010-06-16T13:25:42-00:00Re: XtendParser
https://www.eclipse.org/forums/index.php/mv/msg/170142/540559/#msg_540559
If you have the ExtensionFile instance that's actually the AST.
You should consider looking into the Xtend test plugin for some sources.
CVS coordinates:
- dev.eclipse.org
- /cvsroot/modeling
- org.eclipse.m2t/org.eclipse.xpand/plugins/org.eclipse.xtend. tests
~Karsten]]>Karsten Thoms2010-06-16T14:17:53-00:00Re: XtendParser
https://www.eclipse.org/forums/index.php/mv/msg/170142/540653/#msg_540653
I have looked into org.eclipse.m2t/org.eclipse.xpand/plugins/org.eclipse.xtend. tests and there are many examples there
I tried one of them but now I have another problem with java.lang.NullPointerException at this point: ec = (ExecutionContextImpl) ec.cloneWithResource(file);
I am quite sure that parse function works well because I can read some information from the instance of ExtensionFile. Thus I don't understand why NullPointerException is there
Here is the test code:
ec = new ExecutionContextImpl();
ec.registerMetaModel(new JavaMetaModel("JavaMetaModel", new JavaBeansStrategy()));
final ExtensionFile file = parse(
"foo(String str) : 'String';" +
"foo(Integer int) : 'Int';" +
"foo(Void void) : 'void';"); ec = (ExecutionContextImpl) ec.cloneWithResource(file);
XtendFacade facade = XtendFacade.create(ec);
assertEquals("String",facade.call("foo", "String"));
assertEquals("Int",facade.call("foo", new Long(42)));
assertEquals("void",facade.call("foo", (Object) null));]]>Macca18922010-06-16T20:36:19-00:00Re: XtendParser
https://www.eclipse.org/forums/index.php/mv/msg/170142/540727/#msg_540727
This code works well ]]>Macca18922010-06-17T08:06:20-00:00