Skip to main content



      Home
Home » Modeling » EMF » [Xcore] derived containment
[Xcore] derived containment [message #1067579] Tue, 09 July 2013 08:29 Go to next message
Eclipse UserFriend
Hello.

I'd like to express the following with xcore:
A function has a name and optionally a return type. If it has a return type then it contains an additional variable having the same name as the function and the same type as the function.

class Variable {
   String varName
   String varType
}

class Function {
   String name
   String returnType
   contains Variable localVariables
   contains derived Variable returnVariable get {
      ... how can i create a Variable here
   }
   // i'm content also with
   op Variable getReturnVariable {
      ...
   } 
}


Is there a way to access the factory, in order to create a Variable instance?
Re: [Xcore] derived containment [message #1067618 is a reply to message #1067579] Tue, 09 July 2013 11:12 Go to previous message
Eclipse UserFriend
Ravasz,

Comments below.

On 09/07/2013 2:29 PM, Ravasz Roka wrote:
> Hello.
>
> I'd like to express the following with xcore:
> A function has a name and optionally a return type. If it has a return
> type then it contains an additional variable having the same name as
> the function and the same type as the function.
>
> class Variable {
> String varName
> String varType
> }
>
> class Function {
> String name
> String returnType
> contains Variable localVariables
> contains derived Variable returnVariable get {
> ... how can i create a Variable here
> }
In general, derived containment doesn't make sense. Such objects would
have be be contained somewhere else. It's also a problem that you have
no field in the implementation class in which to store the value once
you create it. So this type of thing is not well supported by the
features in Xcore today.
> // i'm content also with
> op Variable getReturnVariable {
> ...
> } }
>
>
> Is there a way to access the factory, in order to create a Variable
> instance?
What kind of editor are you building for this? You're likely better off
just modeling it like a normal containment reference and if you're using
a structured editor, always create the local variable as well. Another
approach (probably better) would be to create the variable automatically
when you set the return type or the name; but again, Xcore is not well
suited for expression that logic directly. You'll be better off
modifying the generated implementation class (which you can still do
with and Xcore model, but you should change the model directory folder
to src instead of src-gen so that it's never just deleted by a clean
build for example).
Previous Topic:Interface optimization
Next Topic:Invalid proxy URI after unloading a resource
Goto Forum:
  


Current Time: Tue Jul 08 10:21:39 EDT 2025

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

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

Back to the top