groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [2/6] groovy git commit: minor refactor: groovydoc will be more reproducible using LinkedHash{Set|Map} instead of Hash{Set|Map}
Date Sat, 22 Apr 2017 06:08:50 GMT
minor refactor: groovydoc will be more reproducible using LinkedHash{Set|Map} instead of Hash{Set|Map}


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

Branch: refs/heads/GROOVY_2_5_X
Commit: 8d0cf4e90e0e4a3c24d4e4f7df61eb2fb24329d3
Parents: e802f6f
Author: paulk <paulk@asert.com.au>
Authored: Sat Apr 22 07:28:26 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Sat Apr 22 16:08:27 2017 +1000

----------------------------------------------------------------------
 .../tools/groovydoc/GroovyDocTemplateEngine.java      | 14 +++++++-------
 .../groovy/tools/groovydoc/MockOutputTool.java        |  8 ++++----
 .../groovy/tools/groovydoc/SimpleGroovyClassDoc.java  | 14 +++++++-------
 .../groovydoc/SimpleGroovyClassDocAssembler.java      |  8 ++++----
 .../groovy/tools/groovydoc/SimpleGroovyRootDoc.java   |  8 ++++----
 5 files changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8d0cf4e9/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTemplateEngine.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTemplateEngine.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTemplateEngine.java
index 07f7119..ce63ed5 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTemplateEngine.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTemplateEngine.java
@@ -32,8 +32,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -66,9 +66,9 @@ public class GroovyDocTemplateEngine {
         this.docTemplatePaths = Arrays.asList(docTemplates);
         this.packageTemplatePaths = Arrays.asList(packageTemplates);
         this.classTemplatePaths = Arrays.asList(classTemplates);
-        this.docTemplates = new HashMap<String, Template>();
-        this.packageTemplates = new HashMap<String, Template>();
-        this.classTemplates = new HashMap<String, Template>();
+        this.docTemplates = new LinkedHashMap<String, Template>();
+        this.packageTemplates = new LinkedHashMap<String, Template>();
+        this.classTemplates = new LinkedHashMap<String, Template>();
         engine = new GStringTemplateEngine();
 
     }
@@ -82,7 +82,7 @@ public class GroovyDocTemplateEngine {
                 t = engine.createTemplate(resourceManager.getReader(templatePath));
                 classTemplates.put(templatePath, t);
             }
-            Map<String, Object> binding = new HashMap<String, Object>();
+            Map<String, Object> binding = new LinkedHashMap<String, Object>();
             binding.put("classDoc", classDoc);
             binding.put("props", properties);
             templateWithBindingApplied = t.make(binding).toString();
@@ -101,7 +101,7 @@ public class GroovyDocTemplateEngine {
                 t = engine.createTemplate(resourceManager.getReader(template));
                 packageTemplates.put(template, t);
             }
-            Map<String, Object> binding = new HashMap<String, Object>();
+            Map<String, Object> binding = new LinkedHashMap<String, Object>();
             binding.put("packageDoc", packageDoc);
             binding.put("props", properties);
             templateWithBindingApplied = t.make(binding).toString();
@@ -120,7 +120,7 @@ public class GroovyDocTemplateEngine {
                 t = engine.createTemplate(resourceManager.getReader(template));
                 docTemplates.put(template, t);
             }
-            Map<String, Object> binding = new HashMap<String, Object>();
+            Map<String, Object> binding = new LinkedHashMap<String, Object>();
             binding.put("rootDoc", rootDoc);
             binding.put("props", properties);
             templateWithBindingApplied = t.make(binding).toString();

http://git-wip-us.apache.org/repos/asf/groovy/blob/8d0cf4e9/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/MockOutputTool.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/MockOutputTool.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/MockOutputTool.java
index 0a384cf..260485d 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/MockOutputTool.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/MockOutputTool.java
@@ -18,8 +18,8 @@
  */
 package org.codehaus.groovy.tools.groovydoc;
 
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -28,8 +28,8 @@ public class MockOutputTool implements OutputTool {
     Map output;
     
     public MockOutputTool() {
-        outputAreas = new HashSet();
-        output = new HashMap();
+        outputAreas = new LinkedHashSet();
+        output = new LinkedHashMap();
     }
     
     public void makeOutputArea(String filename) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/8d0cf4e9/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
index a55aae8..f81f08e 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
@@ -40,7 +40,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
     public static final Pattern NAME_ARGS_REGEX = Pattern.compile("([^(]+)\\(([^)]*)\\)");
     public static final Pattern SPLIT_ARGS_REGEX = Pattern.compile(",\\s*");
     private static final List<String> PRIMITIVES = Arrays.asList("void", "boolean",
"byte", "short", "char", "int", "long", "float", "double");
-    private static final Map<String, String> TAG_TEXT = new HashMap<String, String>();
+    private static final Map<String, String> TAG_TEXT = new LinkedHashMap<String,
String>();
     static {
         TAG_TEXT.put("see", "See Also");
         TAG_TEXT.put("param", "Parameters");
@@ -91,7 +91,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
     }
 
     public SimpleGroovyClassDoc(List<String> importedClassesAndPackages, String name)
{
-        this(importedClassesAndPackages, new HashMap<String, String>(), name, new ArrayList<LinkArgument>());
+        this(importedClassesAndPackages, new LinkedHashMap<String, String>(), name,
new ArrayList<LinkArgument>());
     }
 
     /**
@@ -249,13 +249,13 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
     }
 
     public Set<GroovyClassDoc> getParentInterfaces() {
-        Set<GroovyClassDoc> result = new HashSet<GroovyClassDoc>();
+        Set<GroovyClassDoc> result = new LinkedHashSet<GroovyClassDoc>();
         result.add(this);
-        Set<GroovyClassDoc> next = new HashSet<GroovyClassDoc>();
+        Set<GroovyClassDoc> next = new LinkedHashSet<GroovyClassDoc>();
         next.addAll(Arrays.asList(this.interfaces()));
         while (!next.isEmpty()) {
             Set<GroovyClassDoc> temp = next;
-            next = new HashSet<GroovyClassDoc>();
+            next = new LinkedHashSet<GroovyClassDoc>();
             for (GroovyClassDoc t : temp) {
                 if (t instanceof SimpleGroovyClassDoc) {
                     next.addAll(((SimpleGroovyClassDoc)t).getParentInterfaces());
@@ -271,7 +271,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
     }
 
     private Set<GroovyClassDoc> getJavaInterfaces(ExternalGroovyClassDoc d) {
-        Set<GroovyClassDoc> result = new HashSet<GroovyClassDoc>();
+        Set<GroovyClassDoc> result = new LinkedHashSet<GroovyClassDoc>();
         Class[] interfaces = d.externalClass().getInterfaces();
         if (interfaces != null) {
             for (Class i : interfaces) {
@@ -858,7 +858,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
         Matcher matcher = regex.matcher(self + "@endMarker");
         if (matcher.find()) {
             matcher.reset();
-            Map<String, List<String>> savedTags = new HashMap<String, List<String>>();
+            Map<String, List<String>> savedTags = new LinkedHashMap<String,
List<String>>();
             StringBuffer sb = new StringBuffer();
             while (matcher.find()) {
                 String tagname = matcher.group(1);

http://git-wip-us.apache.org/repos/asf/groovy/blob/8d0cf4e9/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
index 7439ea7..678f2e3 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
@@ -59,7 +59,7 @@ public class SimpleGroovyClassDocAssembler extends VisitorAdapter implements
Gro
         this.isGroovy = isGroovy;
 
         stack = new Stack<GroovySourceAST>();
-        classDocs = new HashMap<String, GroovyClassDoc>();
+        classDocs = new LinkedHashMap<String, GroovyClassDoc>();
         if (file != null) {
             // todo: replace this simple idea of default class name
             int idx = file.lastIndexOf(".");
@@ -70,7 +70,7 @@ public class SimpleGroovyClassDocAssembler extends VisitorAdapter implements
Gro
 
         deferSetup = packagePath.equals("DefaultPackage");
         importedClassesAndPackages = new ArrayList<String>();
-        aliases = new HashMap<String, String>();
+        aliases = new LinkedHashMap<String, String>();
         if (!deferSetup) setUpImports(packagePath, links, isGroovy, className);
         lastLineCol = new LineColumn(1, 1);
     }
@@ -128,7 +128,7 @@ public class SimpleGroovyClassDocAssembler extends VisitorAdapter implements
Gro
             if (parent != null && isNested() && !insideAnonymousInnerClass())
{
                 className = parent.name() + "." + className;
             } else {
-                foundClasses = new HashMap<String, SimpleGroovyClassDoc>();
+                foundClasses = new LinkedHashMap<String, SimpleGroovyClassDoc>();
             }
             SimpleGroovyClassDoc current = (SimpleGroovyClassDoc) classDocs.get(packagePath
+ FS + className);
             if (current == null) {
@@ -273,7 +273,7 @@ public class SimpleGroovyClassDocAssembler extends VisitorAdapter implements
Gro
             }
             classDocs.put(currentClassDoc.getFullPathName(), currentClassDoc);
             if (foundClasses == null) {
-                foundClasses = new HashMap<String, SimpleGroovyClassDoc>();
+                foundClasses = new LinkedHashMap<String, SimpleGroovyClassDoc>();
             }
             foundClasses.put(className, currentClassDoc);
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/8d0cf4e9/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
index 9ba010f..7c9c172 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
@@ -24,7 +24,7 @@ import org.codehaus.groovy.groovydoc.GroovyRootDoc;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -37,8 +37,8 @@ public class SimpleGroovyRootDoc extends SimpleGroovyDoc implements GroovyRootDo
 
     public SimpleGroovyRootDoc(String name) {
         super(name);
-        packageDocs = new HashMap<String, GroovyPackageDoc>();
-        classDocs = new HashMap<String, GroovyClassDoc>();
+        packageDocs = new LinkedHashMap<String, GroovyPackageDoc>();
+        classDocs = new LinkedHashMap<String, GroovyClassDoc>();
     }
 
     public GroovyClassDoc classNamed(GroovyClassDoc groovyClassDoc, String name) {
@@ -119,7 +119,7 @@ public class SimpleGroovyRootDoc extends SimpleGroovyDoc implements GroovyRootDo
     }
 
     public Map<String, GroovyClassDoc> getVisibleClasses(List importedClassesAndPackages)
{
-        Map<String, GroovyClassDoc> visibleClasses = new HashMap<String, GroovyClassDoc>();
+        Map<String, GroovyClassDoc> visibleClasses = new LinkedHashMap<String, GroovyClassDoc>();
         for (String fullClassName : classDocs.keySet()) {
             String equivalentPackageImport = fullClassName.replaceAll("[^/]+$", "*");
             if (importedClassesAndPackages.contains(fullClassName) ||


Mime
View raw message