Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366786

Summary: ClassCastException in XbaseGrammarAccess when overriding Xbase rule definitions
Product: [Modeling] TMF Reporter: Kai Kreuzer <kai>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: lorenzo.bettini, sebastian.zarnekow
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Kai Kreuzer CLA 2011-12-15 03:53:06 EST
Build Identifier: Xtext 2.2.1

I am trying to adapt Xbase rules to match specific syntax requirements I
have. On the parsing side, everything works fine, but once I try to
serialize my models, I run into ClassCastExceptions.

I have uploaded an example on Github, see
https://github.com/openhab/xtext-tests.

In this example, I am simply removing the possibility to add type
arguments to member feature calls (I copied the Xbase rule and only put
one line in comment):
https://github.com/openhab/xtext-tests/blob/master/org.xtext.example.mydsl/src/org/xtext/example/mydsl/MyDsl.xtext

A very simple test now takes an expression that contains a member
feature call:
https://github.com/openhab/xtext-tests/blob/master/org.xtext.example.mydsl.tests/src/org/xtext/example/mydsl/SerializerTest.java

This test fails with:

java.lang.ClassCastException: org.eclipse.xtext.impl.AssignmentImpl
cannot be cast to org.eclipse.xtext.Group at
org.eclipse.xtext.xbase.services.XbaseGrammarAccess$XMemberFeatureCallElements.<init>(XbaseGrammarAccess.java:853)

Note that this test is just ONE example - it happens for all other cases
where a Xbase rule is overridden as well.

The problem seems to be that the AbstractXbaseSemanticSequencer always
refer to the XbaseGrammarAccess instead of the MyDslGrammarAccess (see
the injection of XbaseGrammarAccess into the field grammarAccess).


Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-12-19 05:03:15 EST

*** This bug has been marked as a duplicate of bug 347171 ***