Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.4
-
Fix Version/s: 1.8.6, 2.0-beta-3
-
Component/s: parser-antlr
-
Labels:None
-
Number of attachments :
Description
Take this code and put it into the groovy console:
def meth() {
label:
assert i == 9
}
Now inspect the AST and navigate to the assert statement. You will see that the assert statement has a lineNumber and lastLineNumber are 2, but it should be 3. This is incorrect. It doesn't seem like this affects Groovy itself too much, but this is causing an exception in Groovy-Eclipse. See GRECLIPSE-1270.
The fix is simple enough.
Issue Links
- is related to
-
GRECLIPSE-1270
IndexOutOfBoundsException with assert keyword in Spock test
-
Fix: in org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AST) at the end of the method, change:
to:
This problem is coming about because the source location of statement is being set twice: once from within the call to labeledStatment using the correct source location and once again using the source location for just the label in the call to statement.
This leads me to question if explicitly calling configureAST is necessary at all in the statement method since all calls to create the different kinds of statements already call configureAST.