Skip to content

Commit 69954f2

Browse files
authored
[pigeon] Fixes some Java lint issues (#3060)
* sets classes to final, and other lint issues * breaking change
1 parent 88859a8 commit 69954f2

File tree

23 files changed

+439
-50
lines changed

23 files changed

+439
-50
lines changed

packages/pigeon/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 7.0.0
2+
3+
* [java] **BREAKING CHANGE**: Makes data classes final.
4+
Updates generators for 1p linters.
5+
16
## 6.0.3
27

38
* [docs] Updates README.md.

packages/pigeon/lib/generator_tools.dart

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

1111
/// The current version of pigeon. This must match the version in pubspec.yaml.
12-
const String pigeonVersion = '6.0.3';
12+
const String pigeonVersion = '7.0.0';
1313

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

packages/pigeon/lib/java_generator.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class JavaGenerator extends StructuredGenerator<JavaOptions> {
186186
indent, klass.documentationComments, _docCommentSpec,
187187
generatorComments: generatedMessages);
188188

189-
indent.write('public static class ${klass.name} ');
189+
indent.write('public static final class ${klass.name} ');
190190
indent.scoped('{', '}', () {
191191
for (final NamedType field in getFieldsInSerializationOrder(klass)) {
192192
_writeClassField(generatorOptions, root, indent, field);
@@ -340,7 +340,7 @@ class JavaGenerator extends StructuredGenerator<JavaOptions> {
340340

341341
/// Writes the code for a flutter [Api], [api].
342342
/// Example:
343-
/// public static class Foo {
343+
/// public static final class Foo {
344344
/// public Foo(BinaryMessenger argBinaryMessenger) {...}
345345
/// public interface Reply<T> {
346346
/// void reply(T reply);
@@ -364,13 +364,14 @@ class JavaGenerator extends StructuredGenerator<JavaOptions> {
364364
addDocumentationComments(indent, api.documentationComments, _docCommentSpec,
365365
generatorComments: generatedMessages);
366366

367-
indent.write('public static class ${api.name} ');
367+
indent.write('public static final class ${api.name} ');
368368
indent.scoped('{', '}', () {
369369
indent.writeln('private final BinaryMessenger binaryMessenger;');
370370
indent.write('public ${api.name}(BinaryMessenger argBinaryMessenger)');
371371
indent.scoped('{', '}', () {
372372
indent.writeln('this.binaryMessenger = argBinaryMessenger;');
373373
});
374+
indent.write('/** Public interface for sending reply. */ ');
374375
indent.write('public interface Reply<T> ');
375376
indent.scoped('{', '}', () {
376377
indent.writeln('void reply(T reply);');
@@ -427,10 +428,10 @@ class JavaGenerator extends StructuredGenerator<JavaOptions> {
427428
indent.dec();
428429
indent.dec();
429430
indent.write('$channel.send($sendArgument, channelReply -> ');
430-
indent.scoped('{', '});', () {
431-
if (func.returnType.isVoid) {
432-
indent.writeln('callback.reply(null);');
433-
} else {
431+
if (func.returnType.isVoid) {
432+
indent.addln('callback.reply(null));');
433+
} else {
434+
indent.scoped('{', '});', () {
434435
const String output = 'output';
435436
indent.writeln('@SuppressWarnings("ConstantConditions")');
436437
if (func.returnType.baseName == 'int') {
@@ -441,8 +442,8 @@ class JavaGenerator extends StructuredGenerator<JavaOptions> {
441442
'$returnType $output = ($returnType)channelReply;');
442443
}
443444
indent.writeln('callback.reply($output);');
444-
}
445-
});
445+
});
446+
}
446447
});
447448
}
448449
});

packages/pigeon/mock_handler_tester/test/message.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44
//
5-
// Autogenerated from Pigeon (v6.0.3), do not edit directly.
5+
// Autogenerated from Pigeon (v7.0.0), do not edit directly.
66
// See also: https://pub.dev/packages/pigeon
77
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
88

packages/pigeon/mock_handler_tester/test/test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44
//
5-
// Autogenerated from Pigeon (v6.0.3), do not edit directly.
5+
// Autogenerated from Pigeon (v7.0.0), do not edit directly.
66
// See also: https://pub.dev/packages/pigeon
77
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
88
// ignore_for_file: avoid_relative_lib_imports

packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44
//
5-
// Autogenerated from Pigeon (v6.0.3), do not edit directly.
5+
// Autogenerated from Pigeon (v7.0.0), do not edit directly.
66
// See also: https://pub.dev/packages/pigeon
77

88
package com.example.alternate_language_test_plugin;
@@ -48,7 +48,7 @@ private AnEnum(final int index) {
4848
}
4949

5050
/** Generated class from Pigeon that represents data sent in messages. */
51-
public static class AllTypes {
51+
public static final class AllTypes {
5252
private @NonNull Boolean aBool;
5353

5454
public @NonNull Boolean getABool() {
@@ -337,7 +337,7 @@ ArrayList<Object> toList() {
337337
}
338338

339339
/** Generated class from Pigeon that represents data sent in messages. */
340-
public static class AllNullableTypes {
340+
public static final class AllNullableTypes {
341341
private @Nullable Boolean aNullableBool;
342342

343343
public @Nullable Boolean getANullableBool() {
@@ -657,7 +657,7 @@ ArrayList<Object> toList() {
657657
}
658658

659659
/** Generated class from Pigeon that represents data sent in messages. */
660-
public static class AllNullableTypesWrapper {
660+
public static final class AllNullableTypesWrapper {
661661
private @NonNull AllNullableTypes values;
662662

663663
public @NonNull AllNullableTypes getValues() {
@@ -2171,13 +2171,13 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) {
21712171
*
21722172
* <p>Generated class from Pigeon that represents Flutter messages that can be called from Java.
21732173
*/
2174-
public static class FlutterIntegrationCoreApi {
2174+
public static final class FlutterIntegrationCoreApi {
21752175
private final BinaryMessenger binaryMessenger;
21762176

21772177
public FlutterIntegrationCoreApi(BinaryMessenger argBinaryMessenger) {
21782178
this.binaryMessenger = argBinaryMessenger;
21792179
}
2180-
2180+
/** Public interface for sending reply. */
21812181
public interface Reply<T> {
21822182
void reply(T reply);
21832183
}
@@ -2192,11 +2192,7 @@ public void noop(Reply<Void> callback) {
21922192
BasicMessageChannel<Object> channel =
21932193
new BasicMessageChannel<>(
21942194
binaryMessenger, "dev.flutter.pigeon.FlutterIntegrationCoreApi.noop", getCodec());
2195-
channel.send(
2196-
null,
2197-
channelReply -> {
2198-
callback.reply(null);
2199-
});
2195+
channel.send(null, channelReply -> callback.reply(null));
22002196
}
22012197
/** Returns the passed object, to test serialization and deserialization. */
22022198
public void echoAllTypes(@NonNull AllTypes everythingArg, Reply<AllTypes> callback) {

packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44
//
5-
// Autogenerated from Pigeon (v6.0.3), do not edit directly.
5+
// Autogenerated from Pigeon (v7.0.0), do not edit directly.
66
// See also: https://pub.dev/packages/pigeon
77

88
#import <Foundation/Foundation.h>

packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44
//
5-
// Autogenerated from Pigeon (v6.0.3), do not edit directly.
5+
// Autogenerated from Pigeon (v7.0.0), do not edit directly.
66
// See also: https://pub.dev/packages/pigeon
77

88
#import "CoreTests.gen.h"

0 commit comments

Comments
 (0)