Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Dynamically call another xtend method from current xtend method
Dynamically call another xtend method from current xtend method [message #483642] Wed, 02 September 2009 12:46 Go to next message
Joerg Reichert is currently offline Joerg ReichertFriend
Messages: 80
Registered: July 2009
Location: Leipzig
Member
Is it possible to dynamically call a Xtend method in another file from the current Xtend file? The path of the method to call is dynamically calculated at runtime in the first extension file. It's like a need for reflection for Xtend.

Use Case:

provided
- source model
- transformation description model containing the paths to the extension files
- target model
- a list of extension files having the same name and the same named methods just differ in the directory location (so the solution to import all possible to use extensions won't work)

runtime
At runtime it is determined on basis of the source model which paths are read out from the transformation model, defining the xtend file and the method to call. The context of the current xtend method should be also available for the called extension.


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Re: Dynamically call another xtend method from current xtend method [message #483860 is a reply to message #483642] Thu, 03 September 2009 12:00 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Joerg,

sorry for the late response. It is actualle not possible to dynamically
invoke extensions. Neither the name of an extension may be an expression
nor the refered extension file may be calculated at runtime. As far as I
know, there is no workaround.

Please feel free to file a bugzilla.

Maybe there is one rather tricky way to do what you want.
The ResourceLoader is the class, that should resolve a given path to an
input stream. Maybe you can use an own implementation and register it at
the ResourceLoaderFactory. Your ResourceLoader could be configured based
on your source model _before_ you invoke the transformation. I'm not
that sure about it but this may work.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Joerg Reichert schrieb:
> Is it possible to dynamically call a Xtend method in another file from
> the current Xtend file? The path of the method to call is dynamically
> calculated at runtime in the first extension file. It's like a need for
> reflection for Xtend.
>
> Use Case:
>
> provided
> - source model
> - transformation description model containing the paths to the extension
> files
> - target model - a list of extension files having the same name and the
> same named methods just differ in the directory location (so the
> solution to import all possible to use extensions won't work)
>
> runtime
> At runtime it is determined on basis of the source model which paths are
> read out from the transformation model, defining the xtend file and the
> method to call. The context of the current xtend method should be also
> available for the called extension.
Re: Dynamically call another xtend method from current xtend method [message #483962 is a reply to message #483860] Thu, 03 September 2009 18:45 Go to previous message
Joerg Reichert is currently offline Joerg ReichertFriend
Messages: 80
Registered: July 2009
Location: Leipzig
Member
Hi Sebastian,

thanks for your clarification and suggestion. I filled in the Feature request. With the resource loader workaround it should be at least feasable to register all possible Xtend calls by the transformation model location and use dummy import statements enumerating the locations. The imports then get resolved against the model locations that are identified at runtime to use. I will give it a try.

Cheers
Joerg


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Previous Topic:[Xpand] Calling Java from Xpand
Next Topic:xtext for metamodeling
Goto Forum:
  


Current Time: Thu Apr 25 10:15:45 GMT 2024

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

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

Back to the top