Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to analyzer 5.1.0 and handle deprecations #1140

Merged
merged 3 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: [2.17.0, dev]
sdk: [2.18.0, dev]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/[email protected]
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: [2.17.0, dev]
sdk: [2.18.0, dev]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.2.5-dev

* Require `package:analyzer` `^5.1.0`.

# 2.2.4

* Unify how brace-delimited syntax is formatted. This is mostly an internal
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/formatter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'show.dart';
import 'summary.dart';

// Note: The following line of code is modified by tool/grind.dart.
const dartStyleVersion = '2.2.4';
const dartStyleVersion = '2.2.5-dev';

/// Global options that affect how the formatter produces and uses its outputs.
class FormatterOptions {
Expand Down
32 changes: 16 additions & 16 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ class SourceVisitor extends ThrowingAstVisitor {
modifier(node.abstractKeyword);
token(node.classKeyword);
space();
token(node.name2);
token(node.name);
visit(node.typeParameters);
visit(node.extendsClause);
_visitClauses(node.withClause, node.implementsClause);
Expand All @@ -617,7 +617,7 @@ class SourceVisitor extends ThrowingAstVisitor {
modifier(node.abstractKeyword);
token(node.typedefKeyword);
space();
token(node.name2);
token(node.name);
visit(node.typeParameters);
space();
token(node.equals);
Expand Down Expand Up @@ -764,7 +764,7 @@ class SourceVisitor extends ThrowingAstVisitor {
modifier(node.factoryKeyword);
visit(node.returnType);
token(node.period);
token(node.name2);
token(node.name);

// Make the rule for the ":" span both the preceding parameter list and
// the entire initialization list. This ensures that we split before the
Expand Down Expand Up @@ -981,7 +981,7 @@ class SourceVisitor extends ThrowingAstVisitor {
@override
void visitEnumConstantDeclaration(EnumConstantDeclaration node) {
visitMetadata(node.metadata);
token(node.name2);
token(node.name);

var arguments = node.arguments;
if (arguments != null) {
Expand All @@ -1006,7 +1006,7 @@ class SourceVisitor extends ThrowingAstVisitor {
builder.nestExpression();
token(node.enumKeyword);
space();
token(node.name2);
token(node.name);
visit(node.typeParameters);
_visitClauses(node.withClause, node.implementsClause);
space();
Expand Down Expand Up @@ -1250,9 +1250,9 @@ class SourceVisitor extends ThrowingAstVisitor {

// Don't put a space after `extension` if the extension is unnamed. That
// way, generic unnamed extensions format like `extension<T> on ...`.
if (node.name2 != null) {
if (node.name != null) {
space();
token(node.name2);
token(node.name);
}

visit(node.typeParameters);
Expand Down Expand Up @@ -1607,17 +1607,17 @@ class SourceVisitor extends ThrowingAstVisitor {
// Inlined visitGenericTypeAlias
_visitGenericTypeAliasHeader(
node.typedefKeyword,
node.name2,
node.name,
node.typeParameters,
null,
node.returnType?.beginToken ?? node.name2);
node.returnType?.beginToken ?? node.name);

space();

// Recursively convert function-arguments to Function syntax.
_insideNewTypedefFix = true;
_visitGenericFunctionType(
node.returnType, null, node.name2, null, node.parameters);
node.returnType, null, node.name, null, node.parameters);
_insideNewTypedefFix = false;
});
return;
Expand All @@ -1627,7 +1627,7 @@ class SourceVisitor extends ThrowingAstVisitor {
token(node.typedefKeyword);
space();
visit(node.returnType, after: space);
token(node.name2);
token(node.name);
visit(node.typeParameters);
visit(node.parameters);
});
Expand Down Expand Up @@ -1669,7 +1669,7 @@ class SourceVisitor extends ThrowingAstVisitor {
void visitGenericTypeAlias(GenericTypeAlias node) {
visitNodes(node.metadata, between: newline, after: newline);
_simpleStatement(node, () {
_visitGenericTypeAliasHeader(node.typedefKeyword, node.name2,
_visitGenericTypeAliasHeader(node.typedefKeyword, node.name,
node.typeParameters, node.equals, null);

space();
Expand Down Expand Up @@ -2022,7 +2022,7 @@ class SourceVisitor extends ThrowingAstVisitor {
_simpleStatement(node, () {
token(node.libraryKeyword);
space();
visit(node.name);
visit(node.name2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's happening with this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In analyzer 5.1.0, .name is deprecated in favor of .name2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on a different type than the rest of the invocations?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, my bad. In all of the other changes, .name2 is deprecated in favor of .name.

For this change, LibraryDirective.name, a non-nullable String is being replaced with LibraryDirective.name2, a nullable String (for the case of an omitted named).

});
}

Expand Down Expand Up @@ -2121,7 +2121,7 @@ class SourceVisitor extends ThrowingAstVisitor {
builder.nestExpression();
token(node.mixinKeyword);
space();
token(node.name2);
token(node.name);
visit(node.typeParameters);

// If there is only a single superclass constraint, format it like an
Expand Down Expand Up @@ -2504,7 +2504,7 @@ class SourceVisitor extends ThrowingAstVisitor {
@override
void visitTypeParameter(TypeParameter node) {
visitParameterMetadata(node.metadata, () {
token(node.name2);
token(node.name);
token(node.extendsKeyword, before: space, after: space);
visit(node.bound);
});
Expand All @@ -2521,7 +2521,7 @@ class SourceVisitor extends ThrowingAstVisitor {

@override
void visitVariableDeclaration(VariableDeclaration node) {
token(node.name2);
token(node.name);
if (node.initializer == null) return;

// If there are multiple variables being declared, we want to nest the
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_style
# Note: See tool/grind.dart for how to bump the version.
version: 2.2.4
version: 2.2.5-dev
description: >-
Opinionated, automatic Dart source code formatter.
Provides an API and a CLI tool.
Expand All @@ -9,7 +9,7 @@ environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
analyzer: '>=4.4.0 <6.0.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't leave a comment on the right line - but we need to bump the version of dart_style

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

analyzer: '^5.1.0'
args: ">=1.0.0 <3.0.0"
path: ^1.0.0
pub_semver: ">=1.4.4 <3.0.0"
Expand Down