Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » obtain class from operation
obtain class from operation [message #1787105] Fri, 18 May 2018 15:42 Go to next message
Eclipse UserFriend
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 01:23 Go to previous message
Eclipse UserFriend
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: Fri Jun 20 13:43:36 EDT 2025

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

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

Back to the top