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

Unified Diff: pkg/analyzer/lib/src/generated/source_io.dart

Issue 1416863003: Fix PackageUriResolver.restoreAbsolute on Windows (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/source_io.dart
diff --git a/pkg/analyzer/lib/src/generated/source_io.dart b/pkg/analyzer/lib/src/generated/source_io.dart
index 4708aa0b97a905835f80482b8caae8182ceb9a38..0c5d9e8171d862a8444619681eea04e661322c3e 100644
--- a/pkg/analyzer/lib/src/generated/source_io.dart
+++ b/pkg/analyzer/lib/src/generated/source_io.dart
@@ -467,15 +467,15 @@ class PackageUriResolver extends UriResolver {
@override
Uri restoreAbsolute(Source source) {
- String sourcePath = source.fullName;
+ String sourceUri = _toFileUri(source.fullName);
for (JavaFile packagesDirectory in _packagesDirectories) {
List<JavaFile> pkgFolders = packagesDirectory.listFiles();
if (pkgFolders != null) {
for (JavaFile pkgFolder in pkgFolders) {
try {
- String pkgCanonicalPath = pkgFolder.getCanonicalPath();
- if (sourcePath.startsWith(pkgCanonicalPath)) {
- String relPath = sourcePath.substring(pkgCanonicalPath.length);
+ String pkgCanonicalUri = _toFileUri(pkgFolder.getCanonicalPath());
+ if (sourceUri.startsWith(pkgCanonicalUri)) {
+ String relPath = sourceUri.substring(pkgCanonicalUri.length);
return parseUriWithException(
"$PACKAGE_SCHEME:${pkgFolder.getName()}$relPath");
}
@@ -501,6 +501,13 @@ class PackageUriResolver extends UriResolver {
}
/**
+ * Convert the given file path to a "file:" URI. On Windows, this transforms
+ * backslashes to forward slashes.
+ */
+ String _toFileUri(String filePath) =>
+ JavaFile.pathContext.toUri(filePath).toString();
+
+ /**
* Return `true` if the given URI is a `package` URI.
*
* @param uri the URI being tested
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698