Skip to content

Commit 464a347

Browse files
committed
Revert "Add APIs for using analyzer element model 2. (#3775)"
This reverts commit 1865a35.
1 parent 1865a35 commit 464a347

File tree

8 files changed

+34
-250
lines changed

8 files changed

+34
-250
lines changed

build/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- Bump the min sdk to 3.6.0-228.0.dev.
44
- Remove some unnecessary casts and non-null assertions now that we have private
55
field promotion.
6-
- Require analyzer ^7.0.0.
6+
- Require analyzer ^6.9.0.
77
- Fix analyzer deprecations.
88

99
## 2.4.1

build/lib/src/analyzer/resolver.dart

-56
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:analyzer/dart/analysis/results.dart';
55
import 'package:analyzer/dart/analysis/session.dart';
66
import 'package:analyzer/dart/ast/ast.dart';
77
import 'package:analyzer/dart/element/element.dart';
8-
import 'package:analyzer/dart/element/element2.dart';
98
import 'package:analyzer/error/error.dart';
109

1110
import '../asset/id.dart';
@@ -30,17 +29,6 @@ abstract class Resolver {
3029
/// instance because due to imports or exports.
3130
Stream<LibraryElement> get libraries;
3231

33-
/// All libraries resolved by this resolver.
34-
///
35-
/// This includes the following libraries:
36-
/// - The primary input of this resolver (in other words, the
37-
/// [BuildStep.inputId] of a build step).
38-
/// - Libraries resolved with a direct [libraryFor] call.
39-
/// - Every public `dart:` library part of the SDK.
40-
/// - All libraries recursively accessible from the mentioned sources, for
41-
/// instance because due to imports or exports.
42-
Stream<LibraryElement2> get libraries2;
43-
4432
/// Returns the parsed [AstNode] for [Element].
4533
///
4634
/// This should always be preferred over using the [AnalysisSession]
@@ -54,19 +42,6 @@ abstract class Resolver {
5442
/// reason.
5543
Future<AstNode?> astNodeFor(Element element, {bool resolve = false});
5644

57-
/// Returns the parsed [AstNode] for [Element].
58-
///
59-
/// This should always be preferred over using the [AnalysisSession]
60-
/// directly, because it avoids [InconsistentAnalysisException] issues.
61-
///
62-
/// If [resolve] is `true` then you will get a resolved ast node, otherwise
63-
/// it will only be a parsed ast node.
64-
///
65-
/// Returns `null` if the ast node can not be found. This can happen if an
66-
/// element is coming from a summary, or is unavailable for some other
67-
/// reason.
68-
Future<AstNode?> astNodeFor2(Fragment element, {bool resolve = false});
69-
7045
/// Returns a parsed AST structor representing the file defined in [assetId].
7146
///
7247
/// * If the [assetId] has syntax errors, and [allowSyntaxErrors] is set to
@@ -85,14 +60,6 @@ abstract class Resolver {
8560
Future<LibraryElement> libraryFor(AssetId assetId,
8661
{bool allowSyntaxErrors = false});
8762

88-
/// Returns a resolved library representing the file defined in [assetId].
89-
///
90-
/// * Throws [NonLibraryAssetException] if [assetId] is not a Dart library.
91-
/// * If the [assetId] has syntax errors, and [allowSyntaxErrors] is set to
92-
/// `false` (the default), throws a [SyntaxErrorInAssetException].
93-
Future<LibraryElement2> libraryFor2(AssetId assetId,
94-
{bool allowSyntaxErrors = false});
95-
9663
/// Returns the first resolved library identified by [libraryName].
9764
///
9865
/// A library is resolved if it's recursively accessible from the entry point
@@ -105,19 +72,6 @@ abstract class Resolver {
10572
/// being unique.
10673
Future<LibraryElement?> findLibraryByName(String libraryName);
10774

108-
/// Returns the first resolved library identified by [libraryName].
109-
///
110-
/// A library is resolved if it's recursively accessible from the entry point
111-
/// or subsequent calls to [libraryFor]. In other words, this searches for
112-
/// libraries in [libraries].
113-
/// If no library can be found, returns `null`.
114-
///
115-
/// **NOTE**: In general, its recommended to use [libraryFor] with an absolute
116-
/// asset id instead of a named identifier that has the possibility of not
117-
/// being unique.
118-
Future<LibraryElement2?> findLibraryByName2(
119-
String libraryName);
120-
12175
/// Returns the [AssetId] of the Dart library or part declaring [element].
12276
///
12377
/// If [element] is defined in the SDK or in a summary throws
@@ -127,16 +81,6 @@ abstract class Resolver {
12781
/// The returned asset is not necessarily the asset that should be imported to
12882
/// use the element, it may be a part file instead of the library.
12983
Future<AssetId> assetIdForElement(Element element);
130-
131-
/// Returns the [AssetId] of the Dart library or part declaring [element].
132-
///
133-
/// If [element] is defined in the SDK or in a summary throws
134-
/// `UnresolvableAssetException`, although a non-throwing return here does not
135-
/// guarantee that the asset is readable.
136-
///
137-
/// The returned asset is not necessarily the asset that should be imported to
138-
/// use the element, it may be a part file instead of the library.
139-
Future<AssetId> assetIdForElement2(Element2 element);
14084
}
14185

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

build/lib/src/builder/build_step.dart

-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'dart:async';
55
import 'dart:convert';
66

77
import 'package:analyzer/dart/element/element.dart';
8-
import 'package:analyzer/dart/element/element2.dart';
98
import 'package:meta/meta.dart';
109
import 'package:package_config/package_config_types.dart';
1110

@@ -40,21 +39,6 @@ abstract class BuildStep implements AssetReader, AssetWriter {
4039
/// ```
4140
Future<LibraryElement> get inputLibrary;
4241

43-
/// Resolved library defined by [inputId].
44-
///
45-
/// Throws [NonLibraryAssetException] if [inputId] is not a Dart library file.
46-
/// Throws [SyntaxErrorInAssetException] if [inputId] contains syntax errors.
47-
/// If you want to support libraries with syntax errors, resolve the library
48-
/// manually instead of using [inputLibrary]:
49-
/// ```dart
50-
/// Future<void> build(BuildStep step) async {
51-
/// // Resolve the input library, allowing syntax errors
52-
/// final inputLibrary =
53-
/// await step.resolver.libraryFor(step.inputId, allowSyntaxErrors: true);
54-
/// }
55-
/// ```
56-
Future<LibraryElement2> get inputLibrary2;
57-
5842
/// Gets an instance provided by [resource] which is guaranteed to be unique
5943
/// within a single build, and may be reused across build steps within a
6044
/// build if the implementation allows.

build/lib/src/builder/build_step_impl.dart

-32
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'dart:convert';
77

88
import 'package:analyzer/dart/ast/ast.dart';
99
import 'package:analyzer/dart/element/element.dart';
10-
import 'package:analyzer/dart/element/element2.dart';
1110
import 'package:async/async.dart';
1211
import 'package:crypto/crypto.dart';
1312
import 'package:glob/glob.dart';
@@ -40,12 +39,6 @@ class BuildStepImpl implements BuildStep {
4039
return resolver.libraryFor(inputId);
4140
}
4241

43-
@override
44-
Future<LibraryElement2> get inputLibrary2 async {
45-
if (_isComplete) throw BuildStepCompletedException();
46-
return resolver.libraryFor2(inputId);
47-
}
48-
4942
/// The list of all outputs which are expected/allowed to be output from this
5043
/// step.
5144
@override
@@ -227,21 +220,10 @@ class _DelayedResolver implements Resolver {
227220
return completer.stream;
228221
}
229222

230-
@override
231-
Stream<LibraryElement2> get libraries2 {
232-
var completer = StreamCompleter<LibraryElement2>();
233-
_delegate.then((r) => completer.setSourceStream(r.libraries2));
234-
return completer.stream;
235-
}
236-
237223
@override
238224
Future<AstNode?> astNodeFor(Element element, {bool resolve = false}) async =>
239225
(await _delegate).astNodeFor(element, resolve: resolve);
240226

241-
@override
242-
Future<AstNode?> astNodeFor2(Fragment fragment, {bool resolve = false}) async =>
243-
(await _delegate).astNodeFor2(fragment, resolve: resolve);
244-
245227
@override
246228
Future<CompilationUnit> compilationUnitFor(AssetId assetId,
247229
{bool allowSyntaxErrors = false}) async =>
@@ -254,25 +236,11 @@ class _DelayedResolver implements Resolver {
254236
(await _delegate)
255237
.libraryFor(assetId, allowSyntaxErrors: allowSyntaxErrors);
256238

257-
@override
258-
Future<LibraryElement2> libraryFor2(AssetId assetId,
259-
{bool allowSyntaxErrors = false}) async =>
260-
(await _delegate)
261-
.libraryFor2(assetId, allowSyntaxErrors: allowSyntaxErrors);
262-
263239
@override
264240
Future<LibraryElement?> findLibraryByName(String libraryName) async =>
265241
(await _delegate).findLibraryByName(libraryName);
266242

267-
@override
268-
Future<LibraryElement2?> findLibraryByName2(String libraryName) async =>
269-
(await _delegate).findLibraryByName2(libraryName);
270-
271243
@override
272244
Future<AssetId> assetIdForElement(Element element) async =>
273245
(await _delegate).assetIdForElement(element);
274-
275-
@override
276-
Future<AssetId> assetIdForElement2(Element2 element) async =>
277-
(await _delegate).assetIdForElement2(element);
278246
}

build/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ environment:
1111
sdk: ^3.6.0-228.0.dev
1212

1313
dependencies:
14-
analyzer: ^7.0.0
14+
analyzer: ^6.9.0
1515
async: ^2.5.0
1616
convert: ^3.0.0
1717
crypto: ^3.0.0

build_resolvers/CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
- Fix SDK summary reads when multiple isolates are using build resolvers (not
77
recommended).
88
- Fix analyzer deprecations.
9-
- Require analyzer ^7.0.0.
109

1110
## 2.4.2
1211

0 commit comments

Comments
 (0)