Skip to main content



      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 06:00 Go to next message
Eclipse UserFriend
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 06:02] by Moderator

Re: Stopping Xtext from replacing generated files/methods [message #1794710 is a reply to message #1794709] Wed, 05 September 2018 06:04 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Wed, 05 September 2018 06:32] by Moderator

Re: Stopping Xtext from replacing generated files/methods [message #1794713 is a reply to message #1794710] Wed, 05 September 2018 06:37 Go to previous messageGo to next message
Eclipse UserFriend
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 07:03 Go to previous message
Eclipse UserFriend
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
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: Wed Jun 25 01:58:30 EDT 2025

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

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

Back to the top