Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ComposedChecks are triggered twice
ComposedChecks are triggered twice [message #1069354] Mon, 15 July 2013 18:23 Go to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi,

I defined a Validator extending AbstractDeclarativeValidator and I declared it as one of ComposedChecks from the main xtext validator of my language and it seems that its checks are triggered twice for each elements!

Once the call tree goes through the main validator, and the second time it goes directly from an instance of the Validator.

Is that normal? I don't think so... I guess it is linked to the fact that if the RuntimeModule contain a eager singleton version of the class (which is not the case in the example given above), the validator is used by xtext.
I think maybe both ComposedChecks and singleton use functionalities are entering into conflict here....
Re: ComposedChecks are triggered twice [message #1069358 is a reply to message #1069354] Mon, 15 July 2013 18:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

so you have the Second validator bound in the runtime module too?

if so it will add itself to the validator registry and the main validator will call its methods too.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ComposedChecks are triggered twice [message #1069379 is a reply to message #1069358] Mon, 15 July 2013 19:44 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi, yes, I know that, what I meant is that:

IF
1) the second one is NOT bound in the runtime module
AND
2) it is declared as one the validators of the @ComposedChecks annotation on the first validator

THEN

@Checks annotated methods are called twice...
Re: ComposedChecks are triggered twice [message #1069384 is a reply to message #1069379] Mon, 15 July 2013 19:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

sorry i cannot reproduce this. the following works nicely with the greetings example

public class XV extends AbstractDeclarativeValidator {
	
	@Check(CheckType.NORMAL)
	public void checkIt(Greeting g) {
		System.out.println("lala");
	}
	
	@Override
	public void register(EValidatorRegistrar registrar) {
	}

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ComposedChecks are triggered twice [message #1069387 is a reply to message #1069384] Mon, 15 July 2013 20:04 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
ok, so what you mean is that by overriding register, I can prevent this validator to be registered and called twice: once by the register thing, and once as a composed check.

That makes sense Smile

Is that documented somewhere?

Thank you for your help!
Re: ComposedChecks are triggered twice [message #1069389 is a reply to message #1069387] Mon, 15 July 2013 20:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
hi i don't think that this is documented. i had a look at other composed validators.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ComposedChecks are triggered twice [message #1069391 is a reply to message #1069389] Mon, 15 July 2013 20:11 Go to previous message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Ok, thanks in any case, now I better understand how it works Smile
Previous Topic:code completion
Next Topic:[Resolved] XText Generator fails, how to debug?
Goto Forum:
  


Current Time: Tue Apr 16 10:31:53 GMT 2024

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

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

Back to the top