Home » Modeling » TMF (Xtext) » problems with formatter2 in Xtext 2.9
problems with formatter2 in Xtext 2.9 [message #1714663] |
Sun, 15 November 2015 09:44  |
|
Hi
I started to port one of my DSLs to Xtext 2.9
(https://github.com/LorenzoBettini/javamm). I'm using the nightly
update site.
After the adaption of validator and compiler tests (due to some small
changes in the errors), tests are green but for the formatter tests.
I'm having lots of IllegalStateExceptions in many test cases from this
method
org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(INode,
NodeModelBasedRegionAccess)
in particular
if (!stack.isEmpty() && semanticElement.eContainer() !=
stack.peek().getSemanticElement())
throw new IllegalStateException();
in other test cases I have IllegalStateExceptions from here
(AbstractSyntacticSequencer):
@Override
public boolean enterAssignedParserRuleCall(RuleCall rc, EObject
semanticChild, ICompositeNode node) {
navigateToAbsorber(rc, node);
boolean shouldEnter = delegate.enterAssignedParserRuleCall(rc,
semanticChild, node);
if (shouldEnter) {
ISerializationContext child =
SerializationContext.forChild(contexts.peek().context, rc, semanticChild);
ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
if (pda == null)
throw new IllegalStateException();
SyntacticalContext j = new SyntacticalContext(child, semanticChild,
pda, node);
contexts.push(j);
}
return shouldEnter;
}
any hint on how to understand what's going on?
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: problems with formatter2 in Xtext 2.9 [message #1715011 is a reply to message #1714663] |
Wed, 18 November 2015 13:25   |
|
On 15/11/2015 10:44, Lorenzo Bettini wrote:
> Hi
>
> I started to port one of my DSLs to Xtext 2.9
> (https://github.com/LorenzoBettini/javamm). I'm using the nightly
> update site.
>
> After the adaption of validator and compiler tests (due to some small
> changes in the errors), tests are green but for the formatter tests.
>
> I'm having lots of IllegalStateExceptions in many test cases from this
> method
> org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(INode,
> NodeModelBasedRegionAccess)
> in particular
> if (!stack.isEmpty() && semanticElement.eContainer() !=
> stack.peek().getSemanticElement())
> throw new IllegalStateException();
>
> in other test cases I have IllegalStateExceptions from here
> (AbstractSyntacticSequencer):
>
> @Override
> public boolean enterAssignedParserRuleCall(RuleCall rc, EObject
> semanticChild, ICompositeNode node) {
> navigateToAbsorber(rc, node);
> boolean shouldEnter = delegate.enterAssignedParserRuleCall(rc,
> semanticChild, node);
> if (shouldEnter) {
> ISerializationContext child =
> SerializationContext.forChild(contexts.peek().context, rc, semanticChild);
> ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
> if (pda == null)
> throw new IllegalStateException();
> SyntacticalContext j = new SyntacticalContext(child, semanticChild,
> pda, node);
> contexts.push(j);
> }
> return shouldEnter;
> }
>
> any hint on how to understand what's going on?
>
> thanks in advance
> Lorenzo
>
So I think I solved that myself...
it looks like the new formatter2 in Xtext 2.9 uses both the serializer
and the node model (and it also checks that the two representations are
the same)... in my DSL I was probably doing some dirty hacks ;) in
particular, I was manually rewriting the AST in one case. I fixed that
dirty hack.
In any case, I had to adjust the serializer as well in some cases,
especially when redefining/reusing some rules from Xbase.
The latter scenario can be common to other Xbase DSLs; in particular,
the homeautomation example's test3 in the FormatterTest fails, I think
because the NodeModel representation and the Serializer representation
differ:
org.junit.ComparisonFailure: expected:<...inaryOperation
X[AdditiveExpression:{XBinaryOperation.leftOperand=}
path:XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
B XFeatureCall
XAdditiveExpression:{XBinaryOperation.leftOperand=}
path:XBinaryOperation/leftOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
286 2 S "t1"
XFeatureCall:feature=[JvmIdentifiableElement|IdOrSuper]
E XFeatureCall
XAdditiveExpression:{XBinaryOperation.leftOperand=}
path:XBinaryOperation/leftOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
288 1 H " " Whitespace:TerminalRule'WS'
289 1 S "-"
XAdditiveExpression:feature=[JvmIdentifiableElement|OpAdd]
290 1 H " " Whitespace:TerminalRule'WS'
B XFeatureCall
XAdditiveExpression:rightOperand=XMultiplicativeExpression
path:XBinaryOperation/rightOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
291 2 S "t0"
XFeatureCall:feature=[JvmIdentifiableElement|IdOrSuper]
E XFeatureCall
XAdditiveExpression:rightOperand=XMultiplicativeExpression
path:XBinaryOperation/rightOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
E XBinaryOperation XAdditive]Expression:{XBinaryO...> but
was:<...inaryOperation
X[RelationalExpression:{XBinaryOperation.leftOperand=}
path:XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
B XFeatureCall
XAdditiveExpression:{XBinaryOperation.leftOperand=}
path:XBinaryOperation/leftOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
286 2 S "t1"
XFeatureCall:feature=[JvmIdentifiableElement|IdOrSuper]
E XFeatureCall
XAdditiveExpression:{XBinaryOperation.leftOperand=}
path:XBinaryOperation/leftOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
288 1 H " " Whitespace:TerminalRule'WS'
289 1 S "-"
XAdditiveExpression:feature=[JvmIdentifiableElement|OpAdd]
290 1 H " " Whitespace:TerminalRule'WS'
B XFeatureCall
XAdditiveExpression:rightOperand=XMultiplicativeExpression
path:XBinaryOperation/rightOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
291 2 S "t0"
XFeatureCall:feature=[JvmIdentifiableElement|IdOrSuper]
E XFeatureCall
XAdditiveExpression:rightOperand=XMultiplicativeExpression
path:XBinaryOperation/rightOperand=XBinaryOperation/leftOperand=XIfExpression/if=XBlockExpression/expressions[4]=Rule/thenPart=Model/declarations[2]
E XBinaryOperation XRelational]Expression:{XBinaryO...>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at
org.eclipse.xtext.junit4.formatter.FormatterTester.createRegionAccess(FormatterTester.java:160)
at
org.eclipse.xtext.junit4.formatter.FormatterTester.assertFormatted(FormatterTester.java:99)
at
org.eclipse.xtext.junit4.formatter.FormatterTester.assertFormatted(FormatterTester.java:117)
at
org.eclipse.xtext.example.homeautomation.tests.FormatterTest.test(FormatterTest.java:24)
at
org.eclipse.xtext.example.homeautomation.tests.AbstractTest.test3(AbstractTest.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.eclipse.xtext.junit4.XtextRunner$1.evaluate(XtextRunner.java:49)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| | |
Goto Forum:
Current Time: Mon Oct 02 17:35:48 GMT 2023
Powered by FUDForum. Page generated in 0.02025 seconds
|