Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370246 - ClassCastException using ContentAssistant
Summary: ClassCastException using ContentAssistant
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-31 11:51 EST by Hendrik Renken CLA
Modified: 2017-09-19 17:11 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: juno+


Attachments
Klass.xtext grammar description. (3.46 KB, text/plain)
2012-01-31 11:51 EST, Hendrik Renken CLA
no flags Details
json grammar description. (784 bytes, text/plain)
2012-01-31 11:52 EST, Hendrik Renken CLA
no flags Details
The stacktrace of the classcastexception (7.89 KB, text/plain)
2012-01-31 11:53 EST, Hendrik Renken CLA
no flags Details
proposed patch pls review (4.14 KB, patch)
2012-01-31 16:01 EST, Michael Clay CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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