Remove DartSdk.analysisContext
Change-Id: I6a67344d928e6182a851741bbbc862284af710c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162623
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index dcbc8f0..540843b 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -500,16 +500,6 @@
buf.writeln('</div>');
- buf.writeln('<div class="column one-half">');
- var sdk = driver?.sourceFactory?.dartSdk;
- AnalysisOptionsImpl sdkOptions = sdk?.context?.analysisOptions;
- if (sdkOptions != null) {
- h3('SDK analysis options');
- p(describe(sdkOptions), raw: true);
- }
-
- buf.writeln('</div>');
-
buf.writeln('</div>');
h3('Lints');
diff --git a/pkg/analyzer/lib/dart/sdk/build_sdk_summary.dart b/pkg/analyzer/lib/dart/sdk/build_sdk_summary.dart
index 50a3925..8705915 100644
--- a/pkg/analyzer/lib/dart/sdk/build_sdk_summary.dart
+++ b/pkg/analyzer/lib/dart/sdk/build_sdk_summary.dart
@@ -5,11 +5,13 @@
import 'dart:typed_data';
import 'package:_fe_analyzer_shared/src/sdk/allowed_experiments.dart';
+import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
@@ -61,8 +63,13 @@
return sdk.mapDartUri(e.shortName);
}).toList();
+ var analysisContext = AnalysisContextImpl(
+ SynchronousSession(AnalysisOptionsImpl(), DeclaredVariables()),
+ SourceFactory([DartUriResolver(sdk)]),
+ );
+
return _Builder(
- sdk.context,
+ analysisContext,
sdk.allowedExperimentsJson,
sdk.languageVersion,
librarySources,
@@ -70,7 +77,7 @@
}
class _Builder {
- final AnalysisContext context;
+ final AnalysisContextImpl context;
final String allowedExperimentsJson;
final Iterable<Source> librarySources;
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index 78b0a00..28cdb0c 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -70,12 +70,3 @@
);
}
}
-
-/// An [AnalysisContext] that only contains sources for a Dart SDK.
-class SdkAnalysisContext extends AnalysisContextImpl {
- /// Initialize a newly created SDK analysis context with the given [options].
- /// Analysis options cannot be changed afterwards. If the given [options] are
- /// `null`, then default options are used.
- SdkAnalysisContext(AnalysisOptions options, SourceFactory sourceFactory)
- : super(SynchronousSession(options, DeclaredVariables()), sourceFactory);
-}
diff --git a/pkg/analyzer/lib/src/dart/sdk/sdk.dart b/pkg/analyzer/lib/src/dart/sdk/sdk.dart
index 2ef05f9..5c3e5c9 100644
--- a/pkg/analyzer/lib/src/dart/sdk/sdk.dart
+++ b/pkg/analyzer/lib/src/dart/sdk/sdk.dart
@@ -10,7 +10,6 @@
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
-import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_engine_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
@@ -35,23 +34,10 @@
/// A mapping from Dart library URI's to the library represented by that URI.
LibraryMap libraryMap = LibraryMap();
- /// The [AnalysisContext] which is used for all of the sources in this SDK.
- SdkAnalysisContext _analysisContext;
-
/// The mapping from Dart URI's to the corresponding sources.
final Map<String, Source> _uriToSourceMap = HashMap<String, Source>();
@override
- AnalysisContext get context {
- if (_analysisContext == null) {
- var factory = SourceFactory([DartUriResolver(this)]);
- var analysisOptions = AnalysisOptionsImpl();
- _analysisContext = SdkAnalysisContext(analysisOptions, factory);
- }
- return _analysisContext;
- }
-
- @override
List<SdkLibrary> get sdkLibraries => libraryMap.sdkLibraries;
/// Return the path separator used by the resource provider.
diff --git a/pkg/analyzer/lib/src/generated/sdk.dart b/pkg/analyzer/lib/src/generated/sdk.dart
index 1f141f7..2ac5298 100644
--- a/pkg/analyzer/lib/src/generated/sdk.dart
+++ b/pkg/analyzer/lib/src/generated/sdk.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
import 'package:analyzer/src/generated/source.dart' show Source;
import 'package:pub_semver/pub_semver.dart';
@@ -32,9 +31,6 @@
/// if the file cannot be read, e.g. does not exist.
String get allowedExperimentsJson;
- /// Return the analysis context used for all of the sources in this [DartSdk].
- AnalysisContext get context;
-
/// Return the language version of this SDK, or throws an exception.
///
/// The language version has only major/minor components, the patch number
diff --git a/pkg/analyzer/lib/src/summary/summary_sdk.dart b/pkg/analyzer/lib/src/summary/summary_sdk.dart
index 80cd239..809db0f 100644
--- a/pkg/analyzer/lib/src/summary/summary_sdk.dart
+++ b/pkg/analyzer/lib/src/summary/summary_sdk.dart
@@ -3,11 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
-import 'package:analyzer/src/context/context.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source.dart'
- show DartUriResolver, Source, SourceFactory;
+import 'package:analyzer/src/generated/source.dart' show Source;
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:pub_semver/pub_semver.dart';
@@ -22,9 +19,6 @@
PackageBundle _bundle;
ResourceProvider resourceProvider;
- /// The [AnalysisContext] which is used for all of the sources in this sdk.
- SdkAnalysisContext _analysisContext;
-
SummaryBasedDartSdk(String summaryPath, bool _, {this.resourceProvider}) {
_dataStore = SummaryDataStore(<String>[summaryPath],
resourceProvider: resourceProvider);
@@ -49,16 +43,6 @@
PackageBundle get bundle => _bundle;
@override
- AnalysisContext get context {
- if (_analysisContext == null) {
- var analysisOptions = AnalysisOptionsImpl();
- var factory = SourceFactory([DartUriResolver(this)]);
- _analysisContext = SdkAnalysisContext(analysisOptions, factory);
- }
- return _analysisContext;
- }
-
- @override
Version get languageVersion {
var version = _bundle.sdk.languageVersion;
return Version(version.major, version.minor, 0);
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
index a4ebb6e..0d6aca6 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
@@ -4,9 +4,7 @@
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
-import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:meta/meta.dart';
@@ -1081,11 +1079,6 @@
final Map<String, String> uriMap = {};
- final AnalysisOptionsImpl _analysisOptions;
-
- /// The [AnalysisContextImpl] which is used for all of the sources.
- AnalysisContextImpl _analysisContext;
-
@override
final List<SdkLibrary> sdkLibraries = [];
@@ -1095,9 +1088,8 @@
/// their units are relative (will be put into `sdkRoot/lib`).
MockSdk({
@required this.resourceProvider,
- AnalysisOptionsImpl analysisOptions,
List<MockSdkLibrary> additionalLibraries = const [],
- }) : _analysisOptions = analysisOptions ?? AnalysisOptionsImpl() {
+ }) {
_versionFile = resourceProvider
.getFolder(resourceProvider.convertPath(sdkRoot))
.getChildAssumingFile('version');
@@ -1190,15 +1182,6 @@
}
@override
- AnalysisContextImpl get context {
- if (_analysisContext == null) {
- var factory = SourceFactory([DartUriResolver(this)]);
- _analysisContext = SdkAnalysisContext(_analysisOptions, factory);
- }
- return _analysisContext;
- }
-
- @override
Version get languageVersion {
var sdkVersionStr = _versionFile.readAsStringSync();
return languageVersionFromSdkVersion(sdkVersionStr);