blob: 5eeaae4a63cfb4dd4078c68c09daea44c91359eb [file] [log] [blame]
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// 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/dart/analysis/context_root.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/driver.dart' show AnalysisDriver;
import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisOptions;
/// An analysis context whose implementation is based on an analysis driver.
class DriverBasedAnalysisContext implements AnalysisContext {
/// The resource provider used to access the file system.
final ResourceProvider resourceProvider;
final ContextRoot contextRoot;
/// The driver on which this context is based.
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].
this.contextRoot, [
@Deprecated('AnalysisDriver will set itself, remove this')
AnalysisDriver? analysisDriver,
AnalysisOptions get analysisOptions => driver.analysisOptions;
AnalysisSession get currentSession => driver.currentSession;
Folder? get sdkRoot {
var sdk = driver.sourceFactory.dartSdk;
if (sdk is FolderBasedDartSdk) {
return null;
Future<List<String>> applyPendingFileChanges() {
return driver.applyPendingFileChanges();
void changeFile(String path) {