| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library testing.mock_sdk; | 5 library testing.mock_sdk; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart' as resource; | 7 import 'package:analyzer/file_system/file_system.dart' as resource; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart' as resource; | 8 import 'package:analyzer/file_system/memory_file_system.dart' as resource; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/sdk.dart'; | 10 import 'package:analyzer/src/generated/sdk.dart'; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 @override | 216 @override |
| 217 Source fromFileUri(Uri uri) { | 217 Source fromFileUri(Uri uri) { |
| 218 String filePath = uri.path; | 218 String filePath = uri.path; |
| 219 String libPath = '/lib'; | 219 String libPath = '/lib'; |
| 220 if (!filePath.startsWith("$libPath/")) { | 220 if (!filePath.startsWith("$libPath/")) { |
| 221 return null; | 221 return null; |
| 222 } | 222 } |
| 223 for (SdkLibrary library in LIBRARIES) { | 223 for (SdkLibrary library in LIBRARIES) { |
| 224 String libraryPath = library.path; | 224 String libraryPath = library.path; |
| 225 if (filePath.replaceAll('\\', '/') == libraryPath) { | 225 if (filePath.replaceAll('\\', '/') == libraryPath) { |
| 226 String path = library.shortName; | |
| 227 try { | 226 try { |
| 228 resource.File file = provider.getResource(uri.path); | 227 resource.File file = provider.getResource(uri.path); |
| 229 Uri dartUri = new Uri(scheme: 'dart', path: path); | 228 Uri dartUri = Uri.parse(library.shortName); |
| 230 return file.createSource(dartUri); | 229 return file.createSource(dartUri); |
| 231 } catch (exception) { | 230 } catch (exception) { |
| 232 return null; | 231 return null; |
| 233 } | 232 } |
| 234 } | 233 } |
| 235 if (filePath.startsWith("$libraryPath/")) { | 234 if (filePath.startsWith("$libraryPath/")) { |
| 236 String pathInLibrary = filePath.substring(libraryPath.length + 1); | 235 String pathInLibrary = filePath.substring(libraryPath.length + 1); |
| 237 String path = '${library.shortName}/${pathInLibrary}'; | 236 String path = '${library.shortName}/${pathInLibrary}'; |
| 238 try { | 237 try { |
| 239 resource.File file = provider.getResource(uri.path); | 238 resource.File file = provider.getResource(uri.path); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 bool get isInternal => throw unimplemented; | 301 bool get isInternal => throw unimplemented; |
| 303 | 302 |
| 304 @override | 303 @override |
| 305 bool get isShared => throw unimplemented; | 304 bool get isShared => throw unimplemented; |
| 306 | 305 |
| 307 @override | 306 @override |
| 308 bool get isVmLibrary => throw unimplemented; | 307 bool get isVmLibrary => throw unimplemented; |
| 309 | 308 |
| 310 UnimplementedError get unimplemented => new UnimplementedError(); | 309 UnimplementedError get unimplemented => new UnimplementedError(); |
| 311 } | 310 } |
| OLD | NEW |