| 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 analyzer.test.src.context.mock_sdk; | 5 library analyzer.test.src.context.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/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/context/context.dart'; | 10 import 'package:analyzer/src/context/context.dart'; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 "dart:collection": "/lib/collection/collection.dart", | 291 "dart:collection": "/lib/collection/collection.dart", |
| 292 "dart:convert": "/lib/convert/convert.dart", | 292 "dart:convert": "/lib/convert/convert.dart", |
| 293 "dart:_foreign_helper": "/lib/_foreign_helper/_foreign_helper.dart", | 293 "dart:_foreign_helper": "/lib/_foreign_helper/_foreign_helper.dart", |
| 294 "dart:math": "/lib/math/math.dart" | 294 "dart:math": "/lib/math/math.dart" |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 static const Map<String, String> NO_ASYNC_URI_MAP = const { | 297 static const Map<String, String> NO_ASYNC_URI_MAP = const { |
| 298 "dart:core": "/lib/core/core.dart", | 298 "dart:core": "/lib/core/core.dart", |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 final resource.MemoryResourceProvider provider = | 301 final resource.MemoryResourceProvider provider; |
| 302 new resource.MemoryResourceProvider(); | |
| 303 | 302 |
| 304 final Map<String, String> uriMap; | 303 final Map<String, String> uriMap; |
| 305 | 304 |
| 306 /** | 305 /** |
| 307 * The [AnalysisContextImpl] which is used for all of the sources. | 306 * The [AnalysisContextImpl] which is used for all of the sources. |
| 308 */ | 307 */ |
| 309 AnalysisContextImpl _analysisContext; | 308 AnalysisContextImpl _analysisContext; |
| 310 | 309 |
| 311 @override | 310 @override |
| 312 final List<SdkLibrary> sdkLibraries; | 311 final List<SdkLibrary> sdkLibraries; |
| 313 | 312 |
| 314 MockSdk({bool dartAsync: true}) | 313 MockSdk({bool dartAsync: true, resource.ResourceProvider resourceProvider}) |
| 315 : sdkLibraries = dartAsync ? _LIBRARIES : [_LIB_CORE], | 314 : provider = resourceProvider ?? new resource.MemoryResourceProvider(), |
| 315 sdkLibraries = dartAsync ? _LIBRARIES : [_LIB_CORE], |
| 316 uriMap = dartAsync ? FULL_URI_MAP : NO_ASYNC_URI_MAP { | 316 uriMap = dartAsync ? FULL_URI_MAP : NO_ASYNC_URI_MAP { |
| 317 for (_MockSdkLibrary library in sdkLibraries) { | 317 for (_MockSdkLibrary library in sdkLibraries) { |
| 318 provider.newFile(library.path, library.content); | 318 provider.newFile(library.path, library.content); |
| 319 library.parts.forEach((String path, String content) { | 319 library.parts.forEach((String path, String content) { |
| 320 provider.newFile(path, content); | 320 provider.newFile(path, content); |
| 321 }); | 321 }); |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 @override | 325 @override |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 436 |
| 437 @override | 437 @override |
| 438 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 438 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 439 if (factory == null) { | 439 if (factory == null) { |
| 440 return super.createCacheFromSourceFactory(factory); | 440 return super.createCacheFromSourceFactory(factory); |
| 441 } | 441 } |
| 442 return new AnalysisCache( | 442 return new AnalysisCache( |
| 443 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 443 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 444 } | 444 } |
| 445 } | 445 } |
| OLD | NEW |