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 2022/04/19 07:46:52 UTC

[groovy] 02/02: minor refactor: remove groovy-macro style warnings

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

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit b5301d60e470f69e2c82cb5f7a0902a6240b331b
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Apr 19 17:33:00 2022 +1000

    minor refactor: remove groovy-macro style warnings
---
 .../macro/matcher/ContextualClassCodeVisitor.java     |  3 ++-
 .../codehaus/groovy/macro/matcher/TreeContext.java    | 19 +++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ContextualClassCodeVisitor.java b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ContextualClassCodeVisitor.java
index 2c2cf4d252..d6b28ecc04 100644
--- a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ContextualClassCodeVisitor.java
+++ b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/ContextualClassCodeVisitor.java
@@ -613,8 +613,9 @@ public abstract class ContextualClassCodeVisitor extends ClassCodeVisitorSupport
 
     // ----------------------------- inner classes --------------------------------------
 
+    @SuppressWarnings("unchecked")
     public static List<ASTNodePredicate> matchByClass(Class<ASTNode>... classes) {
-        ArrayList<ASTNodePredicate> result = new ArrayList<ASTNodePredicate>(classes.length);
+        ArrayList<ASTNodePredicate> result = new ArrayList<>(classes.length);
         for (final Class<ASTNode> astNodeClass : classes) {
             result.add(new MatchByClass(astNodeClass));
         }
diff --git a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/TreeContext.java b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/TreeContext.java
index f8fd564e49..11cd47fc8b 100644
--- a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/TreeContext.java
+++ b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/TreeContext.java
@@ -37,13 +37,12 @@ public class TreeContext {
     }
     final TreeContext parent;
     final ASTNode node;
-    final List<TreeContext> siblings = new LinkedList<TreeContext>();
-    final List<TreeContextAction> onPopHandlers = new LinkedList<TreeContextAction>();
-    final Map<Object, List<?>> userdata = MapWithDefault.newInstance(
-            new HashMap<Object, List<?>>(),
-            new Closure(this) {
+    final List<TreeContext> siblings = new LinkedList<>();
+    final List<TreeContextAction> onPopHandlers = new LinkedList<>();
+    final Map<Object, List<Object>> userdata = MapWithDefault.newInstance(
+            new HashMap<Object, List<Object>>(),
+            new Closure<List<Object>>(this) {
                 private static final long serialVersionUID = -4694773031569936343L;
-
                 public Object doCall(Object key) {
                     return new LinkedList<Object>();
                 }
@@ -58,19 +57,20 @@ public class TreeContext {
         }
     }
 
-    public Map<?, List<?>> getUserdata() {
+    public Map<Object, List<Object>> getUserdata() {
         return userdata;
     }
 
+    @SuppressWarnings("unchecked")
     public void putUserdata(Object key, Object value) {
         ((List)userdata.get(key)).add(value);
     }
 
-    public List<?> getUserdata(Object key) {
+    public List<Object> getUserdata(Object key) {
         return getUserdata(key,true);
     }
 
-    public List<?> getUserdata(Object key, boolean searchParent) {
+    public List<Object> getUserdata(Object key, boolean searchParent) {
         if (userdata.containsKey(key)) {
             return userdata.get(key);
         } else if (parent!=null && searchParent) {
@@ -136,7 +136,6 @@ public class TreeContext {
             sb.append("<-");
             p = p.parent;
         }
-        //sb.append(", siblings=").append(siblings);
         sb.append('}');
         return sb.toString();
     }