Community
Participate
Working Groups
Build Identifier: M20110909-1335 When using a terminal rule in a cross reference (CrossReferenceTerminal) to which a ValueConverter is bound, any ValueConverterExceptions thrown by that value converter are propagated up to the Xtext editor an appear as a "Problem Occurred" pop-up alert rather than as an error marker. As per the contract of IValueConverter, the ValueConverterException is part of the contract. A ValueConverterExceptions thrown by the same value converter for a standard terminal-rule invocation is correctly converted to an error marker. Reproducible: Always Steps to Reproduce: 1. Create a default MyDsl Xtext project 2. Use this grammar for MyDsl.xtext: ------------------ grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" import "http://www.eclipse.org/emf/2002/Ecore" as ecore Model: greetings+=Greeting* 'favourite' favourite=[Greeting|MyId]; Greeting: 'Hello' name=MyId '!'; MyId returns ecore::EString : ID; ------------------ 3. Create a ValueConverterService like this: ------------------ package org.xtext.example.mydsl; import org.eclipse.xtext.common.services.DefaultTerminalConverters; import org.eclipse.xtext.conversion.IValueConverter; import org.eclipse.xtext.conversion.ValueConverter; import org.eclipse.xtext.conversion.ValueConverterException; import org.eclipse.xtext.nodemodel.INode; public class MyDslValueConverterService extends DefaultTerminalConverters { @ValueConverter(rule = "MyId") public IValueConverter<String> ID() { return new IValueConverter<String>() { @Override public String toValue(String string, INode node) throws ValueConverterException { if( string != null && string.length() > 3) { throw new ValueConverterException("ID too long", node, null); } return string; } @Override public String toString(String value) throws ValueConverterException { return value; } }; } } ------------------ 4. Make a Guice binding for the service 5. Start a runtime workbench 6. Enter this text ------------------ Hello max ! Hello peter! favourite peter ------------------ Correctly, an error marker is created for the first occurence of "peter", but an exception window pops up for the second occurrence: ------------------ An internal error occurred during: "Xtext validation". org.eclipse.xtext.linking.impl.IllegalNodeException: org.eclipse.xtext.conversion.ValueConverterException: ID too long
Created attachment 206476 [details] Screenshot of pop-up alert
pushed test and fix to master.
Closing all bugs that were set to RESOLVED before Neon.0