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

Unified Diff: pkg/analysis_server/test/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 | « no previous file | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/mock_sdk.dart
diff --git a/pkg/analysis_server/test/mock_sdk.dart b/pkg/analysis_server/test/mock_sdk.dart
index 9027e6d05e6b5d9045cbc842e193b92e8208a6e0..ab40d919541f0d7e61ee8137c7f2b8518d615565 100644
--- a/pkg/analysis_server/test/mock_sdk.dart
+++ b/pkg/analysis_server/test/mock_sdk.dart
@@ -334,28 +334,26 @@ const Map<String, LibraryInfo> libraries = const {
@override
Source fromFileUri(Uri uri) {
- String filePath = uri.path;
- String libPath = '/lib';
- if (!filePath.startsWith("$libPath/")) {
- return null;
- }
- for (SdkLibrary library in LIBRARIES) {
- String libraryPath = library.path;
- if (filePath.replaceAll('\\', '/') == libraryPath) {
+ String filePath = provider.pathContext.fromUri(uri);
+ for (SdkLibrary library in sdkLibraries) {
+ String libraryPath = provider.convertPath(library.path);
+ if (filePath == libraryPath) {
try {
- resource.File file = provider.getResource(uri.path);
+ 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(uri.path);
- 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 | « no previous file | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698