XbaseCompiler exception when compiling simple XExpressions [message #1758335] |
Mon, 27 March 2017 19:01 |
Rodrigo Ruiz Messages: 28 Registered: March 2017 |
Junior Member |
|
|
Hi,
i'm using XbaseCoimpiler in my generator to genetare java code for XExpressions.
i setup the compilet like this:
def compileXExpression(XExpression xExpression) {
var importManager=new ImportManager()
val result = new FakeTreeAppendable(importManager)
xbaseCompiler.toJavaStatement(xExpression, result, true)// xbaseCompiler.toJavaStatement(xExpression, result, false) doesn't work either.
result
}
and then call that method every time i need the expression translated to java.
even with simple expressions the compiler is unable to find its type:
if i put as expression:
"".toString
i get this exception
java.lang.NullPointerException
at org.eclipse.xtext.xbase.compiler.ImportManager.appendType(ImportManager.java:115)
at org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable.appendType(StringBuilderBasedAppendable.java:36)
at org.eclipse.xtext.xbase.compiler.AbstractStringBuilderBasedAppendable.append(AbstractStringBuilderBasedAppendable.java:49)
at org.eclipse.xtext.xbase.compiler.output.FakeTreeAppendable.append(FakeTreeAppendable.java:38)
at org.eclipse.xtext.xbase.compiler.XbaseCompiler.appendConstructedTypeName(XbaseCompiler.java:972)
at org.eclipse.xtext.xbase.compiler.XbaseCompiler.constructorCallToJavaExpression(XbaseCompiler.java:941)
at org.eclipse.xtext.xbase.compiler.XbaseCompiler._toJavaExpression(XbaseCompiler.java:996)
at org.eclipse.xtext.xbase.compiler.XbaseCompiler.internalToConvertedExpression(XbaseCompiler.java:322)
at org.eclipse.xtext.xbase.compiler.TypeConvertingCompiler.internalToConvertedExpression(TypeConvertingCompiler.java:104)
at org.eclipse.xtext.xbase.compiler.TypeConvertingCompiler.internalToJavaExpression(TypeConvertingCompiler.java:47)
at org.eclipse.xtext.xbase.compiler.FeatureCallCompiler.appendReceiver(FeatureCallCompiler.java:783)
at org.eclipse.xtext.xbase.compiler.FeatureCallCompiler.featureCalltoJavaExpression(FeatureCallCompiler.java:580)
at org.eclipse.xtext.xbase.compiler.FeatureCallCompiler._toJavaStatement(FeatureCallCompiler.java:162)
at org.eclipse.xtext.xbase.compiler.FeatureCallCompiler.doInternalToJavaStatement(FeatureCallCompiler.java:111)
at org.eclipse.xtext.xbase.compiler.XbaseCompiler.doInternalToJavaStatement(XbaseCompiler.java:385)
at org.eclipse.xtext.xbase.compiler.AbstractXbaseCompiler.internalToJavaStatement(AbstractXbaseCompiler.java:473)
at org.eclipse.xtext.xbase.compiler.AbstractXbaseCompiler.toJavaStatement(AbstractXbaseCompiler.java:485)
i've changed the arguments to the xbaseCompiler, but it doesn't work. Based on several examples online it seems to be right, but is not working.
Do you have any clue on what i'm doing wrong?
Thanks for your help!
[Updated on: Mon, 27 March 2017 19:04] Report message to a moderator
|
|
|
|
|
|
|
|
Re: XbaseCompiler exception when cimpiling simple XExpressions [message #1758407 is a reply to message #1758340] |
Tue, 28 March 2017 13:16 |
Rodrigo Ruiz Messages: 28 Registered: March 2017 |
Junior Member |
|
|
no, i'm only importing non existent java classes, since there's no operator overload in java i think i'm safe.
Those missing classes are hardcoded framework classes that i need to include in the generated code (annotations, services, etc.), so i know exactly where to put them.
As for the Xbase code, i only extended a couple of classes to suit my purposes, all the rest of the validation is there., so in theory the user can't enter invalid code, only my generator can put invalid classes in selected places.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04360 seconds