Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Issue with inferred model and variable usage
Issue with inferred model and variable usage [message #959558] Fri, 26 October 2012 20:25 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 672
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I have a model object containing two XExpressions that are used as
bodies of two inferred methods. The declarations in the first
XExpression (if it is an XBlockExpression) are used to infer the
JvmFormalParameter of the second method and a call to that method is
injected by my code generator as the last statement in the block. E.g.
suppose the expressions are as follows

XExpression 1: { val int value = 0 }
XEpression 2: System.out.println(value + 1)

Then the following methods will be generated:

void method1() {
int value = 0;
method2(value);
}

void method2(int value) {
System.out.println(value + 1);
}

This works fine, but there is one problem: I get a yellow warning saying
the the local variable value (in the first XExpression) isn't used.
However, I can navigate with F3 from the value symbol in the second
XExpression to the first one, since it is correctly associated as the
source element of the value JvmFormalParameter of the second method. I
guess only the first XExpression is analyzed for usages, and not the
assocations that make it accessible to other XExpressions, where is IS used.

Is this something that should be fixed?
How can I avoid the warning in this particular case.

Hallvard
Re: Issue with inferred model and variable usage [message #960506 is a reply to message #959558] Sat, 27 October 2012 14:49 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hallvard,

if you change the generated code / logical container for an
expression-block, you'll have to adapt the validator, too.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 26.10.12 22:26, schrieb Hallvard Trætteberg:
> Hi,
>
> I have a model object containing two XExpressions that are used as
> bodies of two inferred methods. The declarations in the first
> XExpression (if it is an XBlockExpression) are used to infer the
> JvmFormalParameter of the second method and a call to that method is
> injected by my code generator as the last statement in the block. E.g.
> suppose the expressions are as follows
>
> XExpression 1: { val int value = 0 }
> XEpression 2: System.out.println(value + 1)
>
> Then the following methods will be generated:
>
> void method1() {
> int value = 0;
> method2(value);
> }
>
> void method2(int value) {
> System.out.println(value + 1);
> }
>
> This works fine, but there is one problem: I get a yellow warning saying
> the the local variable value (in the first XExpression) isn't used.
> However, I can navigate with F3 from the value symbol in the second
> XExpression to the first one, since it is correctly associated as the
> source element of the value JvmFormalParameter of the second method. I
> guess only the first XExpression is analyzed for usages, and not the
> assocations that make it accessible to other XExpressions, where is IS
> used.
>
> Is this something that should be fixed?
> How can I avoid the warning in this particular case.
>
> Hallvard
Previous Topic:Unhide tokens
Next Topic:first and last character truncated in STRING terminals
Goto Forum:
  


Current Time: Sat Sep 26 22:51:00 GMT 2020

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

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

Back to the top