Problem with association between XExpression and logical container [message #919323] |
Fri, 21 September 2012 22:40 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Hi,
I am using jvm model inference as part of code generation, and I'm
struggling with associating XExpressions with the correct method container.
I have a model element M from which I infer two Java methods m1() and
m2(). Part of the content of m1() and m2() will be code generated from
two XExpressions X1 and X2, contained by M. Hence, to help Xtext I
associate these expressions with m1() and m2(), respectively. However,
the editor seems to associate X2 with m1(), because it complains that
X2's type doesn't match m1()'s return type. From looking at the code I
get the impression that Xtext looks at the XExpression's container for
the association, M in my case, and uses the first associated element,
i.e. m1(), instead of using the XExpression's explicit associations.
How can I tell Xtext to assume that X1 will be inside m1() and X2 will
be inside m2()?
Hallvard
|
|
|
Re: Problem with association between XExpression and logical container [message #919349 is a reply to message #919323] |
Fri, 21 September 2012 23:13 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Of course I found the solution just after posting. I can explicitly set
the logical constainer of an expression (or any model object) with
IJvmAssociator's associateLogicalContainer method.
Hallvard
On 21.09.12 15.40, Hallvard Trætteberg wrote:
> Hi,
>
> I am using jvm model inference as part of code generation, and I'm
> struggling with associating XExpressions with the correct method container.
>
> I have a model element M from which I infer two Java methods m1() and
> m2(). Part of the content of m1() and m2() will be code generated from
> two XExpressions X1 and X2, contained by M. Hence, to help Xtext I
> associate these expressions with m1() and m2(), respectively. However,
> the editor seems to associate X2 with m1(), because it complains that
> X2's type doesn't match m1()'s return type. From looking at the code I
> get the impression that Xtext looks at the XExpression's container for
> the association, M in my case, and uses the first associated element,
> i.e. m1(), instead of using the XExpression's explicit associations.
>
> How can I tell Xtext to assume that X1 will be inside m1() and X2 will
> be inside m2()?
>
> Hallvard
|
|
|
Powered by
FUDForum. Page generated in 0.03825 seconds