Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] variables
[Acceleo] variables [message #525828] Wed, 07 April 2010 21:45 Go to next message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi everyone,

im using the "Let" block to declare variables in my transformation. Looks like this:

[let providingComponent : Component = attachment.component]
	[if (providingComponent.name = 'Start')]
	        [providingComponent.interface.portName.toUpperFirst()/];
        [/if]
[/let]


But the generated text shows this:

[The interface port name]


Yes, with square brackets.

How remove the square brackets or how to use another method to declare variables?

Sorry for my english.
Hugo Melo
Re: [Acceleo] variables [message #525900 is a reply to message #525828] Thu, 08 April 2010 08:33 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020500070304040004090400
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Hugo,

Brackets that are part of the Acceleo syntax will never be printed out
in the generated file. Furthermore, Acceleo should never print out the
brackets resulting from a call to the "toString" method of a Collection
(so that Sequence{1, 2, 3}->toString() generates "123" and not "[1, 2, 3]").

The template part you provided here as an example is correct, and I
can't understand how you'd end up with brackets if "interface.portName"
doesn't return them itself. Are you sure that this is the actual part of
your template that generates these extra brackets (for example if you
put static text in your "if" is it generated instead of the bracketed
port name)? And if yes, are you positive that "portName" doesn't return
a bracketed name when called (ie
providingComponent.interface.portName.contains('[') returns false)?

Laurent Goubet
Obeo

Hugo Melo wrote:
> Hi everyone,
>
> im using the "Let" block to declare variables in my transformation.
> Looks like this:
>
>
> [let providingComponent : Component = attachment.component]
> [if (providingComponent.name = 'Start')]
> [providingComponent.interface.portName.toUpperFirst()/];
> [/if]
> [/let]
>
>
> But the generated text shows this:
>
>
> [The interface port name]
>
>
> Yes, with square brackets.
>
> How remove the square brackets or how to use another method to declare
> variables?
>
> Sorry for my english.
> Hugo Melo


--------------020500070304040004090400
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------020500070304040004090400--
Re: [Acceleo] variables [message #526085 is a reply to message #525900] Thu, 08 April 2010 16:08 Go to previous messageGo to next message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Laurent, thank you for the reply.

Actually my example was simplified. The real code is more similar to this:

[providingComponent.interface.portName.toUpperFirst()/].Boot;


Resulting in:

[Start].Boot


The static text is correct. And the "providingComponent.interface.portName.contains('[')" returns false. I noticed that only the variables created on the Let block presented this behaviour. Another variables from For blocks had an correctly output.

Hugo Melo
Re: [Acceleo] variables [message #526228 is a reply to message #526085] Fri, 09 April 2010 09:48 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050807010807090807020909
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hugo,

I've never observed this behavior ... Be it with single value variables
or Collection variables, defined with a let or not. I know we did print
out the brackets resulting from the toString of a Collection at a time,
but I don't really know if that's what you have here. Are you using the
M6 build of Acceleo?

Laurent Goubet
Obeo

Hugo Melo wrote:
> Hi Laurent, thank you for the reply.
>
> Actually my example was simplified. The real code is more similar to this:
>
>
> [providingComponent.interface.portName.toUpperFirst()/].Boot ;
>
>
> Resulting in:
>
>
> [Start].Boot
>
>
> The static text is correct. And the
> "providingComponent.interface.portName.contains('[')" returns false. I
> noticed that only the variables created on the Let block presented this
> behaviour. Another variables from For blocks had an correctly output.
>
> Hugo Melo


--------------050807010807090807020909
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------050807010807090807020909--
Re: [Acceleo] variables [message #526331 is a reply to message #526228] Fri, 09 April 2010 16:56 Go to previous messageGo to next message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Laurent,

I installed the M6 build succesfully (i was using the M2), but now my metamodel couldn't be resolved. This metamodel is a third part product and works fine on previously version of Acceleo. I tried import the metamodel plugin explicity, but its already on eclipse/plugin folder. How this version of Acceleo does the "import" of metamodels?

Hugo Melo
Re: [Acceleo] variables [message #526358 is a reply to message #526331] Fri, 09 April 2010 19:43 Go to previous messageGo to next message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Laurent,

I tried to declare the metamodel by his relative path, just like described on this topic:

http://www.eclipse.org/forums/index.php?t=msg&goto=51127 0&

This works fine. But why the metamodel couldn't be resolved? His definition is on eclipse/plugin folder.

Btw, thank you for help.

Hugo Melo
Re: [Acceleo] variables [message #526542 is a reply to message #526358] Mon, 12 April 2010 08:36 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010201020709070808000108
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hugo,

Appart from a plugin that is not properly installed, I wouldn't know why
it cannot be referenced by Acceleo.

Open a regular ecore file in your workspace (if you haven't got one, use
the file -> new -> other -> Eclipse Modeling Framework -> Ecore model
wizard) ; then right click anywhere and select the action "load
resource..." then click on the "Browse Registered Packages..." button.
Is your metamodel in the list of URIs that pops up?

If yes, your metamodel should be resolved properly by Acceleo. If not,
there is likely an issue with your metamodel. Take note that you need to
generate at least the model code for your metamodel to appear in this list.

Manually contributing to the extension point
"org.eclipse.emf.ecore.generated_package" may work, but I've never tried
it without generating the code for a given metamodel.

Your other option is to contribute to the extension point
"org.eclipse.emf.ecore.uri_mapping" with something like :

----------8<----------
<extension point="org.eclipse.emf.ecore.uri_mapping">
<mapping
source="myMetamodelURI"
target="platform:/plugin/myplugin/mymetamodel.ecore">
</mapping>
</extension>
---------->8----------

should also work for Acceleo to "see" your metamodel. Mind you, I've
never tried to write a generation module for a metamodel that hasn't
been generated yet which URI can be resolved through an URI mapping. If
you use this, please give us your feedback :).

Laurent Goubet
Obeo


Hugo Melo wrote:
> Hi Laurent,
>
> I tried to declare the metamodel by his relative path, just like
> described on this topic:
>
> http://www.eclipse.org/forums/index.php?t=msg&goto=51127 0&
> This works fine. But why the metamodel couldn't be resolved? His
> definition is on eclipse/plugin folder.
>
> Btw, thank you for help.
>
> Hugo Melo


--------------010201020709070808000108
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------010201020709070808000108--
Re: [Acceleo] variables [message #526701 is a reply to message #526542] Mon, 12 April 2010 16:14 Go to previous message
Hugo Melo is currently offline Hugo MeloFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Laurent,

i dont remember if i run the module with the metamodel declaration by URI. I remember that the module file show no errors. Actually, i reinstalled the eclipse and the two used metamodels. I dont know why, but the Acceleo installation corrupted the others plugins. After all, the motive was that the plugin was not properly installed.

Hugo Melo
Previous Topic:Defining package from workflow
Next Topic:[Xpand] from 2 models to text
Goto Forum:
  


Current Time: Thu Apr 25 23:39:16 GMT 2024

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

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

Back to the top