mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
Make generated Java enum fields final (#2899)
* Make generated Java enum fields final The enum should be immutable, so the fields should be final. * Fix tests * Update CHANGELOG.md * Update generator_tools.dart * Update pubspec.yaml
This commit is contained in:

committed by
GitHub

parent
3a0cbadc60
commit
02de151969
@ -1,3 +1,7 @@
|
||||
## 4.2.10
|
||||
|
||||
* Changes generated Java enum field to be final.
|
||||
|
||||
## 4.2.9
|
||||
|
||||
* [kotlin] Fixes a bug with some methods that return `void`.
|
||||
|
@ -9,7 +9,7 @@ import 'dart:mirrors';
|
||||
import 'ast.dart';
|
||||
|
||||
/// The current version of pigeon. This must match the version in pubspec.yaml.
|
||||
const String pigeonVersion = '4.2.9';
|
||||
const String pigeonVersion = '4.2.10';
|
||||
|
||||
/// Read all the content from [stdin] to a String.
|
||||
String readStdin() {
|
||||
|
@ -578,7 +578,7 @@ void generateJava(JavaOptions options, Root root, StringSink sink) {
|
||||
// discouraged. The toMap and fromMap API matches class API to allow
|
||||
// the same code to work with enums and classes, but this
|
||||
// can also be done directly in the host and flutter APIs.
|
||||
indent.writeln('private int index;');
|
||||
indent.writeln('private final int index;');
|
||||
indent.write('private ${anEnum.name}(final int index) ');
|
||||
indent.scoped('{', '}', () {
|
||||
indent.writeln('this.index = index;');
|
||||
|
@ -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: 4.2.9 # This must match the version in lib/generator_tools.dart
|
||||
version: 4.2.10 # This must match the version in lib/generator_tools.dart
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
@ -61,7 +61,7 @@ void main() {
|
||||
expect(code, contains(' ONE(0),'));
|
||||
expect(code, contains(' TWO_THREE_FOUR(1),'));
|
||||
expect(code, contains(' REMOTE_DB(2);'));
|
||||
expect(code, contains('private int index;'));
|
||||
expect(code, contains('private final int index;'));
|
||||
expect(code, contains('private Foobar(final int index) {'));
|
||||
expect(code, contains(' this.index = index;'));
|
||||
});
|
||||
@ -587,7 +587,7 @@ void main() {
|
||||
expect(code, contains(' ONE(0),'));
|
||||
expect(code, contains(' TWO_THREE_FOUR(1),'));
|
||||
expect(code, contains(' REMOTE_DB(2);'));
|
||||
expect(code, contains('private int index;'));
|
||||
expect(code, contains('private final int index;'));
|
||||
expect(code, contains('private Enum1(final int index) {'));
|
||||
expect(code, contains(' this.index = index;'));
|
||||
|
||||
|
Reference in New Issue
Block a user