Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Arithmetics example can't serialize Definition references
Arithmetics example can't serialize Definition references [message #852987] Sun, 22 April 2012 15:07 Go to next message
David Wegener is currently offline David Wegener
Messages: 1341
Registered: July 2009
Senior Member
I have been trying to write a unit test for validating the
parsing/execution of a definition. However, the project is unable to
serialize references to definitions. The problem seems to be related to
the custom naming of the reference in the LinkingService and
NameProvider included in the project. The string representation
internal to the model includes the arguments in addition to the
Definition name. When serializing this string, the '(' and ')'
characters cause the ID rule to fail.

I've been able to use the debugger to change the qualified name of the
reference and remove the arguments from the string. This allows the
serialization to complete successfully.

What I can't figure out is where and how to change the code to allow the
serialization to work in the first place.

Is there a way to get the serialization to work for cross reference that
have customized strings?

Here is an example.

This is the unit test case:
check(10, "def ten(a,b) : a + b; ten(4,6)");

When running this test, you get the following error on serialization:

java.lang.RuntimeException: ID 'ten(arg1,arg2)' contains invalid
characters: '(' (0x28), ')' (0x29), ',' (0x2c)
Semantic Object:
Module'test'.statements[1]->Evaluation.expression->FunctionCall
at
org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
at
org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:141)
at
org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:116)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:448)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:387)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:423)
at
org.eclipse.xtext.example.arithmetics.serializer.AbstractArithmeticsSemanticSequencer.sequence_PrimaryExpression(AbstractArithmeticsSemanticSequencer.java:321)
at
org.eclipse.xtext.example.arithmetics.serializer.AbstractArithmeticsSemanticSequencer.createSequence(AbstractArithmeticsSemanticSequencer.java:102)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:215)
at
org.eclipse.xtext.example.arithmetics.serializer.AbstractArithmeticsSemanticSequencer.sequence_Evaluation(AbstractArithmeticsSemanticSequencer.java:248)
at
org.eclipse.xtext.example.arithmetics.serializer.AbstractArithmeticsSemanticSequencer.createSequence(AbstractArithmeticsSemanticSequencer.java:89)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:380)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:423)
at
org.eclipse.xtext.example.arithmetics.serializer.AbstractArithmeticsSemanticSequencer.sequence_Module(AbstractArithmeticsSemanticSequencer.java:274)
at
org.eclipse.xtext.example.arithmetics.serializer.AbstractArithmeticsSemanticSequencer.createSequence(AbstractArithmeticsSemanticSequencer.java:127)
at
org.eclipse.xtext.junit.serializer.SerializerTester.assertSerializeWithNodeModel(SerializerTester.java:89)
at
org.eclipse.xtext.junit.AbstractXtextTests.getResourceAndExpect(AbstractXtextTests.java:270)
at
org.eclipse.xtext.junit.AbstractXtextTests.getResource(AbstractXtextTests.java:244)
at
org.eclipse.xtext.junit.AbstractXtextTests.getResource(AbstractXtextTests.java:219)
at
org.eclipse.xtext.junit.AbstractXtextTests.getModel(AbstractXtextTests.java:190)
at
org.eclipse.xtext.junit.AbstractXtextTests.getModel(AbstractXtextTests.java:186)
at
org.eclipsecon.example.interpreter.CalculatorTest.getStatement(CalculatorTest.java:53)
at
org.eclipsecon.example.interpreter.CalculatorTest.check(CalculatorTest.java:48)
at
org.eclipsecon.example.interpreter.CalculatorTest.testDef(CalculatorTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Re: Arithmetics example can't serialize Definition references [message #903149 is a reply to message #852987] Wed, 22 August 2012 08:47 Go to previous message
aicha bs is currently offline aicha bs
Messages: 3
Registered: August 2012
Junior Member
Hi,

I have likely the same problem when defining the name of my sadl element (code attached). I have this error:

java.lang.RuntimeException: The value 'customer' is an invalid NAME
Semantic Object: Model.elements[0]->InstanceDeclaration.typeDecl->TypeDeclaration.instName->ResourceName'customer'
at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:66)
at org.eclipse.xtext.serializer.tokens.ValueSerializer.serializeAssignedValue(ValueSerializer.java:95)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:455)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:380)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:416)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_ResourceName(AbstractSadlSemanticSequencer.java:1713)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:653)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:215)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_TypeDeclaration(AbstractSadlSemanticSequencer.java:1842)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:725)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:222)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:380)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:416)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_InstanceDeclaration(AbstractSadlSemanticSequencer.java:1206)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:410)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:373)
at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:416)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.sequence_Model(AbstractSadlSemanticSequencer.java:1479)
at com.ge.research.sadl.serializer.AbstractSadlSemanticSequencer.createSequence(AbstractSadlSemanticSequencer.java:544)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:76)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:84)
at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:106)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:286)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1417)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:986)
at test.ReadItemConnectionFileMeta.test(ReadItemConnectionFileMeta.java:237)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Have you found a solution for that?

Thank you in advance.
  • Attachment: code.txt
    (Size: 0.66KB, Downloaded 57 times)
Previous Topic:Large EPackage don't have a Literals Class
Next Topic:customize ContentAssist
Goto Forum:
  


Current Time: Tue Sep 30 13:54:50 GMT 2014

Powered by FUDForum. Page generated in 0.03348 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software