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

Unified Diff: dart/lib/compiler/implementation/scanner/scanner_task.dart

Issue 11092003: Implement part-of directive. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update co19 status for dart2dart Created 8 years, 2 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: dart/lib/compiler/implementation/scanner/scanner_task.dart
diff --git a/dart/lib/compiler/implementation/scanner/scanner_task.dart b/dart/lib/compiler/implementation/scanner/scanner_task.dart
index 67e98af7def120e094320a79cee09998a1bf8a2a..b91001b4a45efd9e48cadaf0fb0779d08cdfa213 100644
--- a/dart/lib/compiler/implementation/scanner/scanner_task.dart
+++ b/dart/lib/compiler/implementation/scanner/scanner_task.dart
@@ -6,6 +6,9 @@ class ScannerTask extends CompilerTask {
ScannerTask(Compiler compiler) : super(compiler);
String get name => 'Scanner';
+ final Map<String, LibraryElement> libraryNames =
+ new Map<String, LibraryElement>();
+
void scanLibrary(LibraryElement library) {
var compilationUnit = library.entryCompilationUnit;
compiler.log("scanning library ${compilationUnit.script.name}");
@@ -55,6 +58,7 @@ class ScannerTask extends CompilerTask {
} else {
library.libraryTag = tag;
}
+ checkDuplicatedLibraryName(library);
} else if (tag.isPart) {
StringNode uri = tag.uri;
Uri resolved = base.resolve(uri.dartString.slowToString());
@@ -82,6 +86,27 @@ class ScannerTask extends CompilerTask {
}
}
+ void checkDuplicatedLibraryName(LibraryElement library) {
+ LibraryTag tag = library.libraryTag;
+ if (tag != null) {
+ String name = library.getLibraryOrScriptName();
+ LibraryElement existing =
+ libraryNames.putIfAbsent(name, () => library);
+ if (existing !== library) {
+ Uri uri = library.entryCompilationUnit.script.uri;
+ compiler.reportMessage(
+ compiler.spanFromNode(tag.name, uri),
+ MessageKind.DUPLICATED_LIBRARY_NAME.error([name]),
+ api_s.Diagnostic.WARNING);
+ Uri existingUri = existing.entryCompilationUnit.script.uri;
+ compiler.reportMessage(
+ compiler.spanFromNode(existing.libraryTag.name, existingUri),
+ MessageKind.DUPLICATED_LIBRARY_NAME.error([name]),
+ api_s.Diagnostic.WARNING);
+ }
+ }
+ }
+
/**
* Handle a part tag in the scope of [library]. The [path] given is used as
* is, any resolution should be done beforehand.

Powered by Google App Engine
This is Rietveld 408576698