Skip to content

Commit 84a2e79

Browse files
authored
[Pigeon] Make the generated Java Builder class final (#1247)
* make the builder class final * add test * upgrade version
1 parent ffb22bd commit 84a2e79

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

packages/pigeon/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.3
2+
3+
* Makes the generated Java Builder class final.
4+
15
## 2.0.2
26

37
* Fixes Java crash for nullable nested type.

packages/pigeon/lib/generator_tools.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:mirrors';
88
import 'ast.dart';
99

1010
/// The current version of pigeon. This must match the version in pubspec.yaml.
11-
const String pigeonVersion = '2.0.2';
11+
const String pigeonVersion = '2.0.3';
1212

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

packages/pigeon/lib/java_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ void generateJava(JavaOptions options, Root root, StringSink sink) {
567567
}
568568

569569
void writeBuilder() {
570-
indent.write('public static class Builder ');
570+
indent.write('public static final class Builder ');
571571
indent.scoped('{', '}', () {
572572
for (final NamedType field in klass.fields) {
573573
final HostDatatype hostDatatype = getHostDatatype(field, root.classes,

packages/pigeon/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ 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: 2.0.2 # This must match the version in lib/generator_tools.dart
5+
version: 2.0.3 # This must match the version in lib/generator_tools.dart
66

77
environment:
88
sdk: ">=2.12.0 <3.0.0"

packages/pigeon/test/java_generator_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void main() {
3232
final String code = sink.toString();
3333
expect(code, contains('public class Messages'));
3434
expect(code, contains('public static class Foobar'));
35+
expect(code, contains('public static final class Builder'));
3536
expect(code, contains('private @Nullable Long field1;'));
3637
});
3738

0 commit comments

Comments
 (0)