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:03:54 UTC

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

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 cc66180  Tweak text of `MethodCallExpression`
     new 8e5c9db  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   (cc66180)
            \
             N -- N -- N   refs/heads/danielsun/tweak-mce-text (8e5c9db)

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:
 .../java/org/codehaus/groovy/ast/expr/MethodCallExpression.java    | 2 +-
 .../org/codehaus/groovy/ast/expr/MethodCallExpressionTest.groovy   | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

[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 8e5c9db174da7e01e5241b06dbb13692da2268f1
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 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

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()
     }
 }