Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCore/Xbase] Filtering
[XCore/Xbase] Filtering [message #1019179] Fri, 15 March 2013 07:26 Go to next message
Martin  odloucký is currently offline Martin odlouckýFriend
Messages: 49
Registered: July 2010
Member
Hi,

I am trying to do something like this in my XCore source file

class A {
//some code
}

class B extends A {
//more code
}

class C {
contains A[] collection

op B[] filterB() {
return collection.filter(B)
}
}

The editor complains that it does not know class B. So how do I reference a class from my XCore file in Xbase code?

Another problem is that filter() returns Iterable but I have to return EList from filterB. How do I convert the former one to the later?

Is there any documentation of xbase that would describe how the xbase can be used with xcore?

Thanks in advance
Re: [XCore/Xbase] Filtering [message #1019203 is a reply to message #1019179] Fri, 15 March 2013 08:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
Martin,

This does the trick:

op B[] filterB() {
return collection.filter(typeof(B)).toEList();
}

I had to ask Sebastian about this typeof thing. In general all the
methods in ECollections and EcoreUtil are extension methods, i.e.,
that's where toEList comes from. The Xtext project page is the best
source for information about Xbase. Xcore simply reuses it...


On 15/03/2013 8:27 AM, Martin odloucký wrote:
> Hi,
> I am trying to do something like this in my XCore source file
>
> class A {
> //some code
> }
>
> class B extends A {
> //more code
> }
>
> class C {
> contains A[] collection
>
> op B[] filterB() {
> return collection.filter(B)
> }
> }
>
> The editor complains that it does not know class B.
What are you trying to call here
> So how do I reference a class from my XCore file in Xbase code?
> Another problem is that filter() returns Iterable but I have to return
> EList from filterB. How do I convert the former one to the later?
>
> Is there any documentation of xbase that would describe how the xbase
> can be used with xcore?
>
> Thanks in advance
Re: [XCore/Xbase] Filtering [message #1019225 is a reply to message #1019203] Fri, 15 March 2013 09:14 Go to previous messageGo to next message
Martin  odloucký is currently offline Martin odlouckýFriend
Messages: 49
Registered: July 2010
Member
Thank you very much Ed! The typeof works. But I am still gettin error on the toEList function: Couldn't resolve reference to JvmIdentifiable 'toEList'. Neither I see any method of such name in ECollections or EcoreUtil classes.
Re: [XCore/Xbase] Filtering [message #1019249 is a reply to message #1019225] Fri, 15 March 2013 10:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
Martin,

Best you use the EMF 2.9 (Xcore 1.1) stream because lots of things were
fixed and added.

On 15/03/2013 10:14 AM, Martin odloucký wrote:
> Thank you very much Ed! The typeof works. But I am still gettin error
> on the toEList function: Couldn't resolve reference to JvmIdentifiable
> 'toEList'. Neither I see any method of such name in ECollections or
> EcoreUtil classes.
Re: [XCore/Xbase] Filtering [message #1020674 is a reply to message #1019249] Mon, 18 March 2013 17:40 Go to previous message
Martin  odloucký is currently offline Martin odlouckýFriend
Messages: 49
Registered: July 2010
Member
Thank you very much Ed! Works fine.
Previous Topic:How to control default javadoc creation..
Next Topic:Could not initialize class org.eclipse.emf.server.ecore.resource.DatastoreUtil
Goto Forum:
  


Current Time: Fri Dec 19 20:28:45 GMT 2014

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

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