You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2020/06/25 19:12:01 UTC

[groovy] branch master updated: set start position of implicit-this for error reporting

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

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


The following commit(s) were added to refs/heads/master by this push:
     new f3f4853  set start position of implicit-this for error reporting
f3f4853 is described below

commit f3f4853ea22d2c193fdcd5136a0fde4d3cb45f0f
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jun 25 14:11:52 2020 -0500

    set start position of implicit-this for error reporting
---
 .../org/apache/groovy/parser/antlr4/AstBuilder.java     | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 86c4c9d..afa0fa2 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -2429,9 +2429,13 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
             }
 
             // e.g.  m { return 1; }
+            Expression thisExpr = new VariableExpression("this");
+            thisExpr.setColumnNumber(baseExpr.getColumnNumber());
+            thisExpr.setLineNumber(baseExpr.getLineNumber());
+
             MethodCallExpression methodCallExpression =
                     new MethodCallExpression(
-                            new VariableExpression("this"),
+                            thisExpr,
 
                             (baseExpr instanceof VariableExpression)
                                     ? this.createConstantExpression(baseExpr)
@@ -2442,7 +2446,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
                                     closureExpression)
                     );
 
-
             return configureAST(methodCallExpression, ctx);
         }
 
@@ -4210,8 +4213,12 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
 
     // e.g. m(1, 2) or m 1, 2
     private MethodCallExpression createMethodCallExpression(Expression baseExpr, Expression arguments) {
-        MethodCallExpression methodCallExpression = new MethodCallExpression(
-                new VariableExpression("this"),
+        Expression thisExpr = new VariableExpression("this");
+        thisExpr.setColumnNumber(baseExpr.getColumnNumber());
+        thisExpr.setLineNumber(baseExpr.getLineNumber());
+
+        return new MethodCallExpression(
+                thisExpr,
 
                 (baseExpr instanceof VariableExpression)
                         ? this.createConstantExpression(baseExpr)
@@ -4219,8 +4226,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
 
                 arguments
         );
-
-        return methodCallExpression;
     }
 
     private Parameter processFormalParameter(GroovyParserRuleContext ctx,