You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/04/11 01:38:14 UTC

[38/50] groovy git commit: Minor refactoring

Minor refactoring


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

Branch: refs/heads/master
Commit: a1d5b6a2cee1f0f80941bffb159a52175f3e09f8
Parents: fc490b9
Author: sunlan <su...@apache.org>
Authored: Tue Mar 28 09:18:48 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Tue Mar 28 09:18:48 2017 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/classgen/ClassCompletionVerifier.java    | 2 +-
 src/main/org/codehaus/groovy/classgen/VariableScopeVisitor.java  | 2 +-
 src/main/org/codehaus/groovy/syntax/Types.java                   | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/a1d5b6a2/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java b/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
index 4319f2a..41b96c2 100644
--- a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
+++ b/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
@@ -510,7 +510,7 @@ public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
         }
         super.visitBinaryExpression(expression);
 
-        if (Types.ASSIGNMENT_SET.contains(expression.getOperation().getType())) {
+        if (Types.isAssignment(expression.getOperation().getType())) {
             checkFinalFieldAccess(expression.getLeftExpression());
             checkSuperOrThisOnLHS(expression.getLeftExpression());
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/a1d5b6a2/src/main/org/codehaus/groovy/classgen/VariableScopeVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/VariableScopeVisitor.java b/src/main/org/codehaus/groovy/classgen/VariableScopeVisitor.java
index ad9dd76..7a99014 100644
--- a/src/main/org/codehaus/groovy/classgen/VariableScopeVisitor.java
+++ b/src/main/org/codehaus/groovy/classgen/VariableScopeVisitor.java
@@ -348,7 +348,7 @@ public class VariableScopeVisitor extends ClassCodeVisitorSupport {
     public void visitBinaryExpression(BinaryExpression be) {
         super.visitBinaryExpression(be);
 
-        if (Types.ASSIGNMENT_SET.contains(be.getOperation().getType())) {
+        if (Types.isAssignment(be.getOperation().getType())) {
             checkFinalFieldAccess(be.getLeftExpression());
         }
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/a1d5b6a2/src/main/org/codehaus/groovy/syntax/Types.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/syntax/Types.java b/src/main/org/codehaus/groovy/syntax/Types.java
index f03fc18..7265009 100644
--- a/src/main/org/codehaus/groovy/syntax/Types.java
+++ b/src/main/org/codehaus/groovy/syntax/Types.java
@@ -1448,4 +1448,8 @@ public class Types
     }
 
     public static final Set<Integer> ASSIGNMENT_SET = new HashSet<Integer>(Arrays.asList(EQUAL, BITWISE_AND_EQUAL, BITWISE_OR_EQUAL, BITWISE_XOR_EQUAL, PLUS_EQUAL, MINUS_EQUAL, MULTIPLY_EQUAL, DIVIDE_EQUAL, INTDIV_EQUAL, MOD_EQUAL, POWER_EQUAL, LEFT_SHIFT_EQUAL, RIGHT_SHIFT_EQUAL, RIGHT_SHIFT_UNSIGNED_EQUAL, ELVIS_EQUAL));
+
+    public static boolean isAssignment(Integer type) {
+        return ASSIGNMENT_SET.contains(type);
+    }
 }