Home » Modeling » M2T (model-to-text transformation) » [Xpand] setting the value of a global variable from xtend?
|
Re: [Xpand] setting the value of a global variable from xtend? [message #646709 is a reply to message #646706] |
Thu, 30 December 2010 10:19 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
On 12/30/2010 10:54 AM, Lorenzo Bettini wrote:
> Hi
>
> in my Xpand template I'd like to set the value of a variable to be
> available during the generation of a model element, and I don't want to
> pass that value to all the definitions...
>
> I saw that Xpand provides GLOBALVAR
>
> I'd like to set that var when I start to generate a model element, but I
> can't see how to do that...
>
> any help please?
> thanks in advance
> Lorenzo
>
> P.S. sorry, I'v just started using Xpand...
>
OK, I think I found the solution by googling much more, and I try to
answer myself :)
extension org::eclipse::xtend::util::stdlib::globalvar;
String getCurrentModelPackage() :
let currentModelPackage = (String) getGlobalVar("currentModelPackage") :
if(currentModelPackage == null) then (
storeGlobalVar("currentModelPackage", "")
) -> currentModelPackage
;
String setCurrentModelPackage(String s) :
storeGlobalVar("currentModelPackage", s)
;
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Goto Forum:
Current Time: Sun Sep 01 04:44:39 GMT 2024
Powered by FUDForum. Page generated in 0.03290 seconds
|