Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Getting all instances of particular grammar class
Getting all instances of particular grammar class [message #1033840] Thu, 04 April 2013 17:55 Go to next message
Mariusz Mariusz is currently offline Mariusz MariuszFriend
Messages: 17
Registered: April 2012
Junior Member
First of all: great job with Xtext!

I am trying to find all instances (from all source files edited in Eclipse) of a particular grammar class, e.g. Entity (from the tutorial) - I need it for validation. Right now I am able to do it in a single file. I think I have read somewhere about an Eclipse's global cache with all instances but I am not able to find it.
Can anybody please help?
Re: Getting all instances of particular grammar class [message #1033858 is a reply to message #1033840] Thu, 04 April 2013 18:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
http://www.eclipse.org/forums/index.php/mv/msg/261440/754503/#msg_754503

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Getting all instances of particular grammar class [message #1033878 is a reply to message #1033858] Thu, 04 April 2013 18:54 Go to previous messageGo to next message
Mariusz Mariusz is currently offline Mariusz MariuszFriend
Messages: 17
Registered: April 2012
Junior Member
Christian Dietrich wrote on Thu, 04 April 2013 14:24
http://www.eclipse.org/forums/index.php/mv/msg/261440/754503/#msg_754503

Thanks for the quick answer, but I am not sure if this is the right one for me.
The solution is based on a "starting point": Greeting greeting.
My problem is that I would like to find all items of type Package inside Import's validator (to validate if the provided one is on the list of all packages). Moreover I would like to add code completion for the Import with the list of all Packages.
I think that I need something like a class method: "UtilityClass.GetAllInstances(Class)".
Any ideas?
Re: Getting all instances of particular grammar class [message #1033886 is a reply to message #1033878] Thu, 04 April 2013 19:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the links shows you how to get all greetings ?!?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Getting all instances of particular grammar class [message #1033930 is a reply to message #1033886] Thu, 04 April 2013 20:38 Go to previous messageGo to next message
Mariusz Mariusz is currently offline Mariusz MariuszFriend
Messages: 17
Registered: April 2012
Junior Member
Christian Dietrich wrote on Thu, 04 April 2013 15:02
Hi,

the links shows you how to get all greetings ?!?

Yes, but starting from a greeting. In my case, I need to find all Packages inside (starting from) an Import's validator. I would like to get all Packages even those from other source files (Eclipse/Ecor's Resources).
Re: Getting all instances of particular grammar class [message #1033933 is a reply to message #1033930] Thu, 04 April 2013 20:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the starting point can be ANY!!!! EObject !!!!
And it gives all Greetings in all files of the project and referenced project.
just give it a try!

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 04 April 2013 20:45]

Report message to a moderator

Re: Getting all instances of particular grammar class [message #1034233 is a reply to message #1033933] Fri, 05 April 2013 07:14 Go to previous messageGo to next message
Mariusz Mariusz is currently offline Mariusz MariuszFriend
Messages: 17
Registered: April 2012
Junior Member
Christian Dietrich wrote on Thu, 04 April 2013 16:44
Hi,

the starting point can be ANY!!!! EObject !!!!
And it gives all Greetings in all files of the project and referenced project.
just give it a try!

~Christian

Thanks Christian - you were right. Razz
But I have two additional problems/remarks:
- Initially my method getting all packages was written as a static one (because it is accessed from a few different locations of my program). I had to remove the 'static' and put it inside the content provider class because injecting of ResourceDescriptionsProvider and IContainer.Manager was not working. How can I "manually inject" this data (to make the method static)?
- Is there a way to get rid of this EObject starting point? Maybe a list of all reosurces (ResourceSet) for this project/workspace?
Re: Getting all instances of particular grammar class [message #1034272 is a reply to message #1034233] Fri, 05 April 2013 08:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

simple make a non static util and inject it where you need it.
yes you can inject IResourcedescriptions pure and ask it for getExportedObjectsByType
but this will not take care about visibility rules


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Getting all instances of particular grammar class [message #1034560 is a reply to message #1034272] Fri, 05 April 2013 15:31 Go to previous message
Mariusz Mariusz is currently offline Mariusz MariuszFriend
Messages: 17
Registered: April 2012
Junior Member
Christian - thanks again for your help.
Previous Topic:Problem Importing Other Languages
Next Topic:Indentation around formatting
Goto Forum:
  


Current Time: Thu Apr 25 12:38:19 GMT 2024

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

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

Back to the top