Issue with inferred model and variable usage [message #959558] |
Fri, 26 October 2012 16:25  |
Eclipse User |
|
|
|
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 10:49  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03643 seconds