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

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

Issue 10986073: Virtual filesystem support for dart_analyzer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 12972)
+++ compiler/java/com/google/dart/compiler/SystemLibraryManager.java (working copy)
@@ -24,18 +24,22 @@
private HashMap<String, String> expansionMap;
private Map<String, SystemLibrary> hostMap;
- private final File sdkLibPath;
private final URI sdkLibPathUri;
private Map<URI, URI> longToShortUriMap;
private List<SystemLibrary> libraries;
+ private final SystemLibraryProvider libraryProvider;
public SystemLibraryManager(File sdkPath) {
- this.sdkLibPath = new File(sdkPath, "lib").getAbsoluteFile();
- this.sdkLibPathUri = sdkLibPath.toURI();
- setLibraries(getDefaultLibraries());
+ this(new FileBasedSystemLibraryProvider(sdkPath));
}
+
+ public SystemLibraryManager(SystemLibraryProvider libraryProvider) {
+ this.libraryProvider = libraryProvider;
+ this.sdkLibPathUri = libraryProvider.getSdkLibPathUri();
+ setLibraries(getDefaultLibraries());
+ }
public URI expandRelativeDartUri(URI uri) throws AssertionError {
String host = uri.getHost();
@@ -94,8 +98,8 @@
if (library != null) {
return library.translateUri(uri);
}
- if (host != null) {
- return new File(getSdkLibPath(), host).toURI().resolve("." + uri.getPath());
+ if (host != null) {
+ return libraryProvider.resolveHost(host, uri);
}
throw new RuntimeException("No system library defined for " + uri);
@@ -124,8 +128,7 @@
// Cycle through the import.config, extracting explicit mappings and searching directories
URI base = this.sdkLibPathUri;
- SystemLibrariesReader reader = new SystemLibrariesReader(sdkLibPath);
- Map<String, DartLibrary> declaredLibraries = reader.getLibrariesMap();
+ Map<String, DartLibrary> declaredLibraries = libraryProvider.getLibraryMap();
HashSet<String> explicitShortNames = new HashSet<String>();
@@ -142,11 +145,12 @@
} catch (URISyntaxException e) {
continue;
}
- File file = new File(libFileUri);
- if (!file.exists()) {
+
+ if (!libraryProvider.exists(libFileUri)) {
throw new InternalCompilerException("Can't find system library dart:" + shortName
- + " at " + file);
+ + " at " + libFileUri);
}
+
int index = shortName.indexOf(':');
if (index == -1) {
continue;
@@ -161,13 +165,11 @@
continue;
}
String host = relPath.substring(0, index);
- File dir = new File(sdkLibPath, host);
String pathToLib = relPath.substring(index + 1);
addLib(scheme,
host,
name,
- dir,
pathToLib,
library.getCategory(),
library.isDocumented(),
@@ -177,17 +179,13 @@
return libraries.toArray(new SystemLibrary[libraries.size()]);
}
- private boolean addLib(String scheme, String host, String name, File dir, String pathToLib,
+ protected boolean addLib(String scheme, String host, String name, String pathToLib,
String category, boolean documented, boolean implementation)
throws AssertionError {
- File libFile = new File(dir, pathToLib);
- if (!libFile.isFile()) {
- throw new InternalCompilerException("Error mapping dart:" + host + ", path "
- + libFile.getAbsolutePath() + " is not a file.");
- }
- SystemLibrary lib = new SystemLibrary(
- name, host, pathToLib, dir, category, documented, implementation);
+
+ SystemLibrary lib = libraryProvider.createSystemLibrary(name, host, pathToLib, category, documented, implementation);
libraries.add(lib);
+
String libSpec = scheme + name;
URI libUri;
URI expandedUri;
@@ -224,9 +222,5 @@
"//" + host + "/" + library.getPathToLib());
}
}
-
- public File getSdkLibPath() {
- return sdkLibPath;
- }
}

Powered by Google App Engine
This is Rietveld 408576698