Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Trigger validation manually
Trigger validation manually [message #1793562] Fri, 10 August 2018 07:13 Go to next message
Tim Mueller is currently offline Tim MuellerFriend
Messages: 3
Registered: November 2017
Junior Member
I have a validation method which checks for unused objects. If I define an object in resource A it gets marked in Eclipse as unused. If I open resource B and use this object, validation runs only for resource B but I also have to trigger validation for resource A to remove the Eclipse marker (object is now used). My indexer gives me already the information about resources which needs to be revalidated but how can I trigger the resource validation and where is the best place to do this? Is it possible to run only a subset of validation methods (just this one method to check for unused objects)?
Re: Trigger validation manually [message #1793595 is a reply to message #1793562] Fri, 10 August 2018 19:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12230
Registered: July 2009
Senior Member
if you have a own infrastructor to track usage changes then you could use that in the
org.eclipse.xtext.ui.validation.DefaultResourceUIValidatorExtension.updateValidationMarkers(IFile, Resource, CheckMode, IProgressMonitor)
method and call the same for another file/resource


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trigger validation manually [message #1793604 is a reply to message #1793595] Sat, 11 August 2018 02:52 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 134
Registered: July 2009
Location: Canada
Senior Member
This might help - https://nbhusare.github.io/main/2018/04/21/invoking-cross-dsl-validations.html

Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Trigger validation manually [message #1793646 is a reply to message #1793604] Mon, 13 August 2018 07:41 Go to previous messageGo to next message
Tim Mueller is currently offline Tim MuellerFriend
Messages: 3
Registered: November 2017
Junior Member
Thanks! Overriding isAffected() in the DefaultResourceDescriptionManager does the trick but now I have another problem. I thought that my indexer works as expected but it doesn't. I rely on linking during the index built-up phase but this assumption seams to be wrong.

Now I try to put all references in the index and evaluate the list of reference descriptions in each resource description. If I open my DSL Eclipse project and press "Clean project" the access to the reference descriptions is not allowed (IllegalStateException) because the resource descriptions are CopiedResourceDescriptions. I have to open all of my DSL files, trigger a reparse (e.g. add a blank line) to get a "normal" resource description where all reference descriptions are set. My idea is now to get rid of the CopiedResourceDescriptions after a "Clean project" by simulating a change on all files. How can I do this or is there a better way to solve my problem (finding unused objects)?
Re: Trigger validation manually [message #1793721 is a reply to message #1793646] Tue, 14 August 2018 14:42 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 134
Registered: July 2009
Location: Canada
Senior Member
Can you please share an example that demonstrates the problem. Tx.

Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Trigger validation manually [message #1793723 is a reply to message #1793721] Tue, 14 August 2018 14:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12230
Registered: July 2009
Senior Member
the main problem: you cannot rely on reference descriptions to do the validation.
you would have to store the "usage" information in userdata and read it from there.


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trigger validation manually [message #1793754 is a reply to message #1793723] Wed, 15 August 2018 08:45 Go to previous messageGo to next message
Tim Mueller is currently offline Tim MuellerFriend
Messages: 3
Registered: November 2017
Junior Member
@Neeraj: As an example consider two DSL files (EMF resources). In resource A I define an object (e.g. define x int). In resource B I use this object (e.g. x = 123), so there is a cross-reference from resource B to resource A. If I edit resource B and remove the assignment I want to mark "define x int" in resource A as "unused". If I add "x = 123" again I should see the warning again.

@Christian: How can I do this? If I am right, then indexing runs before linking which means I cannot put assignments / cross references in my index (see example above). I cannot store the destination uri in the userdata (because I don't know it at this time). After a "Clean project" the process is something like "indexing A" -> "indexing B" (I don't know where x points to, CopiedResourceDescription is created?!) -> "linking A" -> "linking B" (now I know the destination of x). Is it possible to trigger the recreation of ResourceDescription again, because after all resources are linked and validated Xtext knows all cross-references between resources and I could run my " unused object check"?
I can manually trigger ResourceDescription recreation by open each DSL-file and add a blank line. After this everything works as expected but it is not so handy... ;)
Re: Trigger validation manually [message #1793767 is a reply to message #1793754] Wed, 15 August 2018 12:51 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12230
Registered: July 2009
Senior Member
i dont know your grammar: but depending on the grammar it might be possible to store in the userdata of the "users" that they use stuff that is called "a" "b" "c" (read via node model)
then you can use that information to calculate what is used and what not after indexing.


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Using arrays Arrays and DotNotation in Expressions
Next Topic:C-like multiple declaration
Goto Forum:
  


Current Time: Thu Sep 20 10:58:50 GMT 2018

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

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

Back to the top