Skip to content
Permalink
Browse files
Groovy-10520: Capture correct line numbers for Closure/Block statements.
  • Loading branch information
John Engelman authored and paulk-asert committed Mar 8, 2022
1 parent 6566ea3 commit e7feb3e296b5df49dabcd96cbde54d5a6460e49b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
@@ -499,7 +499,7 @@ lambdaBody

// CLOSURE
closure
: LBRACE (nls (formalParameterList nls)? ARROW)? sep? blockStatementsOpt RBRACE
: LBRACE (nls (formalParameterList nls)? ARROW)? blockStatementsOpt RBRACE
;

// GROOVY-8991: Difference in behaviour with closure and lambda
@@ -509,7 +509,7 @@ closureOrLambdaExpression
;

blockStatementsOpt
: blockStatements?
: sep? blockStatements?
;

blockStatements
@@ -560,7 +560,7 @@ elementValueArrayInitializer
// STATEMENTS / BLOCKS

block
: LBRACE sep? blockStatementsOpt RBRACE
: LBRACE blockStatementsOpt RBRACE
;

blockStatement
@@ -171,6 +171,14 @@ var = f{closure}
:::[MethodCallExpression,(1:7),(1:17)];
[ConstantExpression,(1:7),(1:8)][ArgumentListExpression,(1:8),(1:17)][ClosureExpression,(1:8),(1:17)]


###closureExpressionWithEmptyBlockStatement:::
f{

}
:::[MethodCallExpression,(1:1),(3:2)];
[ConstantExpression,(1:1),(1:2)][ArgumentListExpression,(1:2),(3:2)][ClosureExpression,(1:2),(3:2)][BlockStatement,(1:3),(3:1)]

###ArrayExpressionD1:::
def array = new int[1]
:::[ArrayExpression,(1:13),(1:23)][ClassNode,(1:17),(1:20)][ConstantExpression,(1:21),(1:22)]

0 comments on commit e7feb3e

Please sign in to comment.