Index: pkg/analyzer/test/src/context/mock_sdk.dart |
diff --git a/pkg/analyzer/test/src/context/mock_sdk.dart b/pkg/analyzer/test/src/context/mock_sdk.dart |
index 4b15a90e710031b7eecdd7d38b9ae4d7b952db87..ea2cdc27f9e3d3b7b5f823160f3a2b86726f7e68 100644 |
--- a/pkg/analyzer/test/src/context/mock_sdk.dart |
+++ b/pkg/analyzer/test/src/context/mock_sdk.dart |
@@ -485,30 +485,29 @@ class MockSdk implements DartSdk { |
@override |
Source fromFileUri(Uri uri) { |
- String filePath = uri.path; |
- String libPath = '$sdkRoot/lib'; |
- if (!filePath.startsWith("$libPath/")) { |
+ String filePath = provider.pathContext.fromUri(uri); |
+ if (!filePath.startsWith(provider.convertPath('$sdkRoot/lib/'))) { |
return null; |
} |
for (SdkLibrary library in sdkLibraries) { |
- String libraryPath = library.path; |
- if (filePath.replaceAll('\\', '/') == libraryPath) { |
+ String libraryPath = provider.convertPath(library.path); |
+ if (filePath == libraryPath) { |
try { |
- resource.File file = |
- provider.getResource(provider.convertPath(filePath)); |
+ resource.File file = provider.getResource(filePath); |
Uri dartUri = Uri.parse(library.shortName); |
return file.createSource(dartUri); |
} catch (exception) { |
return null; |
} |
} |
- if (filePath.startsWith("$libraryPath/")) { |
- String pathInLibrary = filePath.substring(libraryPath.length + 1); |
- String path = '${library.shortName}/$pathInLibrary'; |
+ String libraryRootPath = provider.pathContext.dirname(libraryPath) + |
+ provider.pathContext.separator; |
+ if (filePath.startsWith(libraryRootPath)) { |
+ String pathInLibrary = filePath.substring(libraryRootPath.length); |
+ String uriStr = '${library.shortName}/$pathInLibrary'; |
try { |
- resource.File file = |
- provider.getResource(provider.convertPath(filePath)); |
- Uri dartUri = new Uri(scheme: 'dart', path: path); |
+ resource.File file = provider.getResource(filePath); |
+ Uri dartUri = Uri.parse(uriStr); |
return file.createSource(dartUri); |
} catch (exception) { |
return null; |