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

Unified Diff: pkg/analyzer/test/src/context/mock_sdk.dart

Issue 2653753006: Fix MockSdk.fromFileUri() implementations. (Closed)
Patch Set: Created 3 years, 11 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 | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698