| 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 test.src.mock_sdk; | 5 library test.src.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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 Uri uri = new Uri(scheme: 'dart', path: dartUri.substring(5)); | 314 Uri uri = new Uri(scheme: 'dart', path: dartUri.substring(5)); |
| 315 return file.createSource(uri); | 315 return file.createSource(uri); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // If we reach here then we tried to use a dartUri that's not in the | 318 // If we reach here then we tried to use a dartUri that's not in the |
| 319 // table above. | 319 // table above. |
| 320 return null; | 320 return null; |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 class _MockSdkFile { |
| 325 final String path; |
| 326 final String content; |
| 327 |
| 328 const _MockSdkFile(this.path, this.content); |
| 329 } |
| 330 |
| 324 class _MockSdkLibrary implements SdkLibrary { | 331 class _MockSdkLibrary implements SdkLibrary { |
| 325 final String shortName; | 332 final String shortName; |
| 326 final String path; | 333 final String path; |
| 327 final String content; | 334 final String content; |
| 328 final List<_MockSdkFile> parts; | 335 final List<_MockSdkFile> parts; |
| 329 | 336 |
| 330 const _MockSdkLibrary(this.shortName, this.path, this.content, | 337 const _MockSdkLibrary(this.shortName, this.path, this.content, |
| 331 [this.parts = const <_MockSdkFile>[]]); | 338 [this.parts = const <_MockSdkFile>[]]); |
| 332 | 339 |
| 333 @override | 340 @override |
| (...skipping 13 matching lines...) Expand all Loading... |
| 347 | 354 |
| 348 @override | 355 @override |
| 349 bool get isShared => throw unimplemented; | 356 bool get isShared => throw unimplemented; |
| 350 | 357 |
| 351 @override | 358 @override |
| 352 bool get isVmLibrary => throw unimplemented; | 359 bool get isVmLibrary => throw unimplemented; |
| 353 | 360 |
| 354 UnimplementedError get unimplemented => new UnimplementedError(); | 361 UnimplementedError get unimplemented => new UnimplementedError(); |
| 355 } | 362 } |
| 356 | 363 |
| 357 class _MockSdkFile { | |
| 358 final String path; | |
| 359 final String content; | |
| 360 | |
| 361 const _MockSdkFile(this.path, this.content); | |
| 362 } | |
| 363 | |
| 364 /** | 364 /** |
| 365 * An [AnalysisContextImpl] that only contains sources for a Dart SDK. | 365 * An [AnalysisContextImpl] that only contains sources for a Dart SDK. |
| 366 */ | 366 */ |
| 367 class _SdkAnalysisContext extends AnalysisContextImpl { | 367 class _SdkAnalysisContext extends AnalysisContextImpl { |
| 368 final DartSdk sdk; | 368 final DartSdk sdk; |
| 369 | 369 |
| 370 _SdkAnalysisContext(this.sdk); | 370 _SdkAnalysisContext(this.sdk); |
| 371 | 371 |
| 372 @override | 372 @override |
| 373 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 373 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 374 if (factory == null) { | 374 if (factory == null) { |
| 375 return super.createCacheFromSourceFactory(factory); | 375 return super.createCacheFromSourceFactory(factory); |
| 376 } | 376 } |
| 377 return new AnalysisCache(<CachePartition>[ | 377 return new AnalysisCache( |
| 378 AnalysisEngine.instance.partitionManager_new.forSdk(sdk) | 378 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 379 ]); | |
| 380 } | 379 } |
| 381 } | 380 } |
| OLD | NEW |