Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] model query with xTend(How can be found an element of a collection in xTend?)
[SOLVED] model query with xTend [message #637104] Thu, 04 November 2010 08:46 Go to next message
Philipp Missing name is currently offline Philipp Missing nameFriend
Messages: 7
Registered: November 2010
Junior Member
I have problems to determine whether a collection contains a certain element.

I use the following grammar (it is shown only partly).

gcsDefinitions: {gcsDefinitions}
	(datatypes+=Datatype)*
	'attributes' (attributes+=Attribute)* 'end'
	'timerAttributes' '{' (timerAttributes+=TimerAttribute)+ '}'
	;

TimerAttribute:
	name=ID;

Timer:
    'timer' name=ID
    ('attributes' (timerAttributes+=[TimerAttribute])*)?
    'timeconfig' (timeConfigPar=[ParTag]
              |timerValue=TimeValue|'stateDefined')
    ('IN' in=[Tag])?
    'end_timer';


The model looks like:

timerAttributes {ton withOutputTag withParameter restartable recalcable}

timer TransitionTime
attributes ton recalcable withOutputTag 
timeconfig stateDefined
end_timer	


The question is now, how can I check with xPand/xText whether a timer has a particular attribute?



[Updated on: Thu, 04 November 2010 10:07]

Report message to a moderator

Re: model query with xTend [message #637108 is a reply to message #637104] Thu, 04 November 2010 09:03 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Something like
Boolean hasAttribute(Timer timer, String name) : timer. timerAttributes.exists( a | a.name == name);

should do the trick (as an Xtend function; the right hand suffices for Xpand).


[Updated on: Thu, 04 November 2010 09:05]

Report message to a moderator

Re: model query with xTend [message #637117 is a reply to message #637104] Thu, 04 November 2010 09:29 Go to previous messageGo to next message
Philipp Missing name is currently offline Philipp Missing nameFriend
Messages: 7
Registered: November 2010
Junior Member
Many thanks for your help, it works!

Do you have any suggestions where I can get more information, documentation about the xPand/xTend functionality and syntax?

The 'Getting started' Tutorial I understand, but now I miss more detailed documentation.

Do exist books about this topic?

Do I have to learn more about EMF?



Re: model query with xTend [message #637128 is a reply to message #637117] Thu, 04 November 2010 10:02 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
The reference documentation: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .xpand.doc/help/ch01.html

AFAIK, there are no books on Xpand/Xtend/Xtext (not the dead tree-variant, anyway). It never hurts to learn (more) about EMF and there are books on that, although I've never read one: the reference documentation usually suffices.


Previous Topic:examples of ecore post processing
Next Topic:Linking to overloaded methods - getAllContents shouldn't be called on a global scope during linking
Goto Forum:
  


Current Time: Fri Apr 19 08:31:07 GMT 2024

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

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

Back to the top