Skip to content

Commit

Permalink
Require analyzer 6.5.0 and stop using deprecated nodes. (#1490)
Browse files Browse the repository at this point in the history
* Require analyzer 6.5.0 and stop using deprecated nodes.

* Update CHANGELOG.md

* Replace SDK 3.0.0 with 3.4.0 in two places.
  • Loading branch information
scheglov committed May 15, 2024
1 parent 5ddd749 commit 93d2068
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [3.0.0, dev]
sdk: [3.4.0, dev]
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.0.0, dev]
sdk: [3.4.0, dev]
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.3.7-wip

* Remove temporary work around for analyzer 6.2.0 from dart_style 2.3.6.
* Require `package:analyzer` `>=6.5.0 <7.0.0`.

## 2.3.6

Expand Down
24 changes: 12 additions & 12 deletions lib/src/front_end/ast_node_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,13 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {

@override
void visitExtensionDeclaration(ExtensionDeclaration node) {
(Token, TypeAnnotation)? onType;
if (node.onClause case var onClause?) {
onType = (onClause.onKeyword, onClause.extendedType);
}

writeType(node.metadata, [node.extensionKeyword], node.name,
typeParameters: node.typeParameters,
// TODO(rnystrom): Move to the new analyzer API after Dart 3.4 ships.
// ignore: deprecated_member_use
onType: (node.onKeyword, node.extendedType), body: () {
typeParameters: node.typeParameters, onType: onType, body: () {
return pieces.build(() {
writeBody(node.leftBracket, node.members, node.rightBracket);
});
Expand Down Expand Up @@ -1267,6 +1269,12 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
});
}

@override
void visitMixinOnClause(MixinOnClause node) {
throw UnsupportedError(
'This node is handled by PieceFactory.createType().');
}

@override
void visitNamedExpression(NamedExpression node) {
writeAssignment(node.name.label, node.name.colon, node.expression);
Expand Down Expand Up @@ -1332,14 +1340,6 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
pieces.add(builder.build());
}

@override
// TODO(rnystrom): Move to the new analyzer API after Dart 3.4 ships.
// ignore: deprecated_member_use
void visitOnClause(OnClause node) {
throw UnsupportedError(
'This node is handled by PieceFactory.createType().');
}

@override
void visitParenthesizedExpression(ParenthesizedExpression node) {
pieces.token(node.leftParenthesis);
Expand Down
4 changes: 1 addition & 3 deletions lib/src/front_end/piece_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,7 @@ mixin PieceFactory {
NamedType? superclass,
RepresentationDeclaration? representation,
ExtendsClause? extendsClause,
// TODO(rnystrom): Move to the new analyzer API after Dart 3.4 ships.
// ignore: deprecated_member_use
OnClause? onClause,
MixinOnClause? onClause,
WithClause? withClause,
ImplementsClause? implementsClause,
NativeClause? nativeClause,
Expand Down
17 changes: 7 additions & 10 deletions lib/src/short/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1274,13 +1274,12 @@ class SourceVisitor extends ThrowingAstVisitor {
token(node.name, before: space);

visit(node.typeParameters);
soloSplit();
// TODO(rnystrom): Move to the new analyzer API after Dart 3.4 ships.
// ignore: deprecated_member_use
token(node.onKeyword);
space();
// ignore: deprecated_member_use
visit(node.extendedType);
if (node.onClause case var onClause?) {
soloSplit();
token(onClause.onKeyword);
space();
visit(onClause.extendedType);
}
space();
builder.unnest();
_visitBody(node.leftBracket, node.members, node.rightBracket);
Expand Down Expand Up @@ -2369,9 +2368,7 @@ class SourceVisitor extends ThrowingAstVisitor {
}

@override
// TODO(rnystrom): Move to the new analyzer API after Dart 3.4 ships.
// ignore: deprecated_member_use
void visitOnClause(OnClause node) {
void visitMixinOnClause(MixinOnClause node) {
_visitCombinator(node.onKeyword, node.superclassConstraints);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
sdk: "^3.0.0"

dependencies:
analyzer: '^6.3.0'
analyzer: '^6.5.0'
args: ">=1.0.0 <3.0.0"
collection: "^1.17.0"
path: ^1.0.0
Expand Down

0 comments on commit 93d2068

Please sign in to comment.