|
|
|
Re: Serializing expressions results in an exception [message #1756314 is a reply to message #1756307] |
Wed, 15 March 2017 10:13 |
|
the problem is that the serializer is not able to determine the context
can you please file a bug at github eclipse/xtext-core
workaround
Expression result = MyDslFactory.eINSTANCE.createLiteralNumber();
((LiteralNumber)result).setValue(10);
Greeting g = MyDslFactory.eINSTANCE.createGreeting();
LiteralNumber literalNumber = MyDslFactory.eINSTANCE.createLiteralNumber();
literalNumber.setValue(5);
BinaryExpression binaryExpression = MyDslFactory.eINSTANCE.createBinaryExpression();
g.setExpression(binaryExpression);
binaryExpression.setLeft(result);
binaryExpression.setRight(literalNumber);
binaryExpression.setOperator(BinaryOperator.PLUS);
result = binaryExpression;
System.out.println(EmfFormatter.objToStr(result));
MyDslStandaloneSetup standaloneSetup = new MyDslStandaloneSetup();
Injector injector = standaloneSetup.createInjectorAndDoEMFRegistration();
injector.injectMembers(this);
String serializedExpression = serializer.serialize(result);
System.out.println(serializedExpression);
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
Powered by
FUDForum. Page generated in 0.03226 seconds