Skip to content

Commit

Permalink
[Pigeon] Make the generated Java Builder class final (#1247)
Browse files Browse the repository at this point in the history
* make the builder class final

* add test

* upgrade version
  • Loading branch information
zhenqiu1101 authored Mar 22, 2022
1 parent ffb22bd commit 84a2e79
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.3

* Makes the generated Java Builder class final.

## 2.0.2

* Fixes Java crash for nullable nested type.
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 @@ -8,7 +8,7 @@ import 'dart:mirrors';
import 'ast.dart';

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

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/java_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void generateJava(JavaOptions options, Root root, StringSink sink) {
}

void writeBuilder() {
indent.write('public static class Builder ');
indent.write('public static final class Builder ');
indent.scoped('{', '}', () {
for (final NamedType field in klass.fields) {
final HostDatatype hostDatatype = getHostDatatype(field, root.classes,
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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%3Apigeon
version: 2.0.2 # This must match the version in lib/generator_tools.dart
version: 2.0.3 # This must match the version in lib/generator_tools.dart

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/pigeon/test/java_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void main() {
final String code = sink.toString();
expect(code, contains('public class Messages'));
expect(code, contains('public static class Foobar'));
expect(code, contains('public static final class Builder'));
expect(code, contains('private @Nullable Long field1;'));
});

Expand Down

0 comments on commit 84a2e79

Please sign in to comment.