Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314841 - [Xtext] Unexpected ValueConverterException raised
Summary: [Xtext] Unexpected ValueConverterException raised
Status: CLOSED WORKSFORME
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 0.7.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-28 07:09 EDT by Johan Wannheden CLA
Modified: 2010-06-25 11:43 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Wannheden CLA 2010-05-28 07:09:23 EDT
Build Identifier: 20100218-1602

I have a case when an ValueConverterException is wrongly raised. Consider the following two grammars A and B, whereas B derives from A.

Grammar B:

SomeRule :
  'some' 'rule' name=MyDataTypeRuleInA
;

Grammar A:

MyDataTypeRuleInA :
  'a' | 'b' | OtherDataTypeRule | MY_TERMINAL_RULE
;

MY_TERMINAL_RULE :
  ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'#'|'$')*
;

A simple model instance for B contains an assignment in SomeRule. When formatting is applied an exception is raised:

"Format" did not complete normally...
... the value XYZ is an invalid MyDataTypeRuleInA

I traced down the problem to this point:

org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter#assertTokens line 67:

if (!getRuleName().toUpperCase().equals(getRuleName(token))) {
  throw createTokenTypeMismatchException(value, escapedString, token);
}

In my case getRuleName() is "MyDataTypeRuleInA" and getRuleName(token) is "MY_TERMINAL_RULE". The condition looks incorrect to me. Is it a bug?

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2010-05-28 09:01:43 EDT
Did you bind a subclass of AbstractLexerBasedConverter to a data type rule (which is not lexer-based)?
Comment 2 Johan Wannheden CLA 2010-05-28 09:22:13 EDT
Yes I did, and that seems to have been the problem. Thanks.
Comment 3 Sebastian Zarnekow CLA 2010-06-25 11:43:54 EDT
see comment #2