Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsUsing toIterable.FindFirst in Generator
https://www.eclipse.org/forums/index.php/mv/msg/446488/997288/#msg_997288
Assuming the following Xtext grammar rules:
And, assuming that among a number of resources there is one as follows:
Resource abc
size = "large"
color = "blue"
Within MyDslGenerator, I want to use findFirst() to get value of
the Property whose name = size
from the resource whose name = abc.
For example,
val item = resource.resourceSet.allContents.toIterable.findFirst(????????)
I see that findFirst expects Iterable<T>, Function1<? super T, Boolean>
But, I have no clue as to how to supply this. I have spend hours, in vain, trying to find an example.
Thank you in advance for taking time to provide me an example of how to use the findFirst function in the context of IterableExtensions.
]]>Michael Colburn2013-01-05T00:00:49-00:00Re: Using toIterable.FindFirst in Generator
https://www.eclipse.org/forums/index.php/mv/msg/446488/997612/#msg_997612
..toIterable.filter(typeof(MyType))
Then you can pass a closure to the find first
..findFirst[MyType x|x.name=="abc"]) or short
FindFirst[name=="abc"]
--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de]]>Christian Dietrich2013-01-05T08:11:01-00:00Re: Using toIterable.FindFirst in Generator
https://www.eclipse.org/forums/index.php/mv/msg/446488/997765/#msg_997765
Michael Colburn2013-01-08T17:42:43-00:00