Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320393 - AbstractDeclarativeValueConverterService.internalRegisterForClass: declarations in superclasses override re-definitions in subclasses
Summary: AbstractDeclarativeValueConverterService.internalRegisterForClass: declaratio...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-20 09:15 EDT by Thomas Wolf CLA
Modified: 2017-09-19 16:13 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: helios+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wolf CLA 2010-07-20 09:15:24 EDT
Build Identifier: I20100608-0911

Assume an xtext grammar derived from the default terminal grammar:

grammar Foo with org.eclipse.xtext.common.Terminals

which then re-defines the STRING rule, for instance to use Ada (or PL/SQL) style strings:

terminal STRING :
  ('"' ((!'"')|('"' '"'))* '"');

Then write a value converter for this:

class FooValueConverters extends org.eclipse.xtext.common.services.DefaultTerminalConverters {

@ValueConverter(rule = "STRING")
public IValueConverter<String> stringValueConverter() {
  return new AbstractNullSafeConverter<String>() {
    @Override
    protected String internalToValue(String s, AbstractNode node) {
      return return s.substring(1, s.length() - 1).replace("\"\"", "\"");;
    }

    @Override
    protected String internalToString(String value) {
      return '"' + source.replace("\"", "\"\"") + '"';
    }
  };
}

Then inject this value converter.

When this value converter is set up, the implementation in AbstractDeclarativeValueConverterService.internalRegisterForClass will first register this new STRING value converter, and then override it by the default one from org.eclipse.xtext.common.services.DefaultTerminalConverters, from which FooValueConverters is extended. As a result, a string like "bar""" cannot be serialized.

The fix is simple: in internalRegisterForClass, handle superclasses first before checking and registering the methods of the current class.

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2010-07-21 05:31:48 EDT
Fixed in HEAD.
Comment 2 Karsten Thoms CLA 2017-09-19 16:13:11 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.