Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pigeon] Implement Screaming Snake Case Conversion for Kotlin Enum Cases #5918

Merged
merged 10 commits into from
Feb 9, 2024

Conversation

erdzan12
Copy link
Contributor

This pull request addresses issue flutter/flutter#140938 in the Pigeon package, related to the naming convention of Kotlin enum cases generated from lower camel case Dart enums. The current implementation concatenates the enum cases in uppercase, deviating from the Kotlin naming convention, specifically when dealing with multi-word names.

Changes

  • Kotlin Enum Generation: Modified the writeEnum function in the Pigeon package to ensure the Kotlin generator produces enum cases in SCREAMING_SNAKE_CASE. This adheres to the Kotlin coding conventions and allows a consistent cross-platform enum naming convention across Dart, Kotlin, and Swift.
  • Regex Handling: Enhanced the regex pattern to correctly transform lower camel case names to screaming snake case, considering edge cases involving numbers and special characters.
  • Testing: Updated the Dart unit tests to include cases for validating the correct transformation of multi-word and complex enum names from lower camel case to screaming snake case.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

…n for enum member names to follow Kotlin naming conventions

test(kotlin_generator_test.dart): update test cases to reflect changes in enum member name conversion
…ools.dart and pubspec.yaml to reflect new changes

docs(pigeon): update CHANGELOG.md with details of the new version and migration note for users
Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good change, it will need updated integration tests as well though.

Thanks for putting this together.

packages/pigeon/test/kotlin_generator_test.dart Outdated Show resolved Hide resolved
packages/pigeon/CHANGELOG.md Show resolved Hide resolved
…dd SnakeCase enum member to EnumState

refactor(kotlin_generator.dart): simplify nameScreamingSnakeCase regex replacement logic
test(EnumTest.kt): update test cases to use new SnakeCase enum member for better coverage
@tarrinneal tarrinneal mentioned this pull request Jan 20, 2024
11 tasks
@tarrinneal
Copy link
Contributor

This shouldn't be passing tests as is, I'll go ahead and generate the new files, format them, and upload them to this pr (assuming the branch isn't preventing that).

@stuartmorgan for tests not failing here.

@erdzan12
Copy link
Contributor Author

erdzan12 commented Feb 7, 2024

I was hesitant regarding the generated files, wanted to check if they would be generated when running the tests here on the CI, as I saw the generated files on my end had lots of changes but only regarding the formatting + a couple of new things regarding the additions

@tarrinneal
Copy link
Contributor

I was hesitant regarding the generated files, wanted to check if they would be generated when running the tests here on the CI, as I saw the generated files on my end had lots of changes but only regarding the formatting + a couple of new things regarding the additions

always good to run the formatting tool after generation to clean things up a bit: https://github.com/flutter/plugins/blob/master_archive/script/tool/README.md#format-code

@tarrinneal
Copy link
Contributor

tarrinneal commented Feb 7, 2024

There should also be a few integration test in packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart that echo's an enum, it would be good to add one of each that sends one of the new members across as well.

…undredTwentyTwo' to AnEnum to extend test coverage
…n AnEnum for better code readability and to follow correct English spelling conventions
@tarrinneal
Copy link
Contributor

@stuartmorgan for second review

@tarrinneal tarrinneal force-pushed the enum_scream_snake_case_140938 branch from cda5799 to 679cc3d Compare February 7, 2024 22:16
@tarrinneal
Copy link
Contributor

Sorry for the force push, I accidentally sent up a file I didn't mean to, had to revert that.

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the tests pass, this lgtm

@stuartmorgan
Copy link
Contributor

@stuartmorgan for tests not failing here.

What tests weren't failing that should have been, specifically? There was a Flutter-wide issue where test failures didn't turn the step red, so we can inspect the output manually.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stuartmorgan
Copy link
Contributor

(Holding off on autosubmit until the test question is resolved in case there's still something going on here that would result in us not seeing issues with this PR in CI.)

@tarrinneal
Copy link
Contributor

(Holding off on autosubmit until the test question is resolved in case there's still something going on here that would result in us not seeing issues with this PR in CI.)

wasn't related to the code itself. There was no updated generated files, but it didn't fail the formatting test.

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 9, 2024
@auto-submit auto-submit bot merged commit 90baeee into flutter:main Feb 9, 2024
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 9, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 9, 2024
flutter/packages@29d8cc0...11152d2

2024-02-09 [email protected] [webview_flutter] Add interface for showing javascript dialog message (flutter/packages#4704)
2024-02-09 [email protected] [pigeon] Implement Screaming Snake Case Conversion for Kotlin Enum Cases (flutter/packages#5918)
2024-02-09 [email protected] [camerax] Small fixes to starting/stopping video capture (flutter/packages#6068)
2024-02-08 [email protected] Roll Flutter from 8431cae to eb5d0a4 (33 revisions) (flutter/packages#6079)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
…ses (flutter#5918)

This pull request addresses issue flutter/flutter#140938 in the Pigeon package, related to the naming convention of Kotlin enum cases generated from lower camel case Dart enums. The current implementation concatenates the enum cases in uppercase, deviating from the Kotlin naming convention, specifically when dealing with multi-word names.

Changes

- Kotlin Enum Generation: Modified the writeEnum function in the Pigeon package to ensure the Kotlin generator produces enum cases in SCREAMING_SNAKE_CASE. This adheres to the Kotlin coding conventions and allows a consistent cross-platform enum naming convention across Dart, Kotlin, and Swift.
- Regex Handling: Enhanced the regex pattern to correctly transform lower camel case names to screaming snake case, considering edge cases involving numbers and special characters.
- Testing: Updated the Dart unit tests to include cases for validating the correct transformation of multi-word and complex enum names from lower camel case to screaming snake case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants