Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » obtain class from operation
obtain class from operation [message #1787105] Fri, 18 May 2018 19:42 Go to next message
Dim Gle is currently offline Dim GleFriend
Messages: 5
Registered: April 2018
Junior Member
Hello,
Is it possible to obtain from an operation the class where it is defined? I need to call a template like this [template public genRefMethod(c : Class)] from the reference of an operation. I found that getNamespace().name return me the name of the class but I need the reference of the class and not the string of the name.

Thank you in advance.
Dim
Re: obtain class from operation [message #1787117 is a reply to message #1787105] Sat, 19 May 2018 05:23 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Acceleo is an implementation of MOFM2T which is a modeling language. You should therefore use model references such as "namespace" and "name". "getNamespace()" is a bonus exploiting the underlying EMF implementation. Arguably it should not be available at all.

Assuming you are using the UML metamodel for which Fig 9.13 of the UML 2.5 spec shows that an Operation may be contained by an "interface", "datatype" or "class", so if you want the Class just use "class". Since Operation is an Element you can also use "owner". If "class" is a reserved word you will need to escape it as an underscore-prefixed single-quoted string "_'class'" (or more readaly, the deprecated underscore prefixed "_class"). The problems with reserved words infect the EMF implementation where the de-conflicted operation is "getClass_()".

Regards

Ed Willink
Previous Topic:Acceleo Code Generation?
Next Topic:Access to Esuper classes of an Eclass in Acceleo
Goto Forum:
  


Current Time: Sat Apr 27 00:51:20 GMT 2024

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

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

Back to the top