|
| Re: How can I use ATL to modify a java model based on a third party lib [message #789933 is a reply to message #789907] |
Fri, 03 February 2012 10:41   |
Hugo Bruneliere Messages: 467 Registered: July 2009 |
Senior Member |
|
|
Hello Jing,
As you mentioned it, the provided demo shows a transformation creating new getter methods in a Java model.
What you want to do here is following exactly the same principle: creating new annotations (and corresponding type import) in a Java model.
It means that your transformation is going to be of the same kind, but of course the concerned model elements will be different.
To help a bit more, you can also find from https://bugs.eclipse.org/bugs/show_bug.cgi?id=369827 a contribution (to be committed soon) including a transformation similarly adding new annotations...
Best regards,
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
| Re: How can I use ATL to modify a java model based on a third party lib [message #791784 is a reply to message #789933] |
Mon, 06 February 2012 04:00   |
Jing Ge Messages: 12 Registered: January 2012 |
Junior Member |
|
|
Hello Hugo,
thanks for your help and kindly reply .
As I said, I knew how to create new Annotations in a java model by using MoDisco API. I want to know if it is also possible to do it ONLY using ATL. Your example of creating missing getter method shows us that we can, for example,
create method declaration based on the given source java model:
omd : Java!MethodDeclaration (
abstractTypeDeclaration <- ifd.abstractTypeDeclaration,
originalCompilationUnit <- ifd.originalCompilationUnit,
name <- let fieldName : String = ifd.fragments->first().name
in
'get' + fieldName.substring(1,1).toUpper() + fieldName.substring(2,fieldName.size()),
modifier <- om,
body <- ob,
returnType <- ota
)
create a modifier:
om : Java!Modifier (
visibility <- #public
),
Do you mean that we can create any model element like declarations/annotations/imports(even if they are unknown for the source java model) in the target java model ONLY using ATL?
best regards
Jing
[Updated on: Mon, 06 February 2012 05:01] Report message to a moderator
|
|
|
| Re: How can I use ATL to modify a java model based on a third party lib [message #791854 is a reply to message #791784] |
Mon, 06 February 2012 05:34   |
Hugo Bruneliere Messages: 467 Registered: July 2009 |
Senior Member |
|
|
Hi Jing,
Yes you can create any kind of model element in the target model, as long as the corresponding model element type is declared in the target metamodel of course.
Thus, you can create annotations using the same principle as for all types of elements in the Java metamodel.
This is how model-to-model transformation works. I encourage you to take a look to the ATL Documentation (and to the "Concepts" page) to have a clearer understanding of this.
Actually, the contribution bug I indicated in my previous message already shows how to create new elements in a Java model ONLY using ATL (there is no reference to or direct use of a specific MoDisco API there).
Best regards,
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
|
| Re: How can I use ATL to modify a java model based on a third party lib [message #792109 is a reply to message #791990] |
Mon, 06 February 2012 11:22   |
Hugo Bruneliere Messages: 467 Registered: July 2009 |
Senior Member |
|
|
Jing,
When you write this part of the rule
ofd : Java!ClassDeclaration (
annotations <- Sequence{ano}
),
you don't indicate that the already existing annotations for this class declaration still have to be considered... so the corresponding "Annotation" model elements remain in the target model (as you are in a "refinement" transformation) but are not attached anymore to any class declaration.
You could rather do something like
ofd : Java!ClassDeclaration (
annotations <- ifd.annotations.append(ano)
),
Best regards,
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
|
Powered by
FUDForum. Page generated in 0.01616 seconds