Skip to main content



      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 13:35 Go to next message
Eclipse UserFriend
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 15:32 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Validation (warning) when object is not used [message #1804417 is a reply to message #1804416] Mon, 25 March 2019 16:05 Go to previous messageGo to next message
Eclipse UserFriend
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 16:08 Go to previous messageGo to next message
Eclipse UserFriend
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)
Re: Validation (warning) when object is not used [message #1804420 is a reply to message #1804419] Mon, 25 March 2019 16:18 Go to previous messageGo to next message
Eclipse UserFriend
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 16:30 Go to previous message
Eclipse UserFriend
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
Previous Topic:Space validation
Next Topic:Troubles understanding Qualified Name
Goto Forum:
  


Current Time: Wed Apr 30 19:44:54 EDT 2025

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

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

Back to the top