Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Standalone Custom Validation Not Being Called
Standalone Custom Validation Not Being Called [message #1863907] Tue, 05 March 2024 12:52 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I'm very perplexed by this and have never seen it before. When running our standalone compiler, our custom DslValidator is not being called at all. No breakpoints within that validator are ever hit.

Conversely, the validator works perfectly in the Eclipse GUI _and_ the small number of unit test cases we have that test the validator actually work! The junit tests run in standalone, so it's baffling why standalone doesn't work.
Since our junit tests successfully call at least one of our custom validations, I know my stand alone setup should be configured correctly (or the tests would not work)

Our standalone compiler does flag basic parsing errors, linking errors, and names are unique validation, but nothing else. So none of our semantic checks are triggered.

Yes, our Main.java for the standalone compiler calls validate of our injected IResourceValidator. I've copied/pasted Main.java code that has worked perfectly for several DSLs I've done before, but it's coming up with an empty list of issues (when it should have some errors and warnings and infos from our semantic validators)

This is my first time ever attempting to use ComposedChecks so I feel like it has something to do with that. (hard to find documentation on this)

But I don't even know where to start for debugging this - well, I started with breakpoints in our DslValidator, but none of them are hit.

Any ideas?

Xtext 2.31, Java 17, Ecilpse 2023-06

[Updated on: Tue, 05 March 2024 13:02]

Report message to a moderator

Re: Standalone Custom Validation Not Being Called [message #1863908 is a reply to message #1863907] Tue, 05 March 2024 13:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
i propose to debug your standalone compiler and the parts there
e.g.

org.eclipse.xtext.validation.AbstractInjectableValidator.register(EValidatorRegistrar)
validate in CompositeEValidator

in ui: is it hit on the editor or on the file (might be a casing sensitivity thing)
see

org.xtext.example.mydsl.MyDslStandaloneSetupGenerated.register(Injector)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Standalone Custom Validation Not Being Called [message #1863909 is a reply to message #1863908] Tue, 05 March 2024 13:34 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Christian Dietrich wrote on Tue, 05 March 2024 08:07
i propose to debug your standalone compiler and the parts there
e.g.

org.eclipse.xtext.validation.AbstractInjectableValidator.register(EValidatorRegistrar)


That's an interesting start. The following line returns packages as a single entry with a value of null. That can't be good.

	@Inject
	public void register(EValidatorRegistrar registrar) {
		Collection<EPackage> packages = new LinkedHashSet<EPackage>(getEPackages());

Re: Standalone Custom Validation Not Being Called [message #1863910 is a reply to message #1863909] Tue, 05 March 2024 13:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
are you using generated or manual metamodels?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Standalone Custom Validation Not Being Called [message #1863911 is a reply to message #1863909] Tue, 05 March 2024 13:50 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I do have two DSLs. DSL2 does not extend DSL1.

It looks like the EPackage for DSL1 is found, but the EPackage for DSL2 is returning null. Seems like a very basic thing that is going wrong
Re: Standalone Custom Validation Not Being Called [message #1863912 is a reply to message #1863910] Tue, 05 March 2024 13:51 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Christian Dietrich wrote on Tue, 05 March 2024 08:47
are you using generated or manual metamodels?


We have a manually described model. Used the Xtext wizard to generate our DSL from an existing model.

referenced genmodel in the mwe2 looks correct to me.

[Updated on: Tue, 05 March 2024 13:53]

Report message to a moderator

Re: Standalone Custom Validation Not Being Called [message #1863913 is a reply to message #1863912] Tue, 05 March 2024 14:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
then you need to do something like

XtypeStandaloneSetup.createInjectorAndDoEMFRegistration does


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Standalone Custom Validation Not Being Called [message #1863922 is a reply to message #1863913] Wed, 06 March 2024 12:33 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Christian, thank you so much. You are a real treasure of Xtext.

I'm not sure why I had to override createInjectorAndDoEMFRegistration in Xtext 2.31 vs 2.22 and 2.18, but once I did that, everything works!
Re: Standalone Custom Validation Not Being Called [message #1864032 is a reply to message #1863922] Tue, 12 March 2024 15:12 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Sorry, changing topics slightly, but seems related.

Curiously, we've made some progress getting our LS to run in VSCode and it's exhibiting the same symptom that we only get basic parsing validation, unique names validation, and linking validation, but are not getting any of our custom semantic validation called.

Is there any clues as to why the standalone configuration and the LS might be skipping the semantic validation - in your experience?

We are also seeing that testing the LS in Eclipse is also not triggering our customer semantic validation. So that points to a problem/configuration in the generation of the LS and not VSCode specifically.

Xtext 2.31 and LSP4J 0.21.0

[Updated on: Tue, 12 March 2024 16:34]

Report message to a moderator

Re: Standalone Custom Validation Not Being Called [message #1864047 is a reply to message #1864032] Wed, 13 March 2024 11:34 Go to previous message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Turns out, not related at all. We got our validation working in the LS now. Totally different mistake.
Previous Topic:Tree view on model file on the first run not working
Next Topic:Logging in xtext
Goto Forum:
  


Current Time: Sat Dec 14 19:41:31 GMT 2024

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

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

Back to the top