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

Bug 370246

Summary: ClassCastException using ContentAssistant
Product: [Modeling] TMF Reporter: Hendrik Renken <funsheep>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: clay, sebastian.zarnekow
Version: unspecifiedFlags: sebastian.zarnekow: juno+
Target Milestone: M6   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Klass.xtext grammar description.
none
json grammar description.
none
The stacktrace of the classcastexception
none
proposed patch pls review none

Description Hendrik Renken CLA 2012-01-31 11:51:04 EST
Build Identifier: Version: 3.7.1 Build id: M20110909-1335

I created two grammars: "json" and "klass". klass is based on json.

When i now fire up the ContentAssistant to get a suggestion in the .klass file for a jsonvalue, i get the following ClassCastException. I've added the two grammars and the classcastexception as files.

Reproducible in the following situation:

abstract klass Test
{
    properties
    {
          JSON_PROPERTY extends java.util.Set : { "Test : X }
    }
}

At the location of X fire up the content assistant.

Reproducible: Always

Steps to Reproduce:
1. Create two xtext-projects  for the two grammars
2. Compile them and start a new eclipse
3. Add a new file containing the above code
4. Fire up the content assistant where the X is located
Comment 1 Hendrik Renken CLA 2012-01-31 11:51:48 EST
Created attachment 210322 [details]
Klass.xtext grammar description.
Comment 2 Hendrik Renken CLA 2012-01-31 11:52:31 EST
Created attachment 210323 [details]
json grammar description.
Comment 3 Hendrik Renken CLA 2012-01-31 11:53:32 EST
Created attachment 210324 [details]
The stacktrace of the classcastexception
Comment 4 Michael Clay CLA 2012-01-31 16:01:27 EST
Created attachment 210335 [details]
proposed patch pls review
Comment 5 Michael Clay CLA 2012-01-31 16:12:19 EST
JsonValue:
	valueobject=JsonObject | value=STRING | valuearray=JsonArray | value=BOOLEAN | value='null' | value=JsonNumber;

JsonValue has 4 assignments for the feature 'value' 3 RuleCalls and 1 Keyword which causes the CCE in the generated ContentAssist class. Another option to the provided patch would be to add warning/errors validation for such rules.
Comment 6 Sebastian Zarnekow CLA 2012-01-31 16:53:51 EST
Patch looks good besides the indentation in the xpand template.

Could you add a test case in org.eclipse.xtext.ui.tests.editor.contentassist.ContentAssistCustomizingTest

e.g. with

Type:
	(name=FQN|name='FQN') ('extends' superType=TypeRef)? ';'
;
Comment 7 Michael Clay CLA 2012-02-03 08:58:30 EST
psuhed to master
Comment 8 Karsten Thoms CLA 2017-09-19 17:00:30 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 9 Karsten Thoms CLA 2017-09-19 17:11:51 EDT
Closing all bugs that were set to RESOLVED before Neon.0