Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to retrieve all instances of given grammar class?
How to retrieve all instances of given grammar class? [message #805332] Thu, 23 February 2012 16:39 Go to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
Is it possible to retrieve a list of all instances of a given type, i.e. independent of containment relations? For example, assume I have grammar:

Domain:
	'Domain' name=ID '{'
	(elements+=Class)*
	'}';

Class:
  'Class' name=ID '{'
    (features+=ClassFeature)*
  '}';

ClassFeature: 
   //etc.


Is there a way to retrieve a list of all ClassFeature instances? Preferably without having to navigate to the domain instance then iterating down the containment hierarchy.

If navigating the hierarchy is the only way, how to get a reference to the root element?

Thx.



Re: How to retrieve all instances of given grammar class? [message #805347 is a reply to message #805332] Thu, 23 February 2012 16:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13423
Registered: July 2009
Senior Member
Hi do you know ECoreUtil2.getAllContentsOfType
Regards Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to retrieve all instances of given grammar class? [message #805355 is a reply to message #805347] Thu, 23 February 2012 17:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13423
Registered: July 2009
Senior Member
PS: you may have to use EcoreUtil.getrootcontainer anyway depending
from where you start


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to retrieve all instances of given grammar class? [message #805372 is a reply to message #805355] Thu, 23 February 2012 17:30 Go to previous message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
Perfect - thanks.
Previous Topic:extending generator's method in runtime
Next Topic:When to use createLiveScopeResourceDescriptions?
Goto Forum:
  


Current Time: Mon Apr 06 02:44:16 GMT 2020

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

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

Back to the top