Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Stopping Xtext from replacing generated files/methods
Stopping Xtext from replacing generated files/methods [message #1794709] Wed, 05 September 2018 10:00 Go to next message
Rohit Verma is currently offline Rohit VermaFriend
Messages: 21
Registered: August 2017
Junior Member
I am trying to get my custom ValueConverters to work as outlined here. All seems to be working fine, expect that whenever I change the grammar and regenerate the code, the contents of the bindIValueConverterService method in AbstractExpressionDslRuntimeModule (which extends DefaultRuntimeModule) are replaced to refer to the old/default valueconverter which I want to replace with custom value converter. So my question is how can I prevent that from happening?

I understand that overriding the bindIValueConverterService method as specified here should be enough, however it doesn't seem to work for me.

Files are below:
import <lots of stuff>

/**
 * Manual modifications go to {@link ExpressionDslRuntimeModule}.
 */
@SuppressWarnings("all")
public abstract class AbstractExpressionDslRuntimeModule extends DefaultRuntimeModule {

	protected Properties properties = null;

	@Override
	public void configure(Binder binder) {
		properties = tryBindProperties(binder, "ca/mcgill/sel/ram/expressions/ExpressionDsl.properties");
		super.configure(binder);
	}
	
	public void configureLanguageName(Binder binder) {
		binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("ca.mcgill.sel.ram.expressions.ExpressionDsl");
	}

	// contributed by org.eclipse.xtext.xtext.generator.formatting.Formatter2Fragment2
	public void configureFormatterPreferences(Binder binder) {
		binder.bind(IPreferenceValuesProvider.class).annotatedWith(FormatterPreferences.class).to(FormatterPreferenceValuesProvider.class);
	}
	
	// contributed by org.eclipse.xtext.xtext.generator.ecore2xtext.Ecore2XtextValueConverterServiceFragment2
	public Class<? extends IValueConverterService> bindIValueConverterService() {
		return Ecore2XtextTerminalConverters.class;
	}


import org.eclipse.xtext.conversion.IValueConverterService

/**
 * Use this class to register components to be used at runtime / without the Equinox extension registry.
 */
class ExpressionDslRuntimeModule extends AbstractExpressionDslRuntimeModule {
    
  override Class<? extends IValueConverterService> bindIValueConverterService() {
            return CustomValueConverter;
    }
}


Any help would be appreciated. Thanks!

[Updated on: Wed, 05 September 2018 10:02]

Report message to a moderator

Re: Stopping Xtext from replacing generated files/methods [message #1794710 is a reply to message #1794709] Wed, 05 September 2018 10:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
You should do the bindings in MyDslRuntimeMethod e.g by overriding the methods
You can use right klick paste java code if you have problems with the syntax

=> can you provide a minimal reproducing example


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 05 September 2018 10:32]

Report message to a moderator

Re: Stopping Xtext from replacing generated files/methods [message #1794713 is a reply to message #1794710] Wed, 05 September 2018 10:37 Go to previous messageGo to next message
Rohit Verma is currently offline Rohit VermaFriend
Messages: 21
Registered: August 2017
Junior Member
By MyDslRuntimeMethod , do you mean ExpressionDslRuntimeModule ?
If I understand correctly, you mean I should do the bindings in ExpressionDslRuntimeModule by overriding bindIValueConverterService? (which is what I did in the original post).
Sorry, but could you be more specific/ share an example if possible?

Many Thanks!
Re: Stopping Xtext from replacing generated files/methods [message #1794716 is a reply to message #1794713] Wed, 05 September 2018 11:03 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i want (1) a minimal dsl (2) a value converter (3) a test that shows your problem
=> i dont understand why its not working with your ExpressionDslRuntimeModule
are you sure you dont have other bindings at other places?
are you sure the default class / super class is used(Ecore2XtextTerminalConverters)
do you have a call stack to that class


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Can't instantiate byte/long due to"Bad" conversion by ValueConverter
Next Topic:Customize DSL file location in (maven) projects
Goto Forum:
  


Current Time: Tue Apr 23 17:21:44 GMT 2024

Powered by FUDForum. Page generated in 0.03131 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top