[pigeon] allow empty class#12181
Open
tarrinneal wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for empty data classes in Pigeon across Dart, Java, Kotlin, and Objective-C generators, and bumps the package version to 27.2.0. Feedback on the changes suggests adding a blank line between the constructor and the serialization method in the generated Dart code for empty classes to improve readability.
Comment on lines
+229
to
238
| if (classDefinition.fields.isNotEmpty) { | ||
| indent.newln(); | ||
| for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { | ||
| addDocumentationComments(indent, field.documentationComments, docCommentSpec); | ||
|
|
||
| final String datatype = addGenericTypes(field.type); | ||
| indent.writeln('$datatype ${field.name};'); | ||
| indent.newln(); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
When generating Dart code for an empty class, there is no blank line written between the constructor and the _writeToList method. Adding a blank line here improves the readability of the generated code and aligns with Dart style guidelines for class member spacing.
Suggested change
| if (classDefinition.fields.isNotEmpty) { | |
| indent.newln(); | |
| for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { | |
| addDocumentationComments(indent, field.documentationComments, docCommentSpec); | |
| final String datatype = addGenericTypes(field.type); | |
| indent.writeln('$datatype ${field.name};'); | |
| indent.newln(); | |
| } | |
| } | |
| if (classDefinition.fields.isNotEmpty) { | |
| indent.newln(); | |
| for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { | |
| addDocumentationComments(indent, field.documentationComments, docCommentSpec); | |
| final String datatype = addGenericTypes(field.type); | |
| indent.writeln('$datatype ${field.name};'); | |
| indent.newln(); | |
| } | |
| } else { | |
| indent.newln(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
instead of preventing it from being defined, I just made it work