Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Inheriting from Java based validator fails due to changed naming
Inheriting from Java based validator fails due to changed naming [message #1755539] Sun, 05 March 2017 10:58 Go to next message
Thomas Kutz is currently offline Thomas KutzFriend
Messages: 4
Registered: July 2013
Junior Member
Hi all,

I have a DSL which inherits from another thirdparty language. I also want my validator to inherit from that language one's. However, the thirdparty validator I want to inherit from is named "[DslName]JavaValidator " which causes compilation problems because the generated code tries to inherit from "[DslName]Validator" (note the missing 'Java').

Is there any way to configure the MWE workflow to compute the old naming?

My solution would be to bind a custom ValidatorNaming implementation, but this has the drawback that my own validator, which is intended to be Xtend based, also gets the 'Java' part into its class name.

class MyDslWorkflowLanguage extends StandardLanguage {

	override getGuiceModule() {
		Modules.override(super.getGuiceModule()).with(new Module() {
			override configure(Binder binder) {
				binder.bind(ValidatorNaming).to(OldValidatorNaming)
			}
		})
	}
}

class OldValidatorNaming extends ValidatorNaming {

	@Inject extension XtextGeneratorNaming

	override getValidatorClass(Grammar grammar) {
		val runtimeBasePackage = grammar.runtimeBasePackage + ".validation."
		val simpleName = grammar.simpleName
		val name = runtimeBasePackage + simpleName + "JavaValidator"
		return new TypeReference(name)
	}
}
Re: Inheriting from Java based validator fails due to changed naming [message #1755542 is a reply to message #1755539] Sun, 05 March 2017 11:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11307
Registered: July 2009
Senior Member
yes the *JavaValidator* nameing is outdated for years now, the generator assumes that both languages uses the current naming scheme.
if you have the base lang under control have a look at its workflow and the usage of

fragment = validation.ValidatorFragment auto-inject {} (old workflow, new validator naming)

vs

fragment = validation.JavaValidatorFragment {} (old workflow, old validator naming)


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Inheriting from Java based validator fails due to changed naming [message #1755671 is a reply to message #1755542] Mon, 06 March 2017 17:44 Go to previous message
Thomas Kutz is currently offline Thomas KutzFriend
Messages: 4
Registered: July 2013
Junior Member
Thanks for the prompt answer.
Previous Topic:A slot with name 'uml-gen' has not been configured exception
Next Topic:Servlet Session ID
Goto Forum:
  


Current Time: Sat Oct 21 04:55:29 GMT 2017

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

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