Reviewers: scottb, tobyr, jbrosenberg,

Description:
Users found that the error spam reduction hid too many errors.  This
change
makes the error spam reduction take into account inner classes and uses
the code
dependencies instead of just the API dependencies.


Please review this at http://gwt-code-reviews.appspot.com/1416801/

Affected files:
  M dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
  M dev/core/src/com/google/gwt/dev/javac/Shared.java


Index: dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java
===================================================================
--- dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java (revision 9985) +++ dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java (working copy)
@@ -18,6 +18,7 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.TreeLogger.HelpInfo;
 import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.dev.javac.Dependencies.Ref;
 import com.google.gwt.dev.util.Messages;
 import com.google.gwt.dev.util.Util;

@@ -65,17 +66,11 @@

     URL sourceURL = Util.findSourceInClassPath(cl, missingType);
     if (sourceURL != null) {
+      Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
       if (missingType.indexOf(".client.") != -1) {
-        Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
         Messages.HINT_CHECK_MODULE_INHERITANCE.log(logger, null);
       } else {
-        // Give the best possible hint here.
-        //
-        if (Util.findSourceInClassPath(cl, missingType) == null) {
- Messages.HINT_CHECK_MODULE_NONCLIENT_SOURCE_DECL.log(logger, null);
-        } else {
-          Messages.HINT_PRIOR_COMPILER_ERRORS.log(logger, null);
-        }
+        Messages.HINT_CHECK_MODULE_NONCLIENT_SOURCE_DECL.log(logger, null);
       }
     } else if (!missingType.equals("java.lang.Object")) {
       Messages.HINT_CHECK_TYPENAME.log(logger, missingType, null);
@@ -195,22 +190,31 @@
       return false;
     }
     TreeLogger branch =
- CompilationProblemReporter.reportErrors(logger, unit.getProblems(), unit
-            .getResourceLocation(), unit.isError(), new SourceFetcher() {
-
-          public String getSource() {
-            return unit.getSource();
-          }
-
-        }, unit.getTypeName(), suppressErrors);
+        CompilationProblemReporter.reportErrors(logger, unit.getProblems(),
+ unit.getResourceLocation(), unit.isError(), new SourceFetcher() {
+
+              public String getSource() {
+                return unit.getSource();
+              }
+
+            }, unit.getTypeName(), suppressErrors);
     return branch != null;
   }

private static void addUnitToVisit(Map<String, CompilationUnit> unitMap, String typeName,
-      Queue<CompilationUnit> toVisit) {
-    CompilationUnit found = unitMap.get(typeName);
-    if (found != null) {
+      Queue<CompilationUnit> toVisit, Set<CompilationUnit> visited) {
+    String topLevelType = typeName.replaceAll("\\$.*$", "");
+    CompilationUnit found = unitMap.get(topLevelType);
+    if (found != null && !visited.contains(found)) {
       toVisit.add(found);
+      visited.add(found);
+    }
+  }
+
+ private static void addUnitToVisit(Map<String, CompilationUnit> unitMap, Ref ref,
+      Queue<CompilationUnit> toVisit, Set<CompilationUnit> visited) {
+    if (ref != null) {
+ addUnitToVisit(unitMap, Shared.internalNameToBinaryName(ref.getInternalName()), toVisit, visited);
     }
   }

@@ -237,28 +241,27 @@
final Queue<CompilationUnit> toVisit = new LinkedList<CompilationUnit>();

     Map<String, CompilationUnit> unitMap = compilationState.unitMap;
-
     /*
      * Traverses CompilationUnits enqueued in toVisit(), calling {@link
* #addUnitsToVisit(String)} as it encounters dependencies on the node. Each * CompilationUnit is visited only once, and only if it is reachable via the
      * {@link Dependencies} graph.
      */
-    addUnitToVisit(unitMap, missingType, toVisit);
+    addUnitToVisit(unitMap, missingType, toVisit, visited);

     while (!toVisit.isEmpty()) {
       CompilationUnit unit = toVisit.remove();
-      if (visited.contains(unit)) {
-        continue;
-      }
-      visited.add(unit);
       CompilationProblemReporter.reportErrors(logger, unit, false);

       Dependencies deps = unit.getDependencies();
-      for (String ref : deps.getApiRefs()) {
-        addUnitToVisit(unitMap, ref, toVisit);
-      }
-    }
+      for (Ref ref : deps.qualified.values()) {
+        addUnitToVisit(unitMap, ref, toVisit, visited);
+      }
+      for (Ref ref : deps.simple.values()) {
+        addUnitToVisit(unitMap, ref, toVisit, visited);
+      }
+    }
+ logger.log(TreeLogger.DEBUG, "Checked " + visited.size() + " dependencies for errors.");
   }

   /**
Index: dev/core/src/com/google/gwt/dev/javac/Shared.java
===================================================================
--- dev/core/src/com/google/gwt/dev/javac/Shared.java   (revision 9985)
+++ dev/core/src/com/google/gwt/dev/javac/Shared.java   (working copy)
@@ -155,6 +155,10 @@
     return path.substring(0, path.lastIndexOf('.'));
   }

+  public static String internalNameToBinaryName(String internalName) {
+    return internalName.replace('/', '.');
+  }
+
   public static String toPath(String qualifiedTypeName) {
     return qualifiedTypeName.replace('.', '/') + ".java";
   }


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to