Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1268446/#msg_1268446
according to the code below, could you please tell me how (and if it possible to) refer to the array defined inside the class ComputationUnit from the class Service?
class ComputationUnit{
contains Method[1..*] methods
}
class Method{
String name
String signature
Object sourceCode
contains Parameter[1..*] parameters
}
class Service{
contains Comment comment
contains Parameter[1..*] parameters
contains Contract[0..*] contracts
refers Method[] methods //How can I refer to the array defined inside the ComputationUnit class?
}]]>Simone Di Cola2014-03-10T14:08:38-00:00Re: [XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1268566/#msg_1268566
This is again a question of navigation and with only snippets of the
model, it's not clear how to answer...
On 10/03/2014 3:08 PM, Simone Di Cola wrote:
> Hi all,
> according to the code below, could you please tell me how (and if it
> possible to) refer to the array defined inside the class
> ComputationUnit from the class Service?
>
> class ComputationUnit{
> contains Method[1..*] methods }
>
> class Method{
> String name
> String signature
> Object sourceCode
> contains Parameter[1..*] parameters
> }
>
> class Service{
> contains Comment comment
> contains Parameter[1..*] parameters
> contains Contract[0..*] contracts
> refers Method[] methods //How can I refer to the array defined
> inside the ComputationUnit class?
> }]]>Ed Merks2014-03-10T17:24:01-00:00Re: [XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1268579/#msg_1268579
class ComputationUnit{
contains Method[1..*] methods
op Method getMethod(String methodSignature) {
for (Method method : methods) {
if(method.signature == methodSignature) return method
}
return null
}
}
class Method{
String signature
String sourceCode
contains Parameter[1..*] parameters
}
class MethodReference{
contains Method methodReference
}
m1.setSignature("void increment ( int m, int &n )");
mr.setMethodReference(m1);
s1.getMethodReferences().add(mr);
Do you know a better way to do it?
Thanks
Simone
]]>Simone Di Cola2014-03-10T17:45:47-00:00Re: [XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1268595/#msg_1268595
Comments below.
On 10/03/2014 6:45 PM, Simone Di Cola wrote:
> Thanks ED for your answer. Following your advice in my previous topic,
> I've come up with this implementation:
>
> class ComputationUnit{
> contains Method[1..*] methods
> op Method getMethod(String methodSignature) {
> for (Method method : methods) {
> if(method.signature == methodSignature) return method
That seems reasonable, but you'll want to be pretty sure that signatures
such as void increment ( int m, int &n ) use a consistent whitespace
convention if you're going to use String equality... Note too that
using Xbase's closures you can express this more elegantly... The Xtend
documentation shows some of these nice capabilities...
> }
> return null
> }
> }
>
> class Method{
> String signature
> String sourceCode
> contains Parameter[1..*] parameters
> }
>
>
> class MethodReference{
> contains Method methodReference
> }
>
> class Service{
> contains MethodReference[1..*] methodReferences
> contains Comment comment
> contains Parameter[1..*] parameters
> contains Contract[0..*] contracts
> }
>
> So now I can assign a reference of a Method to a service by doing
> something like this:
> Service s1 = factory.createService();
> Method m1 = factory.createMethod();
> MethodReference mr = factory.createMethodReference();
>
> m1.setSignature("void increment ( int m, int &n )");
> mr.setMethodReference(m1);
> s1.getMethodReferences().add(mr);
>
> Do you know a better way to do it?
> Thanks
> Simone
>
>
>
>]]>Ed Merks2014-03-10T18:13:47-00:00Re: [XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1272391/#msg_1272391
how can I define a not contained EReference? I mean, how can I define a reference without using the contains keyword? (if it is possible of course)
Simone ]]>Simone Di Cola2014-03-17T20:20:09-00:00Re: [XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1272399/#msg_1272399
Keep in mind that context completion proposals will show you the
keywords (though very far down in the list). The "refers" keyword is
used to specify cross references.
On 17/03/2014 1:20 PM, Simone Di Cola wrote:
> Hi Ed,
> how can I define a not contained EReference? I mean, how can I define
> a reference without using the contains keyword? (if it is possible of
> course)
> Simone]]>Ed Merks2014-03-17T20:40:24-00:00Re: [XCORE] How to define a non cross reference
https://www.eclipse.org/forums/index.php/mv/msg/670145/1272629/#msg_1272629
It was so obvious.
Thanks again
Simone
]]>Simone Di Cola2014-03-18T11:15:31-00:00