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 2021/07/24 13:08:01 UTC

[groovy] branch danielsun/tweak-mce-text updated (8e5c9db -> 4fab362)

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

sunlan pushed a change to branch danielsun/tweak-mce-text
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard 8e5c9db  Tweak text of `MethodCallExpression`
     new 4fab362  Tweak text of `MethodCallExpression`

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (8e5c9db)
            \
             N -- N -- N   refs/heads/danielsun/tweak-mce-text (4fab362)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .../src/test/groovy/org/apache/groovy/ginq/GinqErrorTest.groovy        | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

[groovy] 01/01: Tweak text of `MethodCallExpression`

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

sunlan pushed a commit to branch danielsun/tweak-mce-text
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4fab3627712aca18b8785d97faf00ed85bae52a6
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 24 20:49:35 2021 +0800

    Tweak text of `MethodCallExpression`
---
 .../java/org/codehaus/groovy/ast/expr/MethodCallExpression.java    | 3 ++-
 .../org/codehaus/groovy/ast/expr/MethodCallExpressionTest.groovy   | 7 +++++++
 .../src/test/groovy/org/apache/groovy/ginq/GinqErrorTest.groovy    | 3 +--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/expr/MethodCallExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/MethodCallExpression.java
index 1eef39e..12443c6 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/MethodCallExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/MethodCallExpression.java
@@ -142,7 +142,8 @@ public class MethodCallExpression extends Expression implements MethodCall {
         String args = arguments.getText();
         String spread = spreadSafe ? "*" : "";
         String dereference = safe ? "?" : "";
-        return object + spread + dereference + "." + meth + args;
+
+        return (implicitThis && "this".equals(object) && !spreadSafe && !safe ? "" : object + spread + dereference + ".") + meth + args;
     }
 
     /**
diff --git a/src/test/org/codehaus/groovy/ast/expr/MethodCallExpressionTest.groovy b/src/test/org/codehaus/groovy/ast/expr/MethodCallExpressionTest.groovy
index e0cff15..48f811f 100644
--- a/src/test/org/codehaus/groovy/ast/expr/MethodCallExpressionTest.groovy
+++ b/src/test/org/codehaus/groovy/ast/expr/MethodCallExpressionTest.groovy
@@ -41,5 +41,12 @@ class MethodCallExpressionTest extends GroovyTestCase {
         method.safe = true
         method.spreadSafe = true
         assert 'foo*?.bar(baz)' == method.text
+
+        def mce = new MethodCallExpression(new VariableExpression('this'), 'foo', new ArgumentListExpression())
+        mce.setImplicitThis(false)
+        assert 'this.foo()' == mce.getText()
+
+        mce.setImplicitThis(true)
+        assert 'foo()' == mce.getText()
     }
 }
diff --git a/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/GinqErrorTest.groovy b/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/GinqErrorTest.groovy
index bea17c9..4d7864a 100644
--- a/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/GinqErrorTest.groovy
+++ b/subprojects/groovy-ginq/src/test/groovy/org/apache/groovy/ginq/GinqErrorTest.groovy
@@ -21,7 +21,6 @@ package org.apache.groovy.ginq
 import groovy.transform.CompileStatic
 import org.junit.Test
 
-import static groovy.test.GroovyAssert.assertScript
 import static groovy.test.GroovyAssert.shouldFail
 
 @CompileStatic
@@ -358,7 +357,7 @@ class GinqErrorTest {
             }.toList()    
         '''
 
-        assert err.toString().contains('`this.hello(n)` is not an aggregate function @ line 4, column 27.')
+        assert err.toString().contains('`hello(n)` is not an aggregate function @ line 4, column 27.')
     }
 
     @Test