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 14:13:34 UTC

[groovy] branch GROOVY-10520 created (now 516df31)

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

sunlan pushed a change to branch GROOVY-10520
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 516df31  GROOVY-10520: Incorrect line numbers for Closure classes in AstNode

This branch includes the following new commits:

     new 516df31  GROOVY-10520: Incorrect line numbers for Closure classes in AstNode

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[groovy] 01/01: GROOVY-10520: Incorrect line numbers for Closure classes in AstNode

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 516df313d405af822a367a9b8a8ad912b46c5511
Author: Daniel Sun <su...@apache.org>
AuthorDate: Tue Mar 8 22:13:07 2022 +0800

    GROOVY-10520: Incorrect line numbers for Closure classes in AstNode
---
 src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java | 3 ++-
 src/test/org/codehaus/groovy/ast/LineColumnCheck.txt          | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 35d2b8f..8061d86 100644
--- a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -4131,11 +4131,12 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
                     ? this.visitFormalParameterList(ctx.formalParameterList())
                     : null;
 
+            Statement code = this.visitBlockStatementsOpt(ctx.blockStatementsOpt());
             if (!asBoolean(ctx.ARROW())) {
                 parameters = Parameter.EMPTY_ARRAY;
+                configureAST(code, ctx);
             }
 
-            Statement code = this.visitBlockStatementsOpt(ctx.blockStatementsOpt());
             ClosureExpression result = configureAST(new ClosureExpression(parameters, code), ctx);
 
             visitingClosureCount -= 1;
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
index 4148608..4bc8d6f 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
@@ -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:2),(3:2)]
+
 ###ArrayExpressionD1:::
 def array = new int[1]
 :::[ArrayExpression,(1:13),(1:23)][ClassNode,(1:17),(1:20)][ConstantExpression,(1:21),(1:22)]