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

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

Issue 9909012: Prevent duplicate entries in the bundled libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/SystemLibraryManager.java
===================================================================
--- compiler/java/com/google/dart/compiler/SystemLibraryManager.java (revision 5968)
+++ compiler/java/com/google/dart/compiler/SystemLibraryManager.java (working copy)
@@ -198,6 +198,7 @@
protected SystemLibrary[] getDefaultLibraries() {
libraries = new ArrayList<SystemLibrary>();
longToShortUriMap = new HashMap<URI, URI>();
+ HashMap<URI, SystemLibrary> shortUriToLibraryMap = new HashMap<URI, SystemLibrary>();
zundel 2012/03/29 15:17:36 This map looks like dart:html --> systemlibrary1
danrubel 2012/03/29 17:00:57 Done.
// Cycle through the import.config, extracting explicit mappings and searching directories
URI base = this.sdkLibPathUri;
@@ -239,7 +240,7 @@
// for libraries and don't want the error to be fatal.
continue;
}
- addLib(shortName, host, host, child, dartFile.getName());
+ addLib(shortUriToLibraryMap, shortName, host, host, child, dartFile.getName());
}
} else {
// Otherwise treat the entry as an explicit shortName to dart file mapping
@@ -250,7 +251,7 @@
explicitShortNames.add(shortName);
String scheme = shortName.substring(0, index + 1);
String host = shortName.substring(index + 1);
- addLib(scheme, host, host, file.getParentFile(), file.getName());
+ addLib(shortUriToLibraryMap, scheme, host, host, file.getParentFile(), file.getName());
}
}
return libraries.toArray(new SystemLibrary[libraries.size()]);
@@ -274,15 +275,13 @@
return importConfig;
}
- private boolean addLib(String scheme, String host, String name, File dir, String libFileName)
+ private boolean addLib(HashMap<URI, SystemLibrary> shortUriToLibraryMap, String scheme, String host, String name, File dir, String libFileName)
throws AssertionError {
File libFile = new File(dir, libFileName);
if (!libFile.isFile()) {
throw new InternalCompilerException("Error mapping dart:" + host + ", path "
+ libFile.getAbsolutePath() + " is not a file.");
}
- SystemLibrary lib = new SystemLibrary(name, host, libFileName, dir);
- libraries.add(lib);
String libSpec = scheme + name;
URI libUri;
URI expandedUri;
@@ -292,6 +291,13 @@
} catch (URISyntaxException e) {
throw new AssertionError(e);
}
+ SystemLibrary lib = shortUriToLibraryMap.get(libUri);
+ if (lib != null) {
+ libraries.remove(lib);
+ }
+ lib = new SystemLibrary(name, host, libFileName, dir);
+ libraries.add(lib);
+ shortUriToLibraryMap.put(libUri, lib);
URI resolvedUri = lib.translateUri(expandedUri);
longToShortUriMap.put(resolvedUri, libUri);
longToShortUriMap.put(expandedUri, libUri);

Powered by Google App Engine
This is Rietveld 408576698