Version 2.18.0-176.0.dev
Merge commit '5004883476aacdd82a06eb5cefb464b7df1e34de' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index c1185f2..220750e 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -106,6 +106,9 @@
updateAnalysisOptions(options);
}
+ final analysisContext =
+ DriverBasedAnalysisContext(resourceProvider, contextRoot);
+
var driver = AnalysisDriver(
scheduler: scheduler,
logger: performanceLog,
@@ -116,19 +119,16 @@
packages: _createPackageMap(
contextRoot: contextRoot,
),
+ analysisContext: analysisContext,
enableIndex: enableIndex,
externalSummaries: summaryData,
retainDataForTesting: retainDataForTesting,
fileContentCache: fileContentCache,
macroKernelBuilder: macroKernelBuilder,
macroExecutor: macroExecutor,
+ declaredVariables: declaredVariables,
);
- if (declaredVariables != null) {
- driver.declaredVariables = declaredVariables;
- driver.configure();
- }
-
// AnalysisDriver reports results into streams.
// We need to drain these streams to avoid memory leak.
if (drainStreams) {
@@ -136,11 +136,7 @@
driver.exceptions.drain<void>();
}
- DriverBasedAnalysisContext context =
- DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
- driver.configure(analysisContext: context);
-
- return context;
+ return analysisContext;
}
/// Return [Packages] to analyze the [contextRoot].
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 3b355eb..25983e2 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -7,7 +7,6 @@
import 'package:_fe_analyzer_shared/src/macros/executor/multi_executor.dart'
as macro;
-import 'package:analyzer/dart/analysis/analysis_context.dart' as api;
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
@@ -17,6 +16,7 @@
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/context/packages.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
+import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/feature_set_provider.dart';
import 'package:analyzer/src/dart/analysis/file_content_cache.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
@@ -132,10 +132,10 @@
final macro.MultiMacroExecutor? macroExecutor;
/// The declared environment variables.
- DeclaredVariables declaredVariables = DeclaredVariables();
+ final DeclaredVariables declaredVariables;
/// The analysis context that created this driver / session.
- api.AnalysisContext? analysisContext;
+ DriverBasedAnalysisContext? analysisContext;
/// The salt to mix into all hashes used as keys for unlinked data.
Uint32List _saltForUnlinked = Uint32List(0);
@@ -256,9 +256,11 @@
required Packages packages,
this.macroKernelBuilder,
this.macroExecutor,
+ this.analysisContext,
FileContentCache? fileContentCache,
this.enableIndex = false,
SummaryDataStore? externalSummaries,
+ DeclaredVariables? declaredVariables,
bool retainDataForTesting = false,
}) : _scheduler = scheduler,
_resourceProvider = resourceProvider,
@@ -270,7 +272,9 @@
_packages = packages,
_sourceFactory = sourceFactory,
_externalSummaries = externalSummaries,
+ declaredVariables = declaredVariables ?? DeclaredVariables(),
testingData = retainDataForTesting ? TestingData() : null {
+ analysisContext?.driver = this;
_onResults = _resultController.stream.asBroadcastStream();
_testView = AnalysisDriverTestView(this);
_createFileTracker();
@@ -569,8 +573,9 @@
///
/// At least one of the optional parameters should be provided, but only those
/// that represent state that has actually changed need be provided.
+ @Deprecated('Provide all necessary values to the constructor')
void configure({
- api.AnalysisContext? analysisContext,
+ DriverBasedAnalysisContext? analysisContext,
AnalysisOptionsImpl? analysisOptions,
Packages? packages,
SourceFactory? sourceFactory,
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart b/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart
index b54b4c4..5eeaae4 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart
@@ -19,18 +19,17 @@
final ContextRoot contextRoot;
/// The driver on which this context is based.
- final AnalysisDriver driver;
+ late final AnalysisDriver driver;
/// Initialize a newly created context that uses the given [resourceProvider]
/// to access the file system and that is based on the given analysis
/// [driver].
DriverBasedAnalysisContext(
this.resourceProvider,
- this.contextRoot,
- this.driver,
- ) {
- driver.analysisContext = this;
- }
+ this.contextRoot, [
+ @Deprecated('AnalysisDriver will set itself, remove this')
+ AnalysisDriver? analysisDriver,
+ ]);
@override
AnalysisOptions get analysisOptions => driver.analysisOptions;
diff --git a/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart b/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart
index 563cba7..be3bdb2 100644
--- a/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/analysis/analysis_context.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/context/packages.dart';
import 'package:analyzer/src/dart/analysis/context_root.dart';
@@ -56,7 +55,7 @@
driver.resourceProvider = resourceProvider;
driver.sourceFactory = sourceFactory;
driver.analysisContext =
- DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
+ DriverBasedAnalysisContext(resourceProvider, contextRoot);
uriConverter = DriverBasedUriConverter(driver);
}
@@ -104,7 +103,7 @@
late final SourceFactory sourceFactory;
@override
- AnalysisContext? analysisContext;
+ DriverBasedAnalysisContext? analysisContext;
@override
dynamic noSuchMethod(Invocation invocation) {
diff --git a/tools/VERSION b/tools/VERSION
index 83da292..7e37bbe 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 175
+PRERELEASE 176
PRERELEASE_PATCH 0
\ No newline at end of file