Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Advices not applied
[Xpand] Advices not applied [message #511369] Mon, 01 February 2010 13:08 Go to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi,

I call a Xpand generation from Java (without MWE), and I want to apply
an aspect (advice) to this generation, but it doesn't works.
I specify my advice template with Generator.setAdvice() with a string
like that
" fr::inria::adam::calico::models::generation::xpand::fractalT emplate::JavaGeneration "

When I debug the template invocation, my advices are registred in
XpandExecutionContextImpl.registerAdvices() but the problem seem to come
from the findDefinition() method of the same class which test if
corresponding DEFINE template match a AROUND advice. Indeed it compares
the simple name of the AROUND advice with the qualified name of the
DEFINE template which apparently don't matches.

I have already use Xpand aspect "weaving" with GMF Xpand where we must
put advice in a template file with the same path and file name that the
template to "weave", but I can't do that with Xpand because I can't find
the right advices and register them.

What is my mistake(s)?

Thanks.

I use Helios M4,
my main template is this plug-in project :
http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/v1/p lugins/fr.inria.adam.calico.models.generation.xpand.common.J avaTemplate/models/fr/inria/adam/calico/models/generation/xp and/common/JavaTemplate/?root=calico

and the advice and the generation invocation is in this plug-in project :
http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/v1/p lugins/fr.inria.adam.calico.models.generation.xpand.fractalT emplate/src/fr/inria/adam/calico/models/generation/xpand/fra ctalTemplate/XpandFractalTemplate.java?rev=490&root=cali co&view=markup

If it can help.

Best Regards.
Re: [Xpand] Advices not applied [message #511891 is a reply to message #511369] Wed, 03 February 2010 10:36 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
The M2T Xpand advices work differently than the one from the GFM derivate.

the simple name of an advice is meant to be a pointcut, so you could use
wildcards in order to match any number of definitions.
in your case something like fractalTemplate*JavaGeneration should do it.

Sven



Esteban DUGUEPEROUX schrieb:
> Hi,
>
> I call a Xpand generation from Java (without MWE), and I want to apply
> an aspect (advice) to this generation, but it doesn't works.
> I specify my advice template with Generator.setAdvice() with a string
> like that
> " fr::inria::adam::calico::models::generation::xpand::fractalT emplate::JavaGeneration "
>
>
> When I debug the template invocation, my advices are registred in
> XpandExecutionContextImpl.registerAdvices() but the problem seem to come
> from the findDefinition() method of the same class which test if
> corresponding DEFINE template match a AROUND advice. Indeed it compares
> the simple name of the AROUND advice with the qualified name of the
> DEFINE template which apparently don't matches.
>
> I have already use Xpand aspect "weaving" with GMF Xpand where we must
> put advice in a template file with the same path and file name that the
> template to "weave", but I can't do that with Xpand because I can't find
> the right advices and register them.
>
> What is my mistake(s)?
>
> Thanks.
>
> I use Helios M4,
> my main template is this plug-in project :
> http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/v1/p lugins/fr.inria.adam.calico.models.generation.xpand.common.J avaTemplate/models/fr/inria/adam/calico/models/generation/xp and/common/JavaTemplate/?root=calico
>
>
> and the advice and the generation invocation is in this plug-in project :
> http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/v1/p lugins/fr.inria.adam.calico.models.generation.xpand.fractalT emplate/src/fr/inria/adam/calico/models/generation/xpand/fra ctalTemplate/XpandFractalTemplate.java?rev=490&root=cali co&view=markup
>
>
> If it can help.
>
> Best Regards.


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xpand] Advices not applied [message #511989 is a reply to message #511891] Wed, 03 February 2010 15:25 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Sven,

Thanks it works fine now.

But in one of my AROUND statement a call to a local DEFINE statement
which call a DEFINE statement in the main template doesn't works.
I must copy DEFINE statements that I would like to use in my second
template (where AROUND statements are defined) from the main template to
my second template.

Is it clear?

There is a mean to reuse DEFINE statements from the main template in my
second template?

Regards.

Sven Efftinge wrote:
> The M2T Xpand advices work differently than the one from the GFM derivate.
>
> the simple name of an advice is meant to be a pointcut, so you could use
> wildcards in order to match any number of definitions.
> in your case something like fractalTemplate*JavaGeneration should do it.
>
> Sven
>
>
>
> Esteban DUGUEPEROUX schrieb:
>> Hi,
>>
>> I call a Xpand generation from Java (without MWE), and I want to apply
>> an aspect (advice) to this generation, but it doesn't works.
>> I specify my advice template with Generator.setAdvice() with a string
>> like that
>> " fr::inria::adam::calico::models::generation::xpand::fractalT emplate::JavaGeneration "
>>
>>
>> When I debug the template invocation, my advices are registred in
>> XpandExecutionContextImpl.registerAdvices() but the problem seem to
>> come from the findDefinition() method of the same class which test if
>> corresponding DEFINE template match a AROUND advice. Indeed it
>> compares the simple name of the AROUND advice with the qualified name
>> of the DEFINE template which apparently don't matches.
>>
>> I have already use Xpand aspect "weaving" with GMF Xpand where we must
>> put advice in a template file with the same path and file name that
>> the template to "weave", but I can't do that with Xpand because I
>> can't find the right advices and register them.
>>
>> What is my mistake(s)?
>>
>> Thanks.
>>
>> I use Helios M4,
>> my main template is this plug-in project :
>> http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/v1/p lugins/fr.inria.adam.calico.models.generation.xpand.common.J avaTemplate/models/fr/inria/adam/calico/models/generation/xp and/common/JavaTemplate/?root=calico
>>
>>
>> and the advice and the generation invocation is in this plug-in project :
>> http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/trunk/v1/p lugins/fr.inria.adam.calico.models.generation.xpand.fractalT emplate/src/fr/inria/adam/calico/models/generation/xpand/fra ctalTemplate/XpandFractalTemplate.java?rev=490&root=cali co&view=markup
>>
>>
>> If it can help.
>>
>> Best Regards.
>
>
Re: [Xpand] Advices not applied [message #512216 is a reply to message #511989] Thu, 04 February 2010 12:38 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Esteban DUGUEPEROUX schrieb:
> Hi Sven,
>
> Thanks it works fine now.
>
> But in one of my AROUND statement a call to a local DEFINE statement
> which call a DEFINE statement in the main template doesn't works.
> I must copy DEFINE statements that I would like to use in my second
> template (where AROUND statements are defined) from the main template to
> my second template.
>
> Is it clear?

Not yet, sorry.

Are you saying that your not able to call DEFINEs from within an AROUND?

Sven


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xpand] Advices not applied [message #512236 is a reply to message #512216] Thu, 04 February 2010 13:27 Go to previous message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Sven Efftinge wrote:
> Esteban DUGUEPEROUX schrieb:
>> Hi Sven,
>>
>> Thanks it works fine now.
>>
>> But in one of my AROUND statement a call to a local DEFINE statement
>> which call a DEFINE statement in the main template doesn't works.
>> I must copy DEFINE statements that I would like to use in my second
>> template (where AROUND statements are defined) from the main template
>> to my second template.
>>
>> Is it clear?
>
> Not yet, sorry.
>
> Are you saying that your not able to call DEFINEs from within an AROUND?
>
> Sven
>
>
I can call local DEFINE statements to my template where I have defined
my AROUND statements but not the DEFINE statements from the main
template which is called for my code generation.

Code example :

Java code which launch my code generation :

Generator generator = new Generator( );
....

String aspectTemplate = "fr::inria::adam::calico::AspectTemplate";
generator.addAdvice(aspectTemplate);
....
generator.setExpand("fr::inria::adam::calico::common::JavaGeneration::main
FOR GenerationDefinition");
....
generator.invoke(ctx, monitor, issues);



my main template :

«DEFINE main FOR generation::GenerationDefinition»
«EXPAND componentImplementation FOR this»
«ENDDEFINE»
....
«DEFINE plop FOR generation::Plop»
....
«ENDDEFINE»

my aspect template :

«AROUND *componentImplementation FOR generation::GenerationDefinition»
«EXPAND plop FOR this.onePlop»
«ENDAROUND»


this doesn't works because I can't call "plop" DEFINE statement defined
in the main template and consequently I must recopy the "plop" DEFINE
statement in my aspect template.

Hum nothing better than an example.
Re: [Xpand] Advices not applied [message #512261 is a reply to message #512236] Thu, 04 February 2010 09:26 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You'll have to call it by its qualified name.
<<EXPAND my::path::TemplateFile::plop FOR this.onePlop>>

Sven

Esteban DUGUEPEROUX schrieb:
> Sven Efftinge wrote:
>> Esteban DUGUEPEROUX schrieb:
>>> Hi Sven,
>>>
>>> Thanks it works fine now.
>>>
>>> But in one of my AROUND statement a call to a local DEFINE statement
>>> which call a DEFINE statement in the main template doesn't works.
>>> I must copy DEFINE statements that I would like to use in my second
>>> template (where AROUND statements are defined) from the main template
>>> to my second template.
>>>
>>> Is it clear?
>>
>> Not yet, sorry.
>>
>> Are you saying that your not able to call DEFINEs from within an AROUND?
>>
>> Sven
>>
>>
> I can call local DEFINE statements to my template where I have defined
> my AROUND statements but not the DEFINE statements from the main
> template which is called for my code generation.
>
> Code example :
>
> Java code which launch my code generation :
>
> Generator generator = new Generator( );
> ....
>
> String aspectTemplate = "fr::inria::adam::calico::AspectTemplate";
> generator.addAdvice(aspectTemplate);
> ....
> generator.setExpand("fr::inria::adam::calico::common::JavaGeneration::main
> FOR GenerationDefinition");
> ....
> generator.invoke(ctx, monitor, issues);
>
>
>
> my main template :
>
> «DEFINE main FOR generation::GenerationDefinition»
> «EXPAND componentImplementation FOR this»
> «ENDDEFINE»
> ....
> «DEFINE plop FOR generation::Plop»
> ....
> «ENDDEFINE»
>
> my aspect template :
>
> «AROUND *componentImplementation FOR generation::GenerationDefinition»
> «EXPAND plop FOR this.onePlop»
> «ENDAROUND»
>
>
> this doesn't works because I can't call "plop" DEFINE statement defined
> in the main template and consequently I must recopy the "plop" DEFINE
> statement in my aspect template.
>
> Hum nothing better than an example.
>
>
>


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xpand] Advices not applied [message #512263 is a reply to message #512261] Thu, 04 February 2010 09:26 Go to previous message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Thanks it works and sorry for the stupid question because it was obvious
answer.

Best Regards.

Sven Efftinge wrote:
> You'll have to call it by its qualified name.
> <<EXPAND my::path::TemplateFile::plop FOR this.onePlop>>
>
> Sven
>
> Esteban DUGUEPEROUX schrieb:
>> Sven Efftinge wrote:
>>> Esteban DUGUEPEROUX schrieb:
>>>> Hi Sven,
>>>>
>>>> Thanks it works fine now.
>>>>
>>>> But in one of my AROUND statement a call to a local DEFINE statement
>>>> which call a DEFINE statement in the main template doesn't works.
>>>> I must copy DEFINE statements that I would like to use in my second
>>>> template (where AROUND statements are defined) from the main
>>>> template to my second template.
>>>>
>>>> Is it clear?
>>>
>>> Not yet, sorry.
>>>
>>> Are you saying that your not able to call DEFINEs from within an AROUND?
>>>
>>> Sven
>>>
>>>
>> I can call local DEFINE statements to my template where I have defined
>> my AROUND statements but not the DEFINE statements from the main
>> template which is called for my code generation.
>>
>> Code example :
>>
>> Java code which launch my code generation :
>>
>> Generator generator = new Generator( );
>> ....
>>
>> String aspectTemplate = "fr::inria::adam::calico::AspectTemplate";
>> generator.addAdvice(aspectTemplate);
>> ....
>> generator.setExpand("fr::inria::adam::calico::common::JavaGeneration::main
>> FOR GenerationDefinition");
>> ....
>> generator.invoke(ctx, monitor, issues);
>>
>>
>>
>> my main template :
>>
>> «DEFINE main FOR generation::GenerationDefinition»
>> «EXPAND componentImplementation FOR this»
>> «ENDDEFINE»
>> ....
>> «DEFINE plop FOR generation::Plop»
>> ....
>> «ENDDEFINE»
>>
>> my aspect template :
>>
>> «AROUND *componentImplementation FOR generation::GenerationDefinition»
>> «EXPAND plop FOR this.onePlop»
>> «ENDAROUND»
>>
>>
>> this doesn't works because I can't call "plop" DEFINE statement
>> defined in the main template and consequently I must recopy the "plop"
>> DEFINE statement in my aspect template.
>>
>> Hum nothing better than an example.
>>
>>
>>
>
>
Previous Topic:How to debug java extensions?
Next Topic:[Acceleo]How to protect user code by signature changes
Goto Forum:
  


Current Time: Fri Apr 19 15:17:31 GMT 2024

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

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

Back to the top