2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.
6
-
7
5
import 'package:analyzer/dart/analysis/results.dart' ;
8
6
import 'package:analyzer/dart/analysis/session.dart' ;
9
7
import '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' ;
11
10
import 'package:analyzer/error/error.dart' ;
12
11
13
12
import 'asset_id.dart' ;
@@ -30,7 +29,7 @@ abstract class Resolver {
30
29
/// - Every public `dart:` library part of the SDK.
31
30
/// - All libraries recursively accessible from the mentioned sources, for
32
31
/// instance because due to imports or exports.
33
- Stream <LibraryElement2 > get libraries;
32
+ Stream <LibraryElement > get libraries;
34
33
35
34
/// Returns the parsed [AstNode] for [fragment] .
36
35
///
@@ -62,7 +61,7 @@ abstract class Resolver {
62
61
/// * Throws [NonLibraryAssetException] if [assetId] is not a Dart library.
63
62
/// * If the [assetId] has syntax errors, and [allowSyntaxErrors] is set to
64
63
/// `false` (the default), throws a [SyntaxErrorInAssetException] .
65
- Future <LibraryElement2 > libraryFor (
64
+ Future <LibraryElement > libraryFor (
66
65
AssetId assetId, {
67
66
bool allowSyntaxErrors = false ,
68
67
});
@@ -77,7 +76,7 @@ abstract class Resolver {
77
76
/// **NOTE**: In general, its recommended to use [libraryFor] with an absolute
78
77
/// asset id instead of a named identifier that has the possibility of not
79
78
/// being unique.
80
- Future <LibraryElement2 ?> findLibraryByName (String libraryName);
79
+ Future <LibraryElement ?> findLibraryByName (String libraryName);
81
80
82
81
/// Returns the [AssetId] of the Dart library or part declaring [element] .
83
82
///
@@ -87,7 +86,7 @@ abstract class Resolver {
87
86
///
88
87
/// The returned asset is not necessarily the asset that should be imported to
89
88
/// 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);
91
90
}
92
91
93
92
/// A resolver that should be manually released at the end of a build step.
@@ -139,7 +138,7 @@ class SyntaxErrorInAssetException implements Exception {
139
138
///
140
139
/// In addition to the asset itself, the resolver also considers syntax errors
141
140
/// in part files.
142
- final List <AnalysisResultWithErrors > filesWithErrors;
141
+ final List <AnalysisResultWithDiagnostics > filesWithErrors;
143
142
144
143
SyntaxErrorInAssetException (this .assetId, this .filesWithErrors)
145
144
: assert (filesWithErrors.isNotEmpty);
@@ -149,23 +148,23 @@ class SyntaxErrorInAssetException implements Exception {
149
148
/// This only contains syntax errors since most semantic errors are expected
150
149
/// during a build (e.g. due to missing part files that haven't been generated
151
150
/// yet).
152
- Iterable <AnalysisError > get syntaxErrors {
151
+ Iterable <Diagnostic > get syntaxErrors {
153
152
return filesWithErrors
154
- .expand ((result) => result.errors )
153
+ .expand ((result) => result.diagnostics )
155
154
.where (_isSyntaxError);
156
155
}
157
156
158
157
/// A map from [syntaxErrors] to per-file results
159
- Map <AnalysisError , AnalysisResultWithErrors > get errorToResult {
158
+ Map <Diagnostic , AnalysisResultWithDiagnostics > get errorToResult {
160
159
return {
161
160
for (final file in filesWithErrors)
162
- for (final error in file.errors )
161
+ for (final error in file.diagnostics )
163
162
if (_isSyntaxError (error)) error: file,
164
163
};
165
164
}
166
165
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 ;
169
168
}
170
169
171
170
@override
0 commit comments