Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347270 - [Serualizer] ClassCastException in ValueConverter in case of Enums
Summary: [Serualizer] ClassCastException in ValueConverter in case of Enums
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 05:03 EDT by Holger Schill CLA
Modified: 2017-09-19 17:17 EDT (History)
1 user (show)

See Also:


Attachments
patch to solve the problem (1.15 KB, patch)
2011-05-26 05:03 EDT, Holger Schill CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Schill CLA 2011-05-26 05:03:00 EDT
Created attachment 196644 [details]
patch to solve the problem

If you have a grammar like this:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	persons+=Person*
;
Person:
	kind=TYPE
;
enum TYPE :
	good | bad
;


You will get a ClassCastException by unsing the ValueConverter. This happens because in 

org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(RuleCall, Object, INode)

there is nobody taking care if it is a enum. Because of that for all assignments the ValueSerializer is used. 

org.eclipse.xtext.serializer.tokens.ValueSerializer.serializeAssignedValue(EObject, RuleCall, Object, INode, Acceptor)

This causes the problem because there is no ValueConverter that can handle Enums.
Instead of the ValueSerializer the EnumSerializer should be used in 
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(RuleCall, Object, INode).

The attached patch solves the problem. I have written an testcase but I could not find other testcases for the serializer independent from xbase of xtend2.
@Moritz Please let me know where we should put common testcases for the serializer.
Comment 1 Moritz Eysholdt CLA 2011-05-31 10:10:37 EDT
the patch looks fine; you can commit it if you want to
Comment 2 Holger Schill CLA 2011-05-31 10:23:31 EDT
pushed to master.
Comment 3 Moritz Eysholdt CLA 2011-06-01 05:41:34 EDT
thx Holger!
Comment 4 Karsten Thoms CLA 2017-09-19 17:05:25 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:17:17 EDT
Closing all bugs that were set to RESOLVED before Neon.0