Skip to main content



      Home
Home » Modeling » EMF » [XCore/Xbase] Filtering
[XCore/Xbase] Filtering [message #1019179] Fri, 15 March 2013 03:26 Go to next message
Eclipse UserFriend
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 04:31 Go to previous messageGo to next message
Eclipse UserFriend
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 05:14 Go to previous messageGo to next message
Eclipse UserFriend
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 06:11 Go to previous messageGo to next message
Eclipse UserFriend
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 13:40 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 21:14:59 EDT 2025

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

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

Back to the top