Skip to content

Commit f3c94b8

Browse files
committed
Element2 migration.
1 parent 85646c8 commit f3c94b8

File tree

27 files changed

+194
-190
lines changed

27 files changed

+194
-190
lines changed

build/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 3.0.0
2+
3+
- Breaking: use the new `element2` APIs in `analyzer`. Builders that do
4+
resolution need to switch to the new API, see
5+
https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/element_model_migration_guide.md.
6+
For questions please use https://github.com/dart-lang/build/discussions.
7+
18
## 2.5.3
29

310
- Use `build_runner_core` 9.1.1.

build/lib/src/analyzer/resolver.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4-
// ignore_for_file: deprecated_member_use
54

65
import 'package:analyzer/dart/analysis/results.dart';
76
import 'package:analyzer/dart/analysis/session.dart';
87
import 'package:analyzer/dart/ast/ast.dart';
9-
import 'package:analyzer/dart/element/element.dart';
8+
import 'package:analyzer/dart/element/element2.dart';
109
import 'package:analyzer/error/error.dart';
1110

1211
import '../asset/id.dart';
@@ -29,9 +28,9 @@ abstract class Resolver {
2928
/// - Every public `dart:` library part of the SDK.
3029
/// - All libraries recursively accessible from the mentioned sources, for
3130
/// instance because due to imports or exports.
32-
Stream<LibraryElement> get libraries;
31+
Stream<LibraryElement2> get libraries;
3332

34-
/// Returns the parsed [AstNode] for [Element].
33+
/// Returns the parsed [AstNode] for [fragment].
3534
///
3635
/// This should always be preferred over using the [AnalysisSession]
3736
/// directly, because it avoids [InconsistentAnalysisException] issues.
@@ -42,7 +41,7 @@ abstract class Resolver {
4241
/// Returns `null` if the ast node can not be found. This can happen if an
4342
/// element is coming from a summary, or is unavailable for some other
4443
/// reason.
45-
Future<AstNode?> astNodeFor(Element element, {bool resolve = false});
44+
Future<AstNode?> astNodeFor(Fragment fragment, {bool resolve = false});
4645

4746
/// Returns a parsed AST structor representing the file defined in [assetId].
4847
///
@@ -61,7 +60,7 @@ abstract class Resolver {
6160
/// * Throws [NonLibraryAssetException] if [assetId] is not a Dart library.
6261
/// * If the [assetId] has syntax errors, and [allowSyntaxErrors] is set to
6362
/// `false` (the default), throws a [SyntaxErrorInAssetException].
64-
Future<LibraryElement> libraryFor(
63+
Future<LibraryElement2> libraryFor(
6564
AssetId assetId, {
6665
bool allowSyntaxErrors = false,
6766
});
@@ -76,7 +75,7 @@ abstract class Resolver {
7675
/// **NOTE**: In general, its recommended to use [libraryFor] with an absolute
7776
/// asset id instead of a named identifier that has the possibility of not
7877
/// being unique.
79-
Future<LibraryElement?> findLibraryByName(String libraryName);
78+
Future<LibraryElement2?> findLibraryByName(String libraryName);
8079

8180
/// Returns the [AssetId] of the Dart library or part declaring [element].
8281
///
@@ -86,7 +85,7 @@ abstract class Resolver {
8685
///
8786
/// The returned asset is not necessarily the asset that should be imported to
8887
/// use the element, it may be a part file instead of the library.
89-
Future<AssetId> assetIdForElement(Element element);
88+
Future<AssetId> assetIdForElement(Element2 element);
9089
}
9190

9291
/// A resolver that should be manually released at the end of a build step.

build/lib/src/builder/build_step.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4-
// ignore_for_file: deprecated_member_use
54

65
import 'dart:async';
76
import 'dart:convert';
87

9-
import 'package:analyzer/dart/element/element.dart';
8+
import 'package:analyzer/dart/element/element2.dart';
109
import 'package:package_config/package_config_types.dart';
1110

1211
import '../analyzer/resolver.dart';
@@ -37,7 +36,7 @@ abstract class BuildStep implements AssetReader, AssetWriter {
3736
/// await step.resolver.libraryFor(step.inputId, allowSyntaxErrors: true);
3837
/// }
3938
/// ```
40-
Future<LibraryElement> get inputLibrary;
39+
Future<LibraryElement2> get inputLibrary;
4140

4241
/// Gets an instance provided by [resource] which is guaranteed to be unique
4342
/// within a single build, and may be reused across build steps within a

build/pubspec.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build
2-
version: 2.5.3
2+
version: 3.0.0
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: '>=6.9.0 <8.0.0'
11+
analyzer: '>=7.4.0 <8.0.0'
1212
async: ^2.5.0
1313
build_runner_core: '9.1.1'
1414
built_collection: ^5.1.1
@@ -24,9 +24,8 @@ dependencies:
2424
pool: ^1.5.0
2525

2626
dev_dependencies:
27-
build_resolvers: '2.5.3'
27+
build_resolvers: '3.0.0'
2828
build_test: ^3.1.0
29-
built_value_generator: ^8.9.5
3029
dart_flutter_team_lints: ^3.1.0
3130
test: ^1.16.0
3231

build_config/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ dependencies:
1717

1818
dev_dependencies:
1919
build_runner: ^2.0.0
20-
json_serializable: ^6.0.0
2120
term_glyph: ^1.2.0
2221
test: ^1.16.0
2322

build_daemon/pubspec.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ dependencies:
2424
dev_dependencies:
2525
analyzer: '>=3.4.0 <8.0.0'
2626
build_runner: ^2.0.0
27-
# TODO: untangle analyzer dependency
28-
built_value_generator: ^8.1.0
2927
mockito: ^5.0.0
3028
test: ^1.25.5
3129
test_descriptor: ^2.0.0
3230

31+
dependency_overrides:
32+
mockito: '5.4.6'
33+
source_gen: '2.0.0'
34+
3335
topics:
3436
- build-runner

build_modules/pubspec.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
analyzer: '>=5.1.0 <8.0.0'
1414
async: ^2.5.0
1515
bazel_worker: ^1.0.0
16-
build: ^2.0.0
16+
build: '>=2.0.0 <4.0.0'
1717
build_config: ^1.0.0
1818
collection: ^1.15.0
1919
crypto: ^3.0.0
@@ -30,11 +30,10 @@ dev_dependencies:
3030
path: test/fixtures/a
3131
b:
3232
path: test/fixtures/b
33-
# Used inside tests
3433
build_runner: ^2.0.0
3534
build_runner_core: ^9.0.0
3635
build_test: ^3.1.0
37-
json_serializable: ^6.9.1
36+
# json_serializable: ^6.9.1
3837
test: ^1.16.0
3938

4039
topics:

build_modules/test/fixtures/a/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: a
2-
resolution: workspace
32
environment:
43
sdk: ^3.7.0
4+
resolution: workspace
55

66
dependencies:
77
b:

build_modules/test/fixtures/b/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: b
2-
resolution: workspace
32
environment:
43
sdk: ^3.7.0
4+
resolution: workspace
55

66
dependencies:
77
a:

build_resolvers/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 3.0.0
2+
3+
- Breaking: use the new `element2` APIs in `analyzer`. Builders that do
4+
resolution need to switch to the new API, see
5+
https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/element_model_migration_guide.md.
6+
For questions please use https://github.com/dart-lang/build/discussions.
7+
18
## 2.5.3
29

310
- Use `build_runner_core` 9.1.1.

0 commit comments

Comments
 (0)