Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] Generate Declarations(Tweak and change to Code)
icon7.gif  [ACCELEO] Generate Declarations [message #1681833] Tue, 17 March 2015 13:34 Go to next message
Frank W. is currently offline Frank W.Friend
Messages: 10
Registered: March 2015
Junior Member
Hi,

I want to generate simple declarations with Acceleo in one of these two ways:

1.
[for (property :Property | c.eContents(Property))]
[PropertyDeclarations(property)/]
[/for]

[template public PropertyDeclarations(property:Property)]
[property.type.getStereotypeValue('Ecore::EDataType', 'instanceClassName')/] [property.name/] = [property.defaultValue/];
[/template]

2.
[c.attribute.type.getStereotypeValue('Ecore::EDataType', 'instanceClassName')/][c.attribute.name/];

Output
1. Yields this as the output
double in = ;
double out = ;
double v0_ = org.eclipse.uml2.uml.internal.impl.LiteralRealImpl@7b87d668 (name: <unset>, visibility: <unset>) (value: 0.0);
double v1_ = org.eclipse.uml2.uml.internal.impl.LiteralRealImpl@d18c0be (name: <unset>, visibility: <unset>) (value: 1.0);

So here I only want to consider the properties which are not ports: meaning 'in' and 'out'
And I want to access the values 0.0 and 1.0 respectively, but it does not work with [property.defaultValue.value/].....

2. If I try it another way with the code in 2. I get the following:
doubledoubledoubledouble inoutv0_v1_;

So basically I am wanting to know how I can change the code to get just the Parameters without the ports (I used the Parameter Property under Contraints and Comments) and in the right order, like this:

double v0_;
double v1_;

Thank you,
Frank
Re: [ACCELEO] Generate Declarations [message #1684181 is a reply to message #1681833] Wed, 18 March 2015 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Dear Frank,
If you want to filter those who are not ports usually in the "for"
clause you should use some OCL. Something like:

[for (property :Property | c.ownedElement->select(p |
p.oclIsKindOf(Property) and not p.oclIsKindOf(Port)))]
[PropertyDeclarations(property)/]
[/for]

For the Real literal to be shown, please, try using explicitly
".toString()" for defaultValue.

Best,

Víctor

El 17/03/2015 a las 15:31, Frank W. escribió:
> Hi,
>
> I want to generate simple declarations with Acceleo in one of these two
> ways:
>
> 1.
> [for (property :Property | c.eContents(Property))]
> [PropertyDeclarations(property)/]
> [/for]
>
> [template public PropertyDeclarations(property:Property)]
> [property.type.getStereotypeValue('Ecore::EDataType',
> 'instanceClassName')/] [property.name/] = [property.defaultValue/];
> [/template]
>
> 2.
> [c.attribute.type.getStereotypeValue('Ecore::EDataType',
> 'instanceClassName')/][c.attribute.name/];
>
> Output
> 1. Yields this as the output
> double in = ;
> double out = ;
> double v0_ =
> mailto:org.eclipse.uml2.uml.internal.impl.LiteralRealImpl@7b87d668
> (name: <unset>, visibility: <unset>) (value: 0.0);
> double v1_ =
> mailto:org.eclipse.uml2.uml.internal.impl.LiteralRealImpl@d18c0be (name:
> <unset>, visibility: <unset>) (value: 1.0);
>
> So here I only want to consider the properties which are not ports:
> meaning 'in' and 'out'
> And I want to access the values 0.0 and 1.0 respectively, but it does
> not work with [property.defaultValue.value/].....
>
> 2. If I try it another way with the code in 2. I get the following:
> doubledoubledoubledouble inoutv0_v1_;
>
> So basically I am wanting to know how I can change the code to get just
> the Parameters without the ports (I used the Parameter Property under
> Contraints and Comments) and in the right order, like this:
>
> double v0_;
> double v1_;
>
> Thank you,
> Frank
>
Re: [ACCELEO] Generate Declarations [message #1687362 is a reply to message #1684181] Thu, 19 March 2015 16:16 Go to previous message
Frank W. is currently offline Frank W.Friend
Messages: 10
Registered: March 2015
Junior Member
Thanks Viktor,

the loop works perfectly fine.
It just gives the warning 'Possible incompatible type between 'Property' and 'Set(Element)''
I don't know why this is so.

If I use
[property.defaultValue.toString()/] it bring the same output:
org.eclipse.uml2.uml.internal.impl.LiteralRealImpl@d18c0be (name:
> <unset>, visibility: <unset>) (value: 1.0);


However I can not access it via
[property.defaultValue.value.toString()/]

The other
[property.defaultValue.name.toString()/] works but result is always null (When I change the name, instead of the value, the name does not get saved in papyrus)
Previous Topic:Acceleo Debugger doesn't work
Next Topic:[Acceleo] Netlist Generation (nested loops+ variables?)
Goto Forum:
  


Current Time: Thu Apr 25 17:13:29 GMT 2024

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

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

Back to the top