Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with association between XExpression and logical container
Problem with association between XExpression and logical container [message #919323] Fri, 21 September 2012 22:40 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
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 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
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
Previous Topic:Odd error using IJvmTypeProvider
Next Topic:Using multiple providers
Goto Forum:
  


Current Time: Fri Apr 19 23:39:44 GMT 2024

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

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

Back to the top