Skip to main content



      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 05:58 Go to next message
Eclipse UserFriend
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 06:23 Go to previous messageGo to next message
Eclipse UserFriend
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)
Re: Inheriting from Java based validator fails due to changed naming [message #1755671 is a reply to message #1755542] Mon, 06 March 2017 12:44 Go to previous message
Eclipse UserFriend
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 Jul 12 09:00:22 EDT 2025

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

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

Back to the top