Skip to content

Commit 6368c5a

Browse files
authored
Bump analyzer version. (#4246)
1 parent 3fc9510 commit 6368c5a

File tree

9 files changed

+35
-39
lines changed

9 files changed

+35
-39
lines changed

build/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 4.0.2
2+
3+
- Require `analyzer` 8.0.0. Remove use of deprecated `analyzer` members, use
4+
their recommended and compatible replacements.
5+
16
## 4.0.1
27

38
- Improvements to dartdoc.

build/lib/src/build_step.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import 'dart:async';
66
import 'dart:convert';
77

8-
// ignore: deprecated_member_use until analyzer 7 support is dropped.
9-
import 'package:analyzer/dart/element/element2.dart';
8+
import 'package:analyzer/dart/element/element.dart';
109
import 'package:crypto/crypto.dart';
1110
import 'package:glob/glob.dart';
1211
import 'package:package_config/package_config_types.dart';
@@ -33,8 +32,7 @@ abstract class BuildStep implements AssetReader, AssetWriter {
3332
///
3433
/// To resolve allowing syntax errors, instead use
3534
/// `resolver.libraryFor(buildStep.inputId, allowSyntaxErrors: true)`.
36-
// ignore: deprecated_member_use until analyzer 7 support is dropped.
37-
Future<LibraryElement2> get inputLibrary;
35+
Future<LibraryElement> get inputLibrary;
3836

3937
/// A [Resolver] that can parse or resolve any Dart source code visible to
4038
/// this build step.

build/lib/src/resolver.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
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-
75
import 'package:analyzer/dart/analysis/results.dart';
86
import 'package:analyzer/dart/analysis/session.dart';
97
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';
1110
import 'package:analyzer/error/error.dart';
1211

1312
import '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

build/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build
2-
version: 4.0.1
2+
version: 4.0.2
33
description: A package for authoring build_runner compatible code generators.
44
repository: https://github.com/dart-lang/build/tree/master/build
55
resolution: workspace
@@ -8,7 +8,7 @@ environment:
88
sdk: ^3.7.0
99

1010
dependencies:
11-
analyzer: '>=7.4.0 <9.0.0'
11+
analyzer: ^8.0.0
1212
crypto: ^3.0.0
1313
glob: ^2.0.0
1414
logging: ^1.0.0

build_daemon/pubspec.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@ dependencies:
2323

2424
dev_dependencies:
2525
build_runner: ^2.0.0
26-
# TODO(davidmorgan): add back when released for build 3.0.0.
27-
# built_value_generator: ^8.1.0
26+
built_value_generator: ^8.1.0
2827
mockito: ^5.0.0
2928
test: ^1.25.5
3029
test_descriptor: ^2.0.0
3130

32-
# TODO(davidmorgan): remove when these are released for build 3.0.0.
33-
dependency_overrides:
34-
mockito: '5.4.6'
35-
source_gen: '2.0.0'
36-
3731
topics:
3832
- build-runner

build_runner/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## 2.9.1-wip
22

3+
- Require `analyzer` 8.0.0. Remove use of deprecated `analyzer` members, use
4+
their recommended and compatible replacements.
35
- Internal changes for `build_test`.
46
- Add the `--dart-jit-vm-arg` option. Its values are passed to `dart run` when
57
a build script is started in JIT mode. This allows specifying options to

build_runner/lib/src/build/build_step_impl.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
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-
75
import 'dart:async';
86
import 'dart:collection';
97
import 'dart:convert';
108

119
import 'package:analyzer/dart/ast/ast.dart';
12-
import 'package:analyzer/dart/element/element2.dart';
10+
import 'package:analyzer/dart/element/element.dart';
1311
import 'package:async/async.dart';
1412
import 'package:build/build.dart';
1513
import 'package:crypto/crypto.dart';
@@ -34,7 +32,7 @@ class BuildStepImpl implements BuildStep {
3432
final AssetId inputId;
3533

3634
@override
37-
Future<LibraryElement2> get inputLibrary async {
35+
Future<LibraryElement> get inputLibrary async {
3836
if (_isComplete) throw BuildStepCompletedException();
3937
return resolver.libraryFor(inputId);
4038
}
@@ -221,8 +219,8 @@ class _DelayedResolver implements Resolver {
221219
(await _delegate).isLibrary(assetId);
222220

223221
@override
224-
Stream<LibraryElement2> get libraries {
225-
final completer = StreamCompleter<LibraryElement2>();
222+
Stream<LibraryElement> get libraries {
223+
final completer = StreamCompleter<LibraryElement>();
226224
_delegate.then((r) => completer.setSourceStream(r.libraries));
227225
return completer.stream;
228226
}
@@ -243,7 +241,7 @@ class _DelayedResolver implements Resolver {
243241
);
244242

245243
@override
246-
Future<LibraryElement2> libraryFor(
244+
Future<LibraryElement> libraryFor(
247245
AssetId assetId, {
248246
bool allowSyntaxErrors = false,
249247
}) async => (await _delegate).libraryFor(
@@ -252,10 +250,10 @@ class _DelayedResolver implements Resolver {
252250
);
253251

254252
@override
255-
Future<LibraryElement2?> findLibraryByName(String libraryName) async =>
253+
Future<LibraryElement?> findLibraryByName(String libraryName) async =>
256254
(await _delegate).findLibraryByName(libraryName);
257255

258256
@override
259-
Future<AssetId> assetIdForElement(Element2 element) async =>
257+
Future<AssetId> assetIdForElement(Element element) async =>
260258
(await _delegate).assetIdForElement(element);
261259
}

build_runner/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ platforms:
1313
macos:
1414

1515
dependencies:
16-
analyzer: '>=7.4.0 <9.0.0'
16+
analyzer: ^8.0.0
1717
args: ^2.5.0
1818
async: ^2.5.0
1919
build: ^4.0.0

build_test/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ environment:
88
sdk: ^3.7.0
99

1010
dependencies:
11-
build: '4.0.1'
11+
build: ^4.0.0
1212
build_config: ^1.0.0
1313
build_runner: '2.9.1-wip'
1414
built_collection: ^5.1.1
@@ -25,7 +25,7 @@ dependencies:
2525
watcher: ^1.0.0
2626

2727
dev_dependencies:
28-
analyzer: '>=5.2.0 <9.0.0'
28+
analyzer: ^8.0.0
2929

3030
topics:
3131
- build-runner

0 commit comments

Comments
 (0)