[pigeon] Tidy GeneratorAdapters to be const, with getters instead of fields#11131
[pigeon] Tidy GeneratorAdapters to be const, with getters instead of fields#11131srawlins merged 2 commits intoflutter:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the GeneratorAdapter classes to enable const constructors. This involves converting the fileTypeList instance field to a getter in GeneratorAdapter and its subclasses, and changing languageString to a static const field. Additionally, the _openSink function is refactored for conciseness by removing unnecessary local variables.
tarrinneal
left a comment
There was a problem hiding this comment.
Seems like this is old code that I would guess was just here for testing when it was added. This seems like a good improvement, thank you
|
@stuartmorgan-g more exceptions here I believe |
|
This is a non-trivial (even if relatively straightforward) set of changes to production code, so our standard practice to version this for continuous release applies. |
|
Thanks! I've bumped the version now. |
flutter/packages@e1d0169...a27d7c5 2026-02-26 [email protected] [pigeon] Tidy GeneratorAdapters to be const, with getters instead of fields (flutter/packages#11131) 2026-02-26 [email protected] [webview_flutter] Remove usesCleartextTraffic (flutter/packages#11124) 2026-02-26 [email protected] [pigeon]: Correct comment references in doc comments (flutter/packages#11129) 2026-02-26 [email protected] [webview_flutter_android] Remove usesCleartextTraffic (flutter/packages#11122) 2026-02-26 [email protected] Roll Flutter from dad6f9d to b31548f (39 revisions) (flutter/packages#11116) 2026-02-26 [email protected] [espresso] Remove usesCleartextTraffic (flutter/packages#11125) 2026-02-26 [email protected] [pigeon] Use function types in order to avoid dynamic calls (flutter/packages#11130) 2026-02-26 [email protected] [shared_preferences] Revert androidx.datastore:datastore to 1.1.7 (flutter/packages#11128) 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] 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
…r#183009) flutter/packages@e1d0169...a27d7c5 2026-02-26 [email protected] [pigeon] Tidy GeneratorAdapters to be const, with getters instead of fields (flutter/packages#11131) 2026-02-26 [email protected] [webview_flutter] Remove usesCleartextTraffic (flutter/packages#11124) 2026-02-26 [email protected] [pigeon]: Correct comment references in doc comments (flutter/packages#11129) 2026-02-26 [email protected] [webview_flutter_android] Remove usesCleartextTraffic (flutter/packages#11122) 2026-02-26 [email protected] Roll Flutter from dad6f9d to b31548f (39 revisions) (flutter/packages#11116) 2026-02-26 [email protected] [espresso] Remove usesCleartextTraffic (flutter/packages#11125) 2026-02-26 [email protected] [pigeon] Use function types in order to avoid dynamic calls (flutter/packages#11130) 2026-02-26 [email protected] [shared_preferences] Revert androidx.datastore:datastore to 1.1.7 (flutter/packages#11128) 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] 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
While walking through the GeneratorAdapter code, I noticed a few oddities. While tidying things up, I found that each of the subclasses could have const constructors, which I think are preferred by the Flutter team.
fileTypeListfield which never stored a value. Each subclass implements the parent class, so the constructor was never called. I changed the field to a getter (for the interface), and removed the constructor.String languageStringwhich could be made static and const.List<FileType> fileTypeListinto a getter, to avoid the "Fields in const classes should not have initializers" enforced lint rule.this.fileTypeListas a constructor parameter, but a value was essentially never passed in. (There was once instance in a test, but it had no effect.) So I removed this constructor parameter, moving the const default values to the getter value._openSinkhad some unnecessary statements, so I made it more concise. Thesinkvariable was unnecessary, and thefilevariable was only used in one else-branch, and so should be declared in that block.Pre-Review Checklist
[shared_preferences]///).