InstantiationException while assigning vaiables [message #559332] |
Thu, 16 September 2010 08:09  |
Eclipse User |
|
|
|
Hello,
I am working with Xtext and want to do a M2T transformation. Before I do the transformation I want to evaluate my model and maybe add different features to some model elements. So I want to do a M2M transformation using Xtend. For adding the new feature I need to create a new instance of a model element. In the Xtend Reference I found that it is possible to use something like:
let var = new ModelElement....
But when I do so I get an java.lang.InstantiationException in the line where I use the new operator. I set up a small project and tried different things but nothing worked.
My Xtext defintion looks like:
...
State hidden (WS, SL_COMMENT):
'state' name = ID
'type' types += Type
('actions' '{' (actions+=[Command])+ '}')?
(transitions+=Transition)*
'end';
Type:
StateTypeList | StateTypeListMand;
StateTypeList:
name = StateType;
StateTypeListMand:
name = StateType man ?= "!";
enum StateType:
S1 = 'one' |
S2 = "two" |
S3 = "three" ;
With the Xtend I want to manipulate the feature TYPES of the STATE rule. So I wrote this Xtend snippet that is called from an Xpand template:
State change(State st) :
let stype = new StateTypeList:
stype.setName( ((StateType)StateType.getStaticProperty("S2").get()) ) ->
st.types.add(stype) ->
st;
Is it possible what I try to do or can I just don't do it? Do I have to use other model elements?
I am very thankful for any suggestions.
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04513 seconds