Re: groovy git commit: Refine the node position of path expression

2017-08-05 Thread Jochen Theodorou



On 05.08.2017 14:58, sun...@apache.org wrote:

Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X edd461375 -> a6e5328f8


Refine the node position of path expression

(cherry picked from commit 3b59585)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a6e5328f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a6e5328f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a6e5328f

Branch: refs/heads/GROOVY_2_6_X
Commit: a6e5328f81c1580f943f7799f3f61635ffa34faf
Parents: edd4613
Author: sunlan 
Authored: Sat Aug 5 20:54:56 2017 +0800
Committer: sunlan 
Committed: Sat Aug 5 20:58:03 2017 +0800

--
 .../groovy/control/CompilerConfiguration.java   |  4 
 .../transform/stc/DelegatesToSTCTest.groovy | 23 ++--
 .../apache/groovy/parser/antlr4/AstBuilder.java |  6 ++---
 3 files changed, 28 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
--
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java 
b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index 17ac7cf..8a0d26f 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -905,4 +905,8 @@ public class CompilerConfiguration {
 public void setBytecodePostprocessor(final BytecodeProcessor 
bytecodePostprocessor) {
 this.bytecodePostprocessor = bytecodePostprocessor;
 }
+
+public boolean isAntlr2Parser() {
+return antlr2Parser;
+}
 }


I think we should not have this method in a public API like 
CompilerConfiguration or at least make it deprecated from the start. Of 
course I am aware of us needing that information and that it would fit 
in this class best, but from the API side I would not want to introduce 
methods that hint for the specific technology used if possible. So I 
guess I would be also ok with some kind of parser version for example.


bye Jochen


groovy git commit: Refine the node position of path expression

2017-08-05 Thread sunlan
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X edd461375 -> a6e5328f8


Refine the node position of path expression

(cherry picked from commit 3b59585)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a6e5328f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a6e5328f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a6e5328f

Branch: refs/heads/GROOVY_2_6_X
Commit: a6e5328f81c1580f943f7799f3f61635ffa34faf
Parents: edd4613
Author: sunlan 
Authored: Sat Aug 5 20:54:56 2017 +0800
Committer: sunlan 
Committed: Sat Aug 5 20:58:03 2017 +0800

--
 .../groovy/control/CompilerConfiguration.java   |  4 
 .../transform/stc/DelegatesToSTCTest.groovy | 23 ++--
 .../apache/groovy/parser/antlr4/AstBuilder.java |  6 ++---
 3 files changed, 28 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
--
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java 
b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index 17ac7cf..8a0d26f 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -905,4 +905,8 @@ public class CompilerConfiguration {
 public void setBytecodePostprocessor(final BytecodeProcessor 
bytecodePostprocessor) {
 this.bytecodePostprocessor = bytecodePostprocessor;
 }
+
+public boolean isAntlr2Parser() {
+return antlr2Parser;
+}
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
--
diff --git a/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy 
b/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
index d58ae9b..9f8dd3f 100644
--- a/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
+++ b/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
@@ -609,7 +609,9 @@ class DelegatesToSTCTest extends StaticTypeCheckingTestCase 
{
 
 // GROOVY-6165
 void testDelegatesToGenericArgumentTypeAndTypo() {
-shouldFailWithMessages '''import groovy.transform.*
+boolean isAntlr2Parser = config.isAntlr2Parser()
+
+String code = '''import groovy.transform.*
 
 @TupleConstructor
 class Person { String name }
@@ -631,7 +633,24 @@ class DelegatesToSTCTest extends 
StaticTypeCheckingTestCase {
 }
 
 test([new Person('Guillaume'), new Person('Cedric')])
-''', 'Cannot find matching method'
+'''
+
+String msg = 'Cannot find matching method'
+
+if (isAntlr2Parser) {
+shouldFailWithMessages code, msg
+} else {
+/*
+ * Because the Parrot parser provides more accurate node position 
information,
+ * 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.addError will not 
be interfered by wrong node position.
+ *
+ * 1) TestScripttestDelegatesToGenericArgumentTypeAndTypo0.groovy: 
17: [Static type checking] - Cannot find matching method 
TestScripttestDelegatesToGenericArgumentTypeAndTypo0#getname(). Please check if 
the declared type is right and if the method exists.
+ * 2) TestScripttestDelegatesToGenericArgumentTypeAndTypo0.groovy: 
17: [Static type checking] - Cannot find matching method 
java.lang.Object#toUpperCase(). Please check if the declared type is right and 
if the method exists.
+ *
+ */
+shouldFailWithMessages code, msg, msg
+}
+
 }
 
 // GROOVY-6323, GROOVY-6325, GROOVY-6332

http://git-wip-us.apache.org/repos/asf/groovy/blob/a6e5328f/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
--
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 4d82c18..5dd8118 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
@@ -1937,9 +1937,9 @@ public class AstBuilder extends 
GroovyParserBaseVisitor implements Groov
 
 @Override
 public Expression visitPathExpression(PathExpressionContext ctx) {
-return this.configureAST(
-this.createPathExpression((Expression) 
this.visit(ctx.primary()), ctx.pathElement()),
-ctx);
+

groovy git commit: Refine the node position of path expression

2017-08-05 Thread sunlan
Repository: groovy
Updated Branches:
  refs/heads/master a3070da9a -> 3b5958538


Refine the node position of path expression


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3b595853
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3b595853
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3b595853

Branch: refs/heads/master
Commit: 3b595853853bb4935461a3deeccf5cf2ed67a0c7
Parents: a3070da
Author: sunlan 
Authored: Sat Aug 5 20:54:56 2017 +0800
Committer: sunlan 
Committed: Sat Aug 5 20:55:21 2017 +0800

--
 .../groovy/control/CompilerConfiguration.java   |  4 
 .../transform/stc/DelegatesToSTCTest.groovy | 23 ++--
 .../apache/groovy/parser/antlr4/AstBuilder.java |  6 ++---
 3 files changed, 28 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/3b595853/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
--
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java 
b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index c0f00c6..bafdfb6 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -905,4 +905,8 @@ public class CompilerConfiguration {
 public void setBytecodePostprocessor(final BytecodeProcessor 
bytecodePostprocessor) {
 this.bytecodePostprocessor = bytecodePostprocessor;
 }
+
+public boolean isAntlr2Parser() {
+return antlr2Parser;
+}
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/3b595853/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
--
diff --git a/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy 
b/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
index d58ae9b..9f8dd3f 100644
--- a/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
+++ b/src/test/groovy/transform/stc/DelegatesToSTCTest.groovy
@@ -609,7 +609,9 @@ class DelegatesToSTCTest extends StaticTypeCheckingTestCase 
{
 
 // GROOVY-6165
 void testDelegatesToGenericArgumentTypeAndTypo() {
-shouldFailWithMessages '''import groovy.transform.*
+boolean isAntlr2Parser = config.isAntlr2Parser()
+
+String code = '''import groovy.transform.*
 
 @TupleConstructor
 class Person { String name }
@@ -631,7 +633,24 @@ class DelegatesToSTCTest extends 
StaticTypeCheckingTestCase {
 }
 
 test([new Person('Guillaume'), new Person('Cedric')])
-''', 'Cannot find matching method'
+'''
+
+String msg = 'Cannot find matching method'
+
+if (isAntlr2Parser) {
+shouldFailWithMessages code, msg
+} else {
+/*
+ * Because the Parrot parser provides more accurate node position 
information,
+ * 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.addError will not 
be interfered by wrong node position.
+ *
+ * 1) TestScripttestDelegatesToGenericArgumentTypeAndTypo0.groovy: 
17: [Static type checking] - Cannot find matching method 
TestScripttestDelegatesToGenericArgumentTypeAndTypo0#getname(). Please check if 
the declared type is right and if the method exists.
+ * 2) TestScripttestDelegatesToGenericArgumentTypeAndTypo0.groovy: 
17: [Static type checking] - Cannot find matching method 
java.lang.Object#toUpperCase(). Please check if the declared type is right and 
if the method exists.
+ *
+ */
+shouldFailWithMessages code, msg, msg
+}
+
 }
 
 // GROOVY-6323, GROOVY-6325, GROOVY-6332

http://git-wip-us.apache.org/repos/asf/groovy/blob/3b595853/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
--
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 e8f0a9b..b65505a 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
@@ -1914,9 +1914,9 @@ public class AstBuilder extends 
GroovyParserBaseVisitor implements Groov
 
 @Override
 public Expression visitPathExpression(PathExpressionContext ctx) {
-return this.configureAST(
-this.createPathExpression((Expression) 
this.visit(ctx.primary()), ctx.pathElement()),
-ctx);
+return //this.configureAST(
+this