[xpand] dynamic expansion of template [message #508215] |
Sun, 17 January 2010 07:58  |
Eclipse User |
|
|
|
Hello,
I just noticed that bug 161915 was closed due to some move operations, but it
doesn't look like the issue has been resolved... This is about determining the
name of the template to expand dynamically at runtime. I could really use this
feature because I do a lot of M2MT before the actual code generation and the
class and method names all come from the transformed model. Without the
dynamic expansion, I have to use a rather unpleasant IF - ELSEIF
sequence. Perhaps this bug should be re-opened?
Thanks
Volker
--
* Volker Wegert * http://www.volker-wegert.de/contact *
"With sufficient thrust, pigs fly just fine. However, this is not necessarily
a good idea. It is hard to be sure where they are going to land, and it could
be dangerous sitting under them as they fly overhead." (RFC 1925)
|
|
|
|
|
|
|
|
|
|
Re: [xpand] dynamic expansion of template [message #510034 is a reply to message #509670] |
Tue, 26 January 2010 04:55  |
Eclipse User |
|
|
|
The injected ExecutionContext actually is an XpandExecutionContext, if
the extension was invoked from an Xpand context (i.e. an Xpand generator
component).
The following code does the trick:
private ExecutionContext ctx;
public void setExecutionContext(ExecutionContext ctx) {
this.ctx = ctx;
}
public void invokeXpand(Object target, String definition) {
if (ctx instanceof XpandExecutionContext) {
XpandExecutionContext ctx2 = (XpandExecutionContext) ctx;
XpandFacade.create(ctx2).evaluate(definition, target);
}
}
Note, that the definition has to be qualified.
Cheers,
Sven
Joerg Reichert schrieb:
> Hi Volker,
>
> no you didn't. Without having tested it before I had assumed that the
> solution for Xtend would be adaptable for Xpand, too. But it isn't as I
> pointed out in my previous post.
>
> Joerg
--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
|
|
|
Powered by
FUDForum. Page generated in 0.04676 seconds