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 2020/04/11 10:11:34 UTC

[groovy] branch danielsun/remove-dup-codes updated (cdf7c9f -> 536567a)

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

sunlan pushed a change to branch danielsun/remove-dup-codes
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard cdf7c9f  Eliminate duplicated code in `BindableASTTransformation`
     new 536567a  Eliminate duplicated code in `BindableASTTransformation`

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   (cdf7c9f)
            \
             N -- N -- N   refs/heads/danielsun/remove-dup-codes (536567a)

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/main/java/groovy/beans/BindableASTTransformation.java | 15 +++------------
 .../java/org/codehaus/groovy/control/ErrorCollector.java  |  8 ++++++++
 2 files changed, 11 insertions(+), 12 deletions(-)


[groovy] 01/01: Eliminate duplicated code in `BindableASTTransformation`

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

sunlan pushed a commit to branch danielsun/remove-dup-codes
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 536567a16fb8a67eaac0d19a3616b9cf5c3fa53e
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Apr 11 17:48:19 2020 +0800

    Eliminate duplicated code in `BindableASTTransformation`
---
 .../java/groovy/beans/BindableASTTransformation.java    | 17 +++--------------
 .../org/codehaus/groovy/control/ErrorCollector.java     |  8 ++++++++
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/main/java/groovy/beans/BindableASTTransformation.java b/src/main/java/groovy/beans/BindableASTTransformation.java
index 60474f9..65f0062 100644
--- a/src/main/java/groovy/beans/BindableASTTransformation.java
+++ b/src/main/java/groovy/beans/BindableASTTransformation.java
@@ -34,8 +34,6 @@ import org.codehaus.groovy.ast.tools.PropertyNodeUtils;
 import org.codehaus.groovy.control.CompilePhase;
 import org.codehaus.groovy.control.SourceUnit;
 import org.codehaus.groovy.control.messages.SimpleMessage;
-import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
-import org.codehaus.groovy.syntax.SyntaxException;
 import org.codehaus.groovy.transform.ASTTransformation;
 import org.codehaus.groovy.transform.GroovyASTTransformation;
 import org.objectweb.asm.Opcodes;
@@ -115,10 +113,7 @@ public class BindableASTTransformation implements ASTTransformation, Opcodes {
         ClassNode declaringClass = parent.getDeclaringClass();
         if (parent instanceof FieldNode) {
             if ((((FieldNode) parent).getModifiers() & Opcodes.ACC_FINAL) != 0) {
-                source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
-                        new SyntaxException("@groovy.beans.Bindable cannot annotate a final property.",
-                                node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
-                        source));
+                source.getErrorCollector().addErrorAndContinue("@groovy.beans.Bindable cannot annotate a final property.", node, source);
             }
 
             if (VetoableASTTransformation.hasVetoableAnnotation(parent.getDeclaringClass())) {
@@ -137,10 +132,7 @@ public class BindableASTTransformation implements ASTTransformation, Opcodes {
             if (propertyNode.getName().equals(fieldName)) {
                 if (field.isStatic()) {
                     //noinspection ThrowableInstanceNeverThrown
-                    source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
-                            new SyntaxException("@groovy.beans.Bindable cannot annotate a static property.",
-                                    node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
-                            source));
+                    source.getErrorCollector().addErrorAndContinue("@groovy.beans.Bindable cannot annotate a static property.", node, source);
                 } else {
                     if (needsPropertyChangeSupport(declaringClass, source)) {
                         addPropertyChangeSupport(declaringClass);
@@ -151,10 +143,7 @@ public class BindableASTTransformation implements ASTTransformation, Opcodes {
             }
         }
         //noinspection ThrowableInstanceNeverThrown
-        source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
-                new SyntaxException("@groovy.beans.Bindable must be on a property, not a field.  Try removing the private, protected, or public modifier.",
-                        node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
-                source));
+        source.getErrorCollector().addErrorAndContinue("@groovy.beans.Bindable must be on a property, not a field.  Try removing the private, protected, or public modifier.", node, source);
     }
 
     private void addListenerToClass(SourceUnit source, ClassNode classNode) {
diff --git a/src/main/java/org/codehaus/groovy/control/ErrorCollector.java b/src/main/java/org/codehaus/groovy/control/ErrorCollector.java
index 60fb05e..85bb723 100644
--- a/src/main/java/org/codehaus/groovy/control/ErrorCollector.java
+++ b/src/main/java/org/codehaus/groovy/control/ErrorCollector.java
@@ -18,6 +18,7 @@
  */
 package org.codehaus.groovy.control;
 
+import org.codehaus.groovy.ast.ASTNode;
 import org.codehaus.groovy.control.messages.ExceptionMessage;
 import org.codehaus.groovy.control.messages.LocatedMessage;
 import org.codehaus.groovy.control.messages.Message;
@@ -94,6 +95,13 @@ public class ErrorCollector implements Serializable {
         errors.add(message);
     }
 
+    public void addErrorAndContinue(String error, ASTNode node, SourceUnit source) {
+        addErrorAndContinue(new SyntaxErrorMessage(
+                new SyntaxException(error,
+                        node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
+                source));
+    }
+
     /**
      * Adds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded.
      * The message is not required to have a source line and column specified, but it is best practice to try