Skip to content
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
[pigeon] Update analyzer and formatter
Adds compatibility with the latest major version of `analyzer` and
`dart_style` (the latter being required to actually allow `analyzer` 7).

The breaking change of `dart_style` does affect our usage, so this
updates rather than expands the allowed version. The range for
`analyzer` is updated to drop versions older thas 6 since `dart_style`
doesn't allow versions older than 6 anyway.

We have to pick a language version to use for formatting; this (somewhat
arbitrarily) uses 3.6, to opt in to the new formatter.

Fixes flutter/flutter#161820
Fixes flutter/flutter#161583
  • Loading branch information
stuartmorgan-g committed Jan 17, 2025
commit 43a70003ef8a7fbac5835a7687cb72bb9c98794c
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 22.7.3

* Adds compatibility with `analyzer` 7.x.*.

## 22.7.2

* Updates README to discuss best practices for using Pigeon-generated code.
Expand Down
7 changes: 5 additions & 2 deletions packages/pigeon/lib/dart_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:code_builder/code_builder.dart' as cb;
import 'package:dart_style/dart_style.dart';
import 'package:path/path.dart' as path;
import 'package:pub_semver/pub_semver.dart';

import 'ast.dart';
import 'dart/templates.dart';
Expand Down Expand Up @@ -779,7 +780,8 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger;

final cb.DartEmitter emitter = cb.DartEmitter(useNullSafetySyntax: true);
indent.format(
DartFormatter().format('${instanceManagerApi.accept(emitter)}'),
DartFormatter(languageVersion: Version(3, 6, 0))
.format('${instanceManagerApi.accept(emitter)}'),
);
}

Expand Down Expand Up @@ -899,7 +901,8 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger;
);

final cb.DartEmitter emitter = cb.DartEmitter(useNullSafetySyntax: true);
indent.format(DartFormatter().format('${proxyApi.accept(emitter)}'));
indent.format(DartFormatter(languageVersion: Version(3, 6, 0))
.format('${proxyApi.accept(emitter)}'));
}

/// Generates Dart source code for test support libraries based on the given AST
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'ast.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '22.7.2';
const String pigeonVersion = '22.7.3';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
6 changes: 3 additions & 3 deletions packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: pigeon
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pigeon%22
version: 22.7.2 # This must match the version in lib/generator_tools.dart
version: 22.7.3 # This must match the version in lib/generator_tools.dart

environment:
sdk: ^3.4.0

dependencies:
analyzer: ">=5.13.0 <7.0.0"
analyzer: ">=6.0.0 <8.0.0"
args: ^2.1.0
code_builder: ^4.10.0
collection: ^1.15.0
dart_style: ^2.3.4
dart_style: ^3.0.0
graphs: ^2.3.1
meta: ^1.9.0
path: ^1.8.0
Expand Down
Loading