Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validation method not being called(Only one check method is called)
Validation method not being called [message #1843883] Mon, 23 August 2021 09:41 Go to next message
Jeff Lowcock is currently offline Jeff LowcockFriend
Messages: 17
Registered: July 2009
Junior Member
I have begun to customise the validator

The first method I wrote works like a charm.

@Check(CheckType.FAST)
public void checkEnvironmentSyntax(Environment env)
{
System.err.println("syn ");

the second, third and fourth method I added to the validator are never called

@Check
public void checkAssignment(Assignment r)
{
System.err.println("ass "+adapter.getSrc() + " "+adapter.getTgt());

Given there is no configuration changes between the two scenarios I have nowhere to go to check why they are not being called

So any hints of where look or what to change - alittle frustraing when all the instructions are "do this, then that, and it just works" when in fact it doesn't.

Oh well back into the fog

[Updated on: Mon, 23 August 2021 09:43]

Report message to a moderator

Re: Validation method not being called [message #1843884 is a reply to message #1843883] Mon, 23 August 2021 09:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14340
Registered: July 2009
Senior Member
can you please post all FQNs for the parameter classes?
did you restart between tests?
can you debug
org.eclipse.xtext.validation.AbstractDeclarativeValidator.MethodWrapper constructions and invocations?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation method not being called [message #1843885 is a reply to message #1843884] Mon, 23 August 2021 11:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7507
Registered: July 2009
Senior Member
Hi

You only show one 'second' method which has an obvious difference: not CheckType.FAST

so a possibility is that you are not activating non CheckType.FAST checks.

Easily checked by cloning the first for a different element.

The above should then enable you do debug the successful invocation of one variant and the unsuccessful invocation of another.

Maybe you have build disabled so nothing changes, Maybe you are editing the wrong files, perhaps because while debugging you copied and pasted a project. Maybe an exception is thrown terminating the validation ....

Regards

Ed Willink
Re: Validation method not being called [message #1843916 is a reply to message #1843885] Tue, 24 August 2021 12:12 Go to previous messageGo to next message
Jeff Lowcock is currently offline Jeff LowcockFriend
Messages: 17
Registered: July 2009
Junior Member
Ed's comments checked and none of those were the issue, extra details as requested, still trying to figure out how to debug org.eclipse.xtext.validation.AbstractDeclarativeValidator.MethodWrapper.
Restart between tests yes, changed run configuration to clean prior to launch no improvement.

Additional Detail added mostly to show where I am at - still reading and trying debug as next step.

This is the method that works

@Check(CheckType.FAST)
public void checkEnvironmentSyntax(Environment env)

These next three (the only ones added after the first method was working and still does)
@Check(CheckType.FAST)
public void checkAssignment(Assignment r)

@Check(CheckType.FAST)
public void checkSrcReferenceSemantic(SrcReference r)

@Check(CheckType.FAST)
public void checkTgtReferenceSemantic(TgtReference r)

The parameter classes
org.vigorous.dopi.lang.inst.transform.transform.Environment
org.vigorous.dopi.lang.inst.transform.transform.Assignment
org.vigorous.dopi.lang.inst.transform.transform.SrcReference
org.vigorous.dopi.lang.inst.transform.transform.TgtReference

All in the same package so nothing there

Re: Validation method not being called [message #1843919 is a reply to message #1843916] Tue, 24 August 2021 12:27 Go to previous messageGo to next message
Jeff Lowcock is currently offline Jeff LowcockFriend
Messages: 17
Registered: July 2009
Junior Member
And now for added embarrassment - went back just to be sure I had looked at everything - forest for the trees - at the end of the first method an exception was thrown so no further processing done - problem solved "operator error".
Thank you all for your kind attention.
Re: Validation method not being called [message #1843923 is a reply to message #1843919] Tue, 24 August 2021 14:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14340
Registered: July 2009
Senior Member
exceptions that disturb the validation should be logged. werent they?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation method not being called [message #1843924 is a reply to message #1843923] Tue, 24 August 2021 15:13 Go to previous messageGo to next message
Ed Merks is currently online Ed MerksFriend
Messages: 32452
Registered: July 2009
Senior Member
I have noticed that org.eclipse.xtext.validation.AbstractDeclarativeValidator.MethodWrapper.invoke(State) calls org.eclipse.xtext.validation.AbstractDeclarativeValidator.MethodWrapper.handleInvocationTargetException(Throwable, State):
		protected void handleInvocationTargetException(Throwable targetException, State state) {
			// ignore GuardException, check is just not evaluated if guard is false
			// ignore NullPointerException, as not having to check for NPEs all the time is a convenience feature
			if (!(targetException instanceof GuardException) && !(targetException instanceof NullPointerException))
				Exceptions.throwUncheckedException(targetException);
		}
And that swallows NPE as a convenience...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validation method not being called [message #1843927 is a reply to message #1843924] Tue, 24 August 2021 17:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14340
Registered: July 2009
Senior Member
yes but npe wont stop other validatons with this.
so i wonder what exception jeff faced.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation method not being called [message #1843950 is a reply to message #1843927] Wed, 25 August 2021 13:39 Go to previous messageGo to next message
Jeff Lowcock is currently offline Jeff LowcockFriend
Messages: 17
Registered: July 2009
Junior Member
I discovered the NPE in my code in the validator as I was debugging my way towards org.eclipse.xtext.validation.AbstractDeclarativeValidator.MethodWrapper found my logic error. Stopped debugging, repaired my code, run again. Everything worked as expected. So the NPE was being swallowed and then no further @Check methods were called. I am still in early days of using Xtext and so was unsure where to look. Once again Christian provide a guide and I was able to resolve after after more reading and understanding.
Re: Validation method not being called [message #1843954 is a reply to message #1843950] Wed, 25 August 2021 14:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7507
Registered: July 2009
Senior Member
Hi

I find that when debugging it is always worth having breakpoints on NPE, ISE, UOE, IOOBE, CCE, CME, NSE, AFE so that 'lost' diagnostics are seen.

Unfortunately some 'poor' code fails to pre-guard against such exceptions so you may need to filter some breakpoints once you realize that they are bogus.

Regards

Ed Willink
Re: Validation method not being called [message #1843992 is a reply to message #1843954] Thu, 26 August 2021 10:40 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14340
Registered: July 2009
Senior Member
@jeff this is not the intended behaviour

having an npe in one method should not stop a SECOND method to be called. it only will stop the CURRENT method
if so please create an issue with a small reproducer at github.com/eclipse/xtext-core


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 26 August 2021 10:40]

Report message to a moderator

Previous Topic:Xtend gradle builder leaves java files for deleted Xtend files behind
Next Topic:Trigger build automatically
Goto Forum:
  


Current Time: Thu Aug 18 11:18:21 GMT 2022

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

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

Back to the top