| Index: pkg/analyzer/test/generated/analysis_context_factory.dart
|
| diff --git a/pkg/analyzer/test/generated/analysis_context_factory.dart b/pkg/analyzer/test/generated/analysis_context_factory.dart
|
| index f3117569db1c364d6525371c6009b9e87fe201bf..f5cb1954e5d4658b1971c3004e8aba87105c705c 100644
|
| --- a/pkg/analyzer/test/generated/analysis_context_factory.dart
|
| +++ b/pkg/analyzer/test/generated/analysis_context_factory.dart
|
| @@ -10,15 +10,16 @@ import 'package:analyzer/dart/ast/ast.dart';
|
| import 'package:analyzer/dart/ast/token.dart';
|
| import 'package:analyzer/dart/element/element.dart';
|
| import 'package:analyzer/dart/element/type.dart';
|
| +import 'package:analyzer/file_system/file_system.dart';
|
| +import 'package:analyzer/file_system/physical_file_system.dart';
|
| import 'package:analyzer/src/context/context.dart';
|
| import 'package:analyzer/src/dart/element/element.dart';
|
| import 'package:analyzer/src/dart/element/type.dart';
|
| +import 'package:analyzer/src/dart/sdk/sdk.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/java_engine_io.dart';
|
| -import 'package:analyzer/src/generated/java_io.dart';
|
| import 'package:analyzer/src/generated/resolver.dart';
|
| import 'package:analyzer/src/generated/sdk.dart';
|
| -import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
|
| import 'package:analyzer/src/generated/source_io.dart';
|
| import 'package:analyzer/src/generated/testing/ast_factory.dart';
|
| import 'package:analyzer/src/generated/testing/element_factory.dart';
|
| @@ -39,46 +40,60 @@ class AnalysisContextFactory {
|
| static String _DART_JS_HELPER = "dart:_js_helper";
|
|
|
| /**
|
| - * Create an analysis context that has a fake core library already resolved.
|
| - * Return the context that was created.
|
| + * Create and return an analysis context that has a fake core library already
|
| + * resolved. The given [resourceProvider] will be used when accessing the file
|
| + * system.
|
| */
|
| - static InternalAnalysisContext contextWithCore() {
|
| + static InternalAnalysisContext contextWithCore(
|
| + {ResourceProvider resourceProvider}) {
|
| AnalysisContextForTests context = new AnalysisContextForTests();
|
| - return initContextWithCore(context);
|
| + return initContextWithCore(context, null, resourceProvider);
|
| }
|
|
|
| /**
|
| - * Create an analysis context that uses the given [options] and has a fake
|
| - * core library already resolved. Return the context that was created.
|
| + * Create and return an analysis context that uses the given [options] and has
|
| + * a fake core library already resolved. The given [resourceProvider] will be
|
| + * used when accessing the file system.
|
| */
|
| static InternalAnalysisContext contextWithCoreAndOptions(
|
| - AnalysisOptions options) {
|
| + AnalysisOptions options,
|
| + {ResourceProvider resourceProvider}) {
|
| AnalysisContextForTests context = new AnalysisContextForTests();
|
| context._internalSetAnalysisOptions(options);
|
| - return initContextWithCore(context);
|
| + return initContextWithCore(context, null, resourceProvider);
|
| }
|
|
|
| + /**
|
| + * Create and return an analysis context that has a fake core library already
|
| + * resolved. If not `null`, the given [packages] map will be used to create a
|
| + * package URI resolver. The given [resourceProvider] will be used when
|
| + * accessing the file system.
|
| + */
|
| static InternalAnalysisContext contextWithCoreAndPackages(
|
| - Map<String, String> packages) {
|
| + Map<String, String> packages,
|
| + {ResourceProvider resourceProvider}) {
|
| AnalysisContextForTests context = new AnalysisContextForTests();
|
| - return initContextWithCore(context, new TestPackageUriResolver(packages));
|
| + return initContextWithCore(
|
| + context, new TestPackageUriResolver(packages), resourceProvider);
|
| }
|
|
|
| /**
|
| - * Initialize the given analysis context with a fake core library already resolved.
|
| - *
|
| - * @param context the context to be initialized (not `null`)
|
| - * @return the analysis context that was created
|
| + * Initialize the given analysis [context] with a fake core library that has
|
| + * already been resolved. If not `null`, the given [contributedResolver] will
|
| + * be added to the context's source factory. The given [resourceProvider] will
|
| + * be used when accessing the file system.
|
| */
|
| static InternalAnalysisContext initContextWithCore(
|
| InternalAnalysisContext context,
|
| - [UriResolver contributedResolver]) {
|
| - DirectoryBasedDartSdk sdk = new _AnalysisContextFactory_initContextWithCore(
|
| - new JavaFile("/fake/sdk"),
|
| + [UriResolver contributedResolver,
|
| + ResourceProvider resourceProvider]) {
|
| + resourceProvider ??= PhysicalResourceProvider.INSTANCE;
|
| + DartSdk sdk = new _AnalysisContextFactory_initContextWithCore(
|
| + resourceProvider, '/fake/sdk',
|
| enableAsync: context.analysisOptions.enableAsync);
|
| List<UriResolver> resolvers = <UriResolver>[
|
| new DartUriResolver(sdk),
|
| - new FileUriResolver()
|
| + new ResourceUriResolver(resourceProvider)
|
| ];
|
| if (contributedResolver != null) {
|
| resolvers.add(contributedResolver);
|
| @@ -540,12 +555,12 @@ class TestPackageUriResolver extends UriResolver {
|
| Uri restoreAbsolute(Source source) => throw new UnimplementedError();
|
| }
|
|
|
| -class _AnalysisContextFactory_initContextWithCore
|
| - extends DirectoryBasedDartSdk {
|
| +class _AnalysisContextFactory_initContextWithCore extends FolderBasedDartSdk {
|
| final bool enableAsync;
|
| - _AnalysisContextFactory_initContextWithCore(JavaFile arg0,
|
| + _AnalysisContextFactory_initContextWithCore(
|
| + ResourceProvider resourceProvider, String sdkPath,
|
| {this.enableAsync: true})
|
| - : super(arg0);
|
| + : super(resourceProvider, resourceProvider.getFolder(sdkPath));
|
|
|
| @override
|
| LibraryMap initialLibraryMap(bool useDart2jsPaths) {
|
|
|