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

Bug 314841

Summary: [Xtext] Unexpected ValueConverterException raised
Product: [Modeling] TMF Reporter: Johan Wannheden <johan.wannheden>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, stephane
Version: 0.7.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

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