22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.
6-
75import 'package:analyzer/dart/analysis/results.dart' ;
86import 'package:analyzer/dart/analysis/session.dart' ;
97import 'package:analyzer/dart/ast/ast.dart' ;
10- import 'package:analyzer/dart/element/element2.dart' ;
8+ import 'package:analyzer/dart/element/element.dart' ;
9+ import 'package:analyzer/diagnostic/diagnostic.dart' ;
1110import 'package:analyzer/error/error.dart' ;
1211
1312import 'asset_id.dart' ;
@@ -30,7 +29,7 @@ abstract class Resolver {
3029 /// - Every public `dart:` library part of the SDK.
3130 /// - All libraries recursively accessible from the mentioned sources, for
3231 /// instance because due to imports or exports.
33- Stream <LibraryElement2 > get libraries;
32+ Stream <LibraryElement > get libraries;
3433
3534 /// Returns the parsed [AstNode] for [fragment] .
3635 ///
@@ -62,7 +61,7 @@ abstract class Resolver {
6261 /// * Throws [NonLibraryAssetException] if [assetId] is not a Dart library.
6362 /// * If the [assetId] has syntax errors, and [allowSyntaxErrors] is set to
6463 /// `false` (the default), throws a [SyntaxErrorInAssetException] .
65- Future <LibraryElement2 > libraryFor (
64+ Future <LibraryElement > libraryFor (
6665 AssetId assetId, {
6766 bool allowSyntaxErrors = false ,
6867 });
@@ -77,7 +76,7 @@ abstract class Resolver {
7776 /// **NOTE**: In general, its recommended to use [libraryFor] with an absolute
7877 /// asset id instead of a named identifier that has the possibility of not
7978 /// being unique.
80- Future <LibraryElement2 ?> findLibraryByName (String libraryName);
79+ Future <LibraryElement ?> findLibraryByName (String libraryName);
8180
8281 /// Returns the [AssetId] of the Dart library or part declaring [element] .
8382 ///
@@ -87,7 +86,7 @@ abstract class Resolver {
8786 ///
8887 /// The returned asset is not necessarily the asset that should be imported to
8988 /// use the element, it may be a part file instead of the library.
90- Future <AssetId > assetIdForElement (Element2 element);
89+ Future <AssetId > assetIdForElement (Element element);
9190}
9291
9392/// A resolver that should be manually released at the end of a build step.
@@ -139,7 +138,7 @@ class SyntaxErrorInAssetException implements Exception {
139138 ///
140139 /// In addition to the asset itself, the resolver also considers syntax errors
141140 /// in part files.
142- final List <AnalysisResultWithErrors > filesWithErrors;
141+ final List <AnalysisResultWithDiagnostics > filesWithErrors;
143142
144143 SyntaxErrorInAssetException (this .assetId, this .filesWithErrors)
145144 : assert (filesWithErrors.isNotEmpty);
@@ -149,23 +148,23 @@ class SyntaxErrorInAssetException implements Exception {
149148 /// This only contains syntax errors since most semantic errors are expected
150149 /// during a build (e.g. due to missing part files that haven't been generated
151150 /// yet).
152- Iterable <AnalysisError > get syntaxErrors {
151+ Iterable <Diagnostic > get syntaxErrors {
153152 return filesWithErrors
154- .expand ((result) => result.errors )
153+ .expand ((result) => result.diagnostics )
155154 .where (_isSyntaxError);
156155 }
157156
158157 /// A map from [syntaxErrors] to per-file results
159- Map <AnalysisError , AnalysisResultWithErrors > get errorToResult {
158+ Map <Diagnostic , AnalysisResultWithDiagnostics > get errorToResult {
160159 return {
161160 for (final file in filesWithErrors)
162- for (final error in file.errors )
161+ for (final error in file.diagnostics )
163162 if (_isSyntaxError (error)) error: file,
164163 };
165164 }
166165
167- bool _isSyntaxError (AnalysisError error ) {
168- return error.errorCode .type == ErrorType .SYNTACTIC_ERROR ;
166+ bool _isSyntaxError (Diagnostic diagnostic ) {
167+ return diagnostic.diagnosticCode .type == DiagnosticType .SYNTACTIC_ERROR ;
169168 }
170169
171170 @override
0 commit comments