Stop using deprecated ContextLocator and ContextBuilder. (#4326)
diff --git a/lib/src/dart.dart b/lib/src/dart.dart
index 56e69f5f..1ed734f 100644
--- a/lib/src/dart.dart
+++ b/lib/src/dart.dart
@@ -8,8 +8,7 @@
import 'dart:async';
import 'dart:io';
-import 'package:analyzer/dart/analysis/context_builder.dart';
-import 'package:analyzer/dart/analysis/context_locator.dart';
+import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/ast/ast.dart';
@@ -33,17 +32,9 @@
);
AnalysisContextManager._(this.packagePath)
- : _session = ContextBuilder()
- .createContext(
- contextRoot: ContextLocator().locateRoots(
- includedPaths: [p.absolute(p.normalize(packagePath))],
- optionsFile:
- // We don't want to take 'analysis_options.yaml' files into
- // account. So we replace it with an empty file.
- Platform.isWindows ? r'C:\NUL' : '/dev/null',
- ).first,
- )
- .currentSession;
+ : _session = AnalysisContextCollection(
+ includedPaths: [packagePath],
+ ).contextFor(packagePath).currentSession;
/// Parse the file with the given [path] into AST.
///
diff --git a/pubspec.yaml b/pubspec.yaml
index 9525507..4942604 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@
sdk: ^3.2.0
dependencies:
- analyzer: ^6.3.0
+ analyzer: ^6.8.0
args: ^2.5.0
async: ^2.11.0
cli_util: ^0.4.1