[ https://issues.apache.org/jira/browse/GROOVY-8002?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-8002: -------------------------------- Description: @CompileStatic is dropping source position for method calls in a couple cases. There are several circumstances where a MethodCallExpression is created using the 1st constructor of MCE, which creates a ConstantExpression for the method with no position. And later when org.codehaus.groovy.classgen.asm.sc.StaticPropertyAccessHelper.PoppingMethodCallExpression.transformExpression(ExpressionTransformer) is called, the transformed expression has lost position info. The latter is pretty easy. See the one line addition below: {code} public Expression transformExpression(final ExpressionTransformer transformer) { PoppingMethodCallExpression trn = new PoppingMethodCallExpression(receiver.transformExpression(transformer), setter, (TemporaryVariableExpression) tmp.transformExpression(transformer)); trn.copyNodeMetaData(this); // GRECLIPSE add trn.setSourcePosition(this); // GRECLIPSE end trn.setImplicitThis(isImplicitThis()); trn.setSafe(isSafe()); trn.setSpreadSafe(isSpreadSafe()); return trn; } {code} MethodCallExpression could use an override of setSourcePosition to try and propagate some info to method and arguments expressions. Here is what I came up with: {code} public void setSourcePosition(ASTNode node) { super.setSourcePosition(node); if (node instanceof MethodCall) { if (node instanceof MethodCallExpression) { method.setSourcePosition(((MethodCallExpression) node).getMethod()); } else { method.setSourcePosition(node); method.setEnd(method.getStart() + getMethodAsString().length()); } if (arguments != null) { arguments.setSourcePosition(((MethodCall) node).getArguments()); } } else if (node instanceof PropertyExpression) { method.setSourcePosition(((PropertyExpression) node).getProperty()); } } {code} was: @CompileStatic is dropping source position for method calls in a couple cases. There are several circumstances where a MethodCallExpression is created using the 1st constructor of MCE, which creates a ConstantExpression for the method with no position. And later when org.codehaus.groovy.classgen.asm.sc.StaticPropertyAccessHelper.PoppingMethodCallExpression.transformExpression(ExpressionTransformer) is called, the transformed expression has lost position info. The latter is pretty easy. See the one line addition below: {java} public Expression transformExpression(final ExpressionTransformer transformer) { PoppingMethodCallExpression trn = new PoppingMethodCallExpression(receiver.transformExpression(transformer), setter, (TemporaryVariableExpression) tmp.transformExpression(transformer)); trn.copyNodeMetaData(this); // GRECLIPSE add trn.setSourcePosition(this); // GRECLIPSE end trn.setImplicitThis(isImplicitThis()); trn.setSafe(isSafe()); trn.setSpreadSafe(isSpreadSafe()); return trn; } {/java} MethodCallExpression could use an override of setSourcePosition to try and propagate some info to method and arguments expressions. Here is what I came up with: {java} public void setSourcePosition(ASTNode node) { super.setSourcePosition(node); if (node instanceof MethodCall) { if (node instanceof MethodCallExpression) { method.setSourcePosition(((MethodCallExpression) node).getMethod()); } else { method.setSourcePosition(node); method.setEnd(method.getStart() + getMethodAsString().length()); } if (arguments != null) { arguments.setSourcePosition(((MethodCall) node).getArguments()); } } else if (node instanceof PropertyExpression) { method.setSourcePosition(((PropertyExpression) node).getProperty()); } } {/java} > Static compilation drops source position for method calls > --------------------------------------------------------- > > Key: GROOVY-8002 > URL: https://issues.apache.org/jira/browse/GROOVY-8002 > Project: Groovy > Issue Type: Bug > Reporter: Eric Milles > Priority: Minor > > @CompileStatic is dropping source position for method calls in a couple > cases. There are several circumstances where a MethodCallExpression is > created using the 1st constructor of MCE, which creates a ConstantExpression > for the method with no position. And later when > org.codehaus.groovy.classgen.asm.sc.StaticPropertyAccessHelper.PoppingMethodCallExpression.transformExpression(ExpressionTransformer) > is called, the transformed expression has lost position info. > The latter is pretty easy. See the one line addition below: > {code} > public Expression transformExpression(final ExpressionTransformer > transformer) { > PoppingMethodCallExpression trn = new > PoppingMethodCallExpression(receiver.transformExpression(transformer), > setter, (TemporaryVariableExpression) tmp.transformExpression(transformer)); > trn.copyNodeMetaData(this); > // GRECLIPSE add > trn.setSourcePosition(this); > // GRECLIPSE end > trn.setImplicitThis(isImplicitThis()); > trn.setSafe(isSafe()); > trn.setSpreadSafe(isSpreadSafe()); > return trn; > } > {code} > MethodCallExpression could use an override of setSourcePosition to try and > propagate some info to method and arguments expressions. Here is what I came > up with: > {code} > public void setSourcePosition(ASTNode node) { > super.setSourcePosition(node); > if (node instanceof MethodCall) { > if (node instanceof MethodCallExpression) { > method.setSourcePosition(((MethodCallExpression) > node).getMethod()); > } else { > method.setSourcePosition(node); > method.setEnd(method.getStart() + > getMethodAsString().length()); > } > if (arguments != null) { > arguments.setSourcePosition(((MethodCall) > node).getArguments()); > } > } else if (node instanceof PropertyExpression) { > method.setSourcePosition(((PropertyExpression) > node).getProperty()); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)