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

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

Issue 10532100: Issue 3532. Report error if one unit included twice (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check uniqueness using URIs Created 8 years, 6 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/DartCompiler.java
diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java
index 0639e82754e44d1d9b8c7aab1822e5e9684ce8cd..8842ec66bad4dc780c7e105aedc15260883e4944 100644
--- a/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -619,6 +619,20 @@ public class DartCompiler {
if (SystemLibraryManager.isDartUri(lib.getSource().getUri())) {
continue;
}
+
+ // check for #source uniqueness
+ {
+ Set<URI> includedSourceUris = Sets.newHashSet();
+ for (LibraryNode sourceNode : lib.getSourcePaths()) {
+ String path = sourceNode.getText();
+ URI uri = lib.getSource().getSourceFor(path).getUri();
+ if (includedSourceUris.contains(uri)) {
+ context.onError(new DartCompilationError(sourceNode.getSourceInfo(),
+ DartCompilerErrorCode.UNIT_WAS_ALREADY_INCLUDED, uri));
+ }
+ includedSourceUris.add(uri);
+ }
+ }
// Validate import prefixes.
for (LibraryNode importNode : lib.getImportPaths()) {
@@ -682,6 +696,7 @@ public class DartCompiler {
continue;
}
DartSource dartSource = (DartSource) unit.getSourceInfo().getSource();
+ // check for directives
if (dartSource.getRelativePath().equals(sourceNode.getText())) {
context.onError(new DartCompilationError(unit.getDirectives().get(0),
DartCompilerErrorCode.ILLEGAL_DIRECTIVES_IN_SOURCED_UNIT,

Powered by Google App Engine
This is Rietveld 408576698