Revision: 9993
Author:   zun...@google.com
Date:     Thu Apr 14 07:13:39 2011
Log: 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.

Review at http://gwt-code-reviews.appspot.com/1416801

http://code.google.com/p/google-web-toolkit/source/detail?r=9993

Modified:
/trunk/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java Tue Apr 5 03:08:39 2011 +++ /trunk/dev/core/src/com/google/gwt/dev/javac/CompilationProblemReporter.java Thu Apr 14 07:13:39 2011
@@ -65,17 +65,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 +189,26 @@
       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);
+ private static void addUnitToVisit(Map<String, CompiledClass> classMap, String typeName,
+      Queue<CompilationUnit> toVisit, Set<CompilationUnit> visited) {
+    CompiledClass found = classMap.get(typeName);
     if (found != null) {
-      toVisit.add(found);
+      CompilationUnit unit = found.getUnit();
+      if (!visited.contains(unit)) {
+        toVisit.add(unit);
+        visited.add(unit);
+      }
     }
   }

@@ -235,8 +233,7 @@
       CompilationState compilationState) {
     final Set<CompilationUnit> visited = new HashSet<CompilationUnit>();
final Queue<CompilationUnit> toVisit = new LinkedList<CompilationUnit>();
-
-    Map<String, CompilationUnit> unitMap = compilationState.unitMap;
+ Map<String, CompiledClass> classMap = compilationState.getClassFileMapBySource();

     /*
      * Traverses CompilationUnits enqueued in toVisit(), calling {@link
@@ -244,21 +241,17 @@
* CompilationUnit is visited only once, and only if it is reachable via the
      * {@link Dependencies} graph.
      */
-    addUnitToVisit(unitMap, missingType, toVisit);
+    addUnitToVisit(classMap, 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 (String apiRef : unit.getDependencies().getApiRefs()) {
+        addUnitToVisit(classMap, apiRef, toVisit, visited);
       }
     }
+ logger.log(TreeLogger.DEBUG, "Checked " + visited.size() + " dependencies for errors.");
   }

   /**

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

Reply via email to