Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: compiler/java/com/google/dart/compiler/DartCompilerMainContext.java

Issue 9148026: Recompile unit with potential conflict/dependency on some top-level symbol. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix for compiling corelib, so NPE in TreeShaker Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/DartCompilerMainContext.java
diff --git a/compiler/java/com/google/dart/compiler/DartCompilerMainContext.java b/compiler/java/com/google/dart/compiler/DartCompilerMainContext.java
index 5aff52ca5e2373cf86cd10783157a8bf28a1d57d..beb23040698e28a5334e11ef25588d0fe765887c 100644
--- a/compiler/java/com/google/dart/compiler/DartCompilerMainContext.java
+++ b/compiler/java/com/google/dart/compiler/DartCompilerMainContext.java
@@ -4,6 +4,8 @@
package com.google.dart.compiler;
+import com.google.common.collect.Lists;
+import com.google.common.collect.MapMaker;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.metrics.CompilerMetrics;
@@ -14,6 +16,9 @@ import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -29,6 +34,8 @@ final class DartCompilerMainContext implements DartCompilerListener, DartCompile
private final LibrarySource lib;
private final DartArtifactProvider provider;
private final DartCompilerListener listener;
+ private final Map<Source, List<DartCompilationError>> errors =
+ new MapMaker().weakKeys().makeMap();
private final AtomicInteger errorCount = new AtomicInteger(0);
private final AtomicInteger warningCount = new AtomicInteger(0);
private final AtomicInteger typeErrorCount = new AtomicInteger(0);
@@ -49,6 +56,19 @@ final class DartCompilerMainContext implements DartCompilerListener, DartCompile
@Override
public void onError(DartCompilationError event) {
+ // Remember error.
+ {
+ Source source = event.getSource();
+ if (source != null) {
+ List<DartCompilationError> sourceErrors = errors.get(source);
+ if (sourceErrors == null) {
+ sourceErrors = Lists.newArrayList();
+ errors.put(source, sourceErrors);
+ }
+ sourceErrors.add(event);
+ }
+ }
+ // Increment counters.
if (event.getErrorCode().getSubSystem() == SubSystem.STATIC_TYPE) {
incrementTypeErrorCount();
} else if (shouldWarnOnNoSuchType() && event.getErrorCode() == ResolverErrorCode.NO_SUCH_TYPE) {
@@ -58,6 +78,7 @@ final class DartCompilerMainContext implements DartCompilerListener, DartCompile
} else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.WARNING) {
incrementWarningCount();
}
+ // Notify listener.
listener.onError(event);
}
@@ -102,6 +123,17 @@ final class DartCompilerMainContext implements DartCompilerListener, DartCompile
return provider.getArtifactWriter(source, part, extension);
}
+ /**
+ * @return the {@link DartCompilationError}s found in the given {@link Source}.
+ */
+ public List<DartCompilationError> getSourceErrors(Source source) {
+ List<DartCompilationError> sourceErrors = errors.get(source);
+ if (sourceErrors != null) {
+ return sourceErrors;
+ }
+ return Collections.emptyList();
+ }
+
public int getErrorCount() {
return errorCount.get();
}

Powered by Google App Engine
This is Rietveld 408576698