Skip to content

Commit d83ab7f

Browse files
authored
[pigeon] Require analyzer 5.13.0, prepare for NamedType refactoring. (#4127)
We would like to make a breaking change to the Dart analyzer. https://dart-review.googlesource.com/c/sdk/+/303280 flutter/flutter#128212 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
1 parent de7331a commit d83ab7f

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

packages/pigeon/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 10.0.1
2+
3+
* Requires `analyzer 5.13.0` and replaces use of deprecated APIs.
4+
15
## 10.0.0
26

37
* [swift] Avoids using `Any` to represent `Optional` in Swift.

packages/pigeon/lib/generator_tools.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'ast.dart';
1111
/// The current version of pigeon.
1212
///
1313
/// This must match the version in pubspec.yaml.
14-
const String pigeonVersion = '10.0.0';
14+
const String pigeonVersion = '10.0.1';
1515

1616
/// Read all the content from [stdin] to a String.
1717
String readStdin() {

packages/pigeon/lib/pigeon_lib.dart

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,10 +1004,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
10041004
final dart_ast.NamedType? namedType =
10051005
getFirstChildOfType<dart_ast.NamedType>(parameter);
10061006
if (namedType != null) {
1007-
// TODO(stuartmorgan): Replace `name` when adopting the next version of
1008-
// analyzer.
1009-
// ignore: deprecated_member_use
1010-
final String argTypeBaseName = namedType.name.name;
1007+
final String argTypeBaseName = _getNamedTypeQualifiedName(namedType);
10111008
final bool isNullable = namedType.question != null;
10121009
final List<TypeDeclaration> argTypeArguments =
10131010
typeAnnotationsToTypeArguments(namedType.typeArguments);
@@ -1089,10 +1086,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
10891086
Method(
10901087
name: node.name.lexeme,
10911088
returnType: TypeDeclaration(
1092-
// TODO(stuartmorgan): Replace `name` when adopting the next
1093-
// version of analyzer.
1094-
// ignore: deprecated_member_use
1095-
baseName: returnType.name.name,
1089+
baseName: _getNamedTypeQualifiedName(returnType),
10961090
typeArguments:
10971091
typeAnnotationsToTypeArguments(returnType.typeArguments),
10981092
isNullable: returnType.question != null),
@@ -1141,10 +1135,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
11411135
for (final Object x in typeArguments.childEntities) {
11421136
if (x is dart_ast.NamedType) {
11431137
result.add(TypeDeclaration(
1144-
// TODO(stuartmorgan): Replace `name` when adopting the next
1145-
// version of analyzer.
1146-
// ignore: deprecated_member_use
1147-
baseName: x.name.name,
1138+
baseName: _getNamedTypeQualifiedName(x),
11481139
isNullable: x.question != null,
11491140
typeArguments: typeAnnotationsToTypeArguments(x.typeArguments)));
11501141
}
@@ -1174,10 +1165,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
11741165
final dart_ast.TypeArgumentList? typeArguments = type.typeArguments;
11751166
_currentClass!.fields.add(NamedType(
11761167
type: TypeDeclaration(
1177-
// TODO(stuartmorgan): Replace `name` when adopting the next
1178-
// version of analyzer.
1179-
// ignore: deprecated_member_use
1180-
baseName: type.name.name,
1168+
baseName: _getNamedTypeQualifiedName(type),
11811169
isNullable: type.question != null,
11821170
typeArguments: typeAnnotationsToTypeArguments(typeArguments),
11831171
),
@@ -1223,6 +1211,14 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
12231211
node.visitChildren(this);
12241212
return null;
12251213
}
1214+
1215+
static String _getNamedTypeQualifiedName(dart_ast.NamedType node) {
1216+
final dart_ast.ImportPrefixReference? importPrefix = node.importPrefix;
1217+
if (importPrefix != null) {
1218+
return '${importPrefix.name.lexeme}.${node.name2.lexeme}';
1219+
}
1220+
return node.name2.lexeme;
1221+
}
12261222
}
12271223

12281224
int? _calculateLineNumberNullable(String contents, int? offset) {

packages/pigeon/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: pigeon
22
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
33
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
5-
version: 10.0.0 # This must match the version in lib/generator_tools.dart
5+
version: 10.0.1 # This must match the version in lib/generator_tools.dart
66

77
environment:
8-
sdk: ">=2.18.0 <4.0.0"
8+
sdk: ">=2.19.0 <4.0.0"
99

1010
dependencies:
11-
analyzer: "^5.2.0"
11+
analyzer: "^5.13.0"
1212
args: ^2.1.0
1313
collection: ^1.15.0
1414
meta: ^1.7.0

0 commit comments

Comments
 (0)