You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/03/08 13:29:23 UTC

[groovy] branch GROOVY_4_0_X updated: Revert "Groovy-10520: Capture correct line numbers for Closure/Block statements."

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new 73c136e  Revert "Groovy-10520: Capture correct line numbers for Closure/Block statements."
73c136e is described below

commit 73c136ec68d3b62026e177d6ea07e0950fc0dfcf
Author: Daniel Sun <su...@apache.org>
AuthorDate: Tue Mar 8 21:28:53 2022 +0800

    Revert "Groovy-10520: Capture correct line numbers for Closure/Block statements."
    
    This reverts commit 638ba3d3b1d21060ec3549349fcd6389ccfa4079.
---
 src/antlr/GroovyParser.g4                            | 6 +++---
 src/test/org/codehaus/groovy/ast/LineColumnCheck.txt | 8 --------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 1e5662a..9d26199 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -499,7 +499,7 @@ lambdaBody
 
 // CLOSURE
 closure
-    :   LBRACE (nls (formalParameterList nls)? ARROW)? blockStatementsOpt RBRACE
+    :   LBRACE (nls (formalParameterList nls)? ARROW)? sep? blockStatementsOpt RBRACE
     ;
 
 // GROOVY-8991: Difference in behaviour with closure and lambda
@@ -509,7 +509,7 @@ closureOrLambdaExpression
     ;
 
 blockStatementsOpt
-    :   sep? blockStatements?
+    :   blockStatements?
     ;
 
 blockStatements
@@ -560,7 +560,7 @@ elementValueArrayInitializer
 // STATEMENTS / BLOCKS
 
 block
-    :   LBRACE blockStatementsOpt RBRACE
+    :   LBRACE sep? blockStatementsOpt RBRACE
     ;
 
 blockStatement
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
index 353e2e3..4148608 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
@@ -171,14 +171,6 @@ 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)]