Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validation (warning) when object is not used
Validation (warning) when object is not used [message #1804343] Fri, 22 March 2019 17:35 Go to next message
Željko Kovačević is currently offline Željko KovačevićFriend
Messages: 16
Registered: March 2019
Junior Member
Hi,

I would like to give warning for the variable (object) that was declared but never used in code. Any example for this?
Re: Validation (warning) when object is not used [message #1804416 is a reply to message #1804343] Mon, 25 March 2019 19:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13118
Registered: July 2009
Senior Member
do you want to do this locally or globally.
if locally: simply traverse the file for references
if globally: this will be hard. you have to do this in the index. and do it as expensive validation which is explicitely triggered


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation (warning) when object is not used [message #1804417 is a reply to message #1804416] Mon, 25 March 2019 20:05 Go to previous messageGo to next message
Željko Kovačević is currently offline Željko KovačevićFriend
Messages: 16
Registered: March 2019
Junior Member
Locally will do for now. Your answer in my previous topic helped me to understand how to traverse the file for references.

Thanks!
Re: Validation (warning) when object is not used [message #1804419 is a reply to message #1804417] Mon, 25 March 2019 20:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13118
Registered: July 2009
Senior Member
well i would be doing basically the same.
traverse the tree. looks where references are.
maybe use org.eclipse.xtext.EcoreUtil2.findCrossReferences(EObject, Set<? extends EObject>, ElementReferenceAcceptor)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation (warning) when object is not used [message #1804420 is a reply to message #1804419] Mon, 25 March 2019 20:18 Go to previous messageGo to next message
Željko Kovačević is currently offline Željko KovačevićFriend
Messages: 16
Registered: March 2019
Junior Member
Yes. I understood that I need to traverse but didn't know how.

Like I said, I am just a beginner :)
Re: Validation (warning) when object is not used [message #1804422 is a reply to message #1804420] Mon, 25 March 2019 20:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13118
Registered: July 2009
Senior Member
the esiest is to traverse your model along the structure

ask model for its models
have a look if there are student, course, enroll.
have a looks at the references within these


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Space validation
Next Topic:Troubles understanding Qualified Name
Goto Forum:
  


Current Time: Tue Sep 17 04:39:45 GMT 2019

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

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

Back to the top