Skip to content

Commit

Permalink
fix analyzer deprecations (#3376)
Browse files Browse the repository at this point in the history
Fixes the build by removing usages of deprecated analyzer apis
  • Loading branch information
jakemac53 committed Oct 4, 2022
1 parent 7409980 commit 9648eff
Show file tree
Hide file tree
Showing 17 changed files with 583 additions and 250 deletions.
766 changes: 539 additions & 227 deletions .github/workflows/dart.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pubspec.yaml
Expand Up @@ -4,7 +4,7 @@ description: A package for authoring build_runner compatible code generators.
repository: https://github.com/dart-lang/build/tree/master/build

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"

dependencies:
analyzer: ">=1.5.0 <6.0.0"
Expand Down
5 changes: 5 additions & 0 deletions build_modules/CHANGELOG.md
@@ -1,3 +1,8 @@
## 4.0.7-dev

- Migrate off deprecated analyzer apis.
- Update min sdk constraint to 2.18.0.

## 4.0.6

- Allow the latest `package:analyzer`.
Expand Down
2 changes: 1 addition & 1 deletion build_modules/lib/src/module_library.dart
Expand Up @@ -238,6 +238,6 @@ bool _isPart(CompilationUnit dart) =>
// but has a part that does, or it exports a `main` from another library.
bool _hasMainMethod(CompilationUnit dart) => dart.declarations.any((node) =>
node is FunctionDeclaration &&
node.name2.lexeme == 'main' &&
node.name.lexeme == 'main' &&
node.functionExpression.parameters != null &&
node.functionExpression.parameters!.parameters.length <= 2);
1 change: 1 addition & 0 deletions build_modules/mono_pkg.yaml
@@ -1,5 +1,6 @@
sdk:
- dev
- pubspec

stages:
- analyze_and_format:
Expand Down
6 changes: 3 additions & 3 deletions build_modules/pubspec.yaml
@@ -1,13 +1,13 @@
name: build_modules
version: 4.0.6
version: 4.0.7-dev
description: Builders for Dart modules
repository: https://github.com/dart-lang/build/tree/master/build_modules

environment:
sdk: ">=2.14.0 <3.0.0"
sdk: '>=2.18.0 <3.0.0'

dependencies:
analyzer: '>=4.4.0 <6.0.0'
analyzer: '>=5.1.0 <6.0.0'
async: ^2.5.0
bazel_worker: ^1.0.0
build: ^2.0.0
Expand Down
5 changes: 5 additions & 0 deletions build_resolvers/CHANGELOG.md
@@ -1,3 +1,8 @@
## 2.0.11-dev

- Migrate off deprecated analyzer apis.
- Update min sdk constraint to 2.18.0.

## 2.0.10

- Migrate from `LibraryElement#parts` to `LibraryElement#parts2`.
Expand Down
8 changes: 4 additions & 4 deletions build_resolvers/pubspec.yaml
@@ -1,17 +1,17 @@
name: build_resolvers
version: 2.0.10
version: 2.0.11-dev
description: Resolve Dart code in a Builder
repository: https://github.com/dart-lang/build/tree/master/build_resolvers

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: '>=2.18.0 <3.0.0'

dependencies:
analyzer: '>=4.6.0 <6.0.0'
analyzer: '>=5.1.0 <6.0.0'
async: ^2.5.0
build: ^2.0.0
crypto: ^3.0.0
graphs: ">=1.0.0 <3.0.0"
graphs: '>=1.0.0 <3.0.0'
logging: ^1.0.0
path: ^1.8.0
package_config: ^2.0.0
Expand Down
7 changes: 3 additions & 4 deletions build_resolvers/test/resolver_test.dart
Expand Up @@ -733,7 +733,7 @@ int? get x => 1;
expect(
unit.declarations.first,
isA<FunctionDeclaration>()
.having((d) => d.name2.lexeme, 'main', 'main'));
.having((d) => d.name.lexeme, 'main', 'main'));
}, resolvers: AnalyzerResolvers());
});
});
Expand All @@ -747,7 +747,7 @@ int? get x => 1;
var unit = await resolver.astNodeFor(lib.topLevelElements.first);
expect(unit, isA<FunctionDeclaration>());
expect(unit!.toSource(), 'main() {}');
expect((unit as FunctionDeclaration).declaredElement2, isNull);
expect((unit as FunctionDeclaration).declaredElement, isNull);
}, resolvers: AnalyzerResolvers());
});

Expand All @@ -762,8 +762,7 @@ int? get x => 1;
unit,
isA<FunctionDeclaration>()
.having((fd) => fd.toSource(), 'toSource()', 'main() {}')
.having(
(fd) => fd.declaredElement2, 'declaredElement', isNotNull),
.having((fd) => fd.declaredElement, 'declaredElement', isNotNull),
);
}, resolvers: AnalyzerResolvers());
});
Expand Down
4 changes: 2 additions & 2 deletions build_test/pubspec.yaml
Expand Up @@ -4,7 +4,7 @@ version: 2.1.6-dev
repository: https://github.com/dart-lang/build/tree/master/build_test

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: '>=2.17.0 <3.0.0'

dependencies:
async: ^2.5.0
Expand All @@ -20,7 +20,7 @@ dependencies:
path: ^1.8.0
stream_transform: ^2.0.0
test: ^1.16.0
test_core: ">=0.3.19 <0.5.0"
test_core: '>=0.3.19 <0.5.0'
watcher: ^1.0.0

dev_dependencies:
Expand Down
5 changes: 5 additions & 0 deletions build_vm_compilers/CHANGELOG.md
@@ -1,3 +1,8 @@
## 1.0.13-dev

- Migrate off deprecated analyzer apis.
- Update min sdk constraint to 2.18.0.

## 1.0.12

- Allow the latest `package:analyzer`.
Expand Down
2 changes: 1 addition & 1 deletion build_vm_compilers/lib/src/vm_entrypoint_builder.dart
Expand Up @@ -94,7 +94,7 @@ Future<bool> _isAppEntryPoint(AssetId dartId, AssetReader reader) async {
// but has a part that does, or it exports a `main` from another library.
return parsed.declarations.any((node) {
return node is FunctionDeclaration &&
node.name2.lexeme == 'main' &&
node.name.lexeme == 'main' &&
node.functionExpression.parameters != null &&
node.functionExpression.parameters!.parameters.length <= 2;
});
Expand Down
6 changes: 3 additions & 3 deletions build_vm_compilers/pubspec.yaml
@@ -1,13 +1,13 @@
name: build_vm_compilers
version: 1.0.12
version: 1.0.13-dev
description: Builder implementations wrapping Dart VM compilers.
repository: https://github.com/dart-lang/build/tree/master/build_vm_compilers

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: '>=2.18.0 <3.0.0'

dependencies:
analyzer: '>=4.4.0 <6.0.0'
analyzer: '>=5.1.0 <6.0.0'
build: ^2.0.0
build_config: ^1.0.0
build_modules: ^4.0.0
Expand Down
5 changes: 5 additions & 0 deletions build_web_compilers/CHANGELOG.md
@@ -1,3 +1,8 @@
## 3.2.7-dev

- Migrate off deprecated analyzer apis.
- Update min sdk constraint to 2.18.0.

## 3.2.6

- Allow the latest `package:analyzer`.
Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/lib/src/web_entrypoint_builder.dart
Expand Up @@ -181,7 +181,7 @@ Future<bool> _isAppEntryPoint(AssetId dartId, AssetReader reader) async {
// but has a part that does, or it exports a `main` from another library.
return parsed.declarations.any((node) {
return node is FunctionDeclaration &&
node.name2.lexeme == 'main' &&
node.name.lexeme == 'main' &&
node.functionExpression.parameters != null &&
node.functionExpression.parameters!.parameters.length <= 2;
});
Expand Down
1 change: 1 addition & 0 deletions build_web_compilers/mono_pkg.yaml
@@ -1,5 +1,6 @@
sdk:
- dev
- pubspec

stages:
- analyze_and_format:
Expand Down
6 changes: 3 additions & 3 deletions build_web_compilers/pubspec.yaml
@@ -1,13 +1,13 @@
name: build_web_compilers
version: 3.2.6
version: 3.2.7-dev
description: Builder implementations wrapping Dart compilers.
repository: https://github.com/dart-lang/build/tree/master/build_web_compilers

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: '>=2.18.0 <3.0.0'

dependencies:
analyzer: '>=4.4.0 <6.0.0'
analyzer: '>=5.1.0 <6.0.0'
archive: ^3.0.0
bazel_worker: ^1.0.0
build: ^2.0.0
Expand Down

0 comments on commit 9648eff

Please sign in to comment.