mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:11:19 +00:00
Deprecate AnalysisDriver.configure(), accept 'contextRoot'.
This is rework of https://dart-review.googlesource.com/c/sdk/+/247626 Change-Id: Ic6cb6210eae26f5a7338532c80572e2654fad0a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247862 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
cc9b825974
commit
5004883476
|
@ -106,6 +106,9 @@ class ContextBuilderImpl implements ContextBuilder {
|
|||
updateAnalysisOptions(options);
|
||||
}
|
||||
|
||||
final analysisContext =
|
||||
DriverBasedAnalysisContext(resourceProvider, contextRoot);
|
||||
|
||||
var driver = AnalysisDriver(
|
||||
scheduler: scheduler,
|
||||
logger: performanceLog,
|
||||
|
@ -116,19 +119,16 @@ class ContextBuilderImpl implements ContextBuilder {
|
|||
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 @@ class ContextBuilderImpl implements ContextBuilder {
|
|||
driver.exceptions.drain<void>();
|
||||
}
|
||||
|
||||
DriverBasedAnalysisContext context =
|
||||
DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
|
||||
driver.configure(analysisContext: context);
|
||||
|
||||
return context;
|
||||
return analysisContext;
|
||||
}
|
||||
|
||||
/// Return [Packages] to analyze the [contextRoot].
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'dart:typed_data';
|
|||
|
||||
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/exception/exception.dart';
|
|||
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 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
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 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
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 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
_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 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
///
|
||||
/// 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,
|
||||
|
|
|
@ -19,18 +19,17 @@ class DriverBasedAnalysisContext implements AnalysisContext {
|
|||
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;
|
||||
|
|
|
@ -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 @@ class DriverBasedUriConverterTest with ResourceProviderMixin {
|
|||
driver.resourceProvider = resourceProvider;
|
||||
driver.sourceFactory = sourceFactory;
|
||||
driver.analysisContext =
|
||||
DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
|
||||
DriverBasedAnalysisContext(resourceProvider, contextRoot);
|
||||
|
||||
uriConverter = DriverBasedUriConverter(driver);
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ class MockAnalysisDriver implements AnalysisDriver {
|
|||
late final SourceFactory sourceFactory;
|
||||
|
||||
@override
|
||||
AnalysisContext? analysisContext;
|
||||
DriverBasedAnalysisContext? analysisContext;
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) {
|
||||
|
|
Loading…
Reference in a new issue