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

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

Issue 10823060: fix resolving import uri's for packages (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/UrlLibrarySource.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/SystemLibraryManager.java
===================================================================
--- compiler/java/com/google/dart/compiler/SystemLibraryManager.java (revision 9991)
+++ compiler/java/com/google/dart/compiler/SystemLibraryManager.java (working copy)
@@ -200,7 +200,7 @@
URI relativeUri = sdkLibPathUri.relativize(fileUri);
if (relativeUri.getScheme() == null) {
try {
- return new URI(null, null, "dart://" + relativeUri.getPath(), null);
+ return new URI(null, null, "dart://" + relativeUri.getPath(), null, null);
} catch (URISyntaxException e) {
//$FALL-THROUGH$
}
@@ -210,7 +210,7 @@
relativeUri = rootUri.relativize(fileUri);
if (relativeUri.getScheme() == null) {
try {
- return new URI(null, null, "package://" + relativeUri.getPath(), null);
+ return new URI(null, null, "package://" + relativeUri.getPath(), null, null);
} catch (URISyntaxException e) {
//$FALL-THROUGH$
}
@@ -228,6 +228,9 @@
public URI resolvePackageUri(String packageUriRef) {
if (packageUriRef.startsWith(PACKAGE_SCHEME_SPEC)) {
String relPath = packageUriRef.substring(PACKAGE_SCHEME_SPEC.length());
+ if (relPath.startsWith("/")){
+ relPath = relPath.replaceAll("^\\/+", "");
+ }
for (URI rootUri : packageRootsUri){
URI fileUri = rootUri.resolve(relPath);
if (new File(fileUri).exists()){
@@ -252,7 +255,7 @@
shortUri = getRelativeUri(uri);
if (shortUri != null){
try {
- return new URI(null, null, shortUri.getScheme() + ":" + shortUri.getHost() + shortUri.getPath(),null);
+ return new URI(null, null, shortUri.getScheme() + ":" + shortUri.getHost() + shortUri.getPath(),null, null);
} catch (URISyntaxException e) {
}
}
@@ -328,6 +331,20 @@
}
return uri;
}
+
+ /**
+ * Given a uri, resolve against the list of package roots, used to find generated files
+ * @return uri - resolved uri if file exists, else return given uri
+ */
+ public URI resolveRelativeUri(URI uri){
danrubel 2012/07/31 16:49:48 For clarity, rename parameter "uri" to "fileUri".
+
+ URI resolvedUri = getRelativeUri(uri);
+ if (isPackageUri(resolvedUri)){
+ resolvedUri = resolvePackageUri(resolvedUri.toString());
+ return resolvedUri;
+ }
+ return uri;
+ }
/**
* Resolves the given uri against the package root uri
@@ -369,7 +386,7 @@
File file;
try {
- file = new File(base.resolve(new URI(null, null, path, null)).normalize());
+ file = new File(base.resolve(new URI(null, null, path, null, null)).normalize());
} catch (URISyntaxException e) {
continue;
}
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/UrlLibrarySource.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698