Skip to content

Conversation

@osa1
Copy link
Member

@osa1 osa1 commented Nov 14, 2025

  • Move static method FileGenerator._getDeclaredMixins to the end of the file
    as a top-level function.

    This is a utility method but it came first in the class and it's quite large
    (~90 lines). Move it to the end so that it will allow top-down reading of the
    class and won't obstruct more important details like fields.

  • Refactor import prefix generation: currently if I'm importing container in
    file, I need to do container.importPrefix(context: file). This is
    confusing and it took me a while to figure out what it's doing: It's a method
    on the container type but it modifies the file. Files can import, not
    containers. So files should have import prefixes, not containers.

    Move the method to FileGenerator. The code above now looks like
    file.importPrefix(container).

    Also document the fact that just generating the import prefix for an imported
    thing does not make it imported automatically. This is quite error prone, if
    I call file.importPrefix(container) and use the prefix in e.g.
    EnumGenerator, I need to make sure to update FileGenerator to actually
    generate the import.

    It would be good to refactor this so that just using an prefix is enough to
    import it. But for now this part is not done.

  • Minor changes: use spread syntax instead of []..addAll(...) and similar.
    Add one line space between some of the fields.

@github-actions
Copy link

Package publishing

Package Version Status Publish tag (post-merge)
package:protobuf 5.2.0 ready to publish protobuf-v5.2.0
package:protoc_plugin 24.0.0 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@osa1 osa1 marked this pull request as ready for review November 17, 2025 09:23
@osa1 osa1 requested a review from sigurdm November 17, 2025 09:23
Copy link
Collaborator

@sigurdm sigurdm left a comment

Choose a reason for hiding this comment

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

https://storage.googleapis.com/dart-specification/DartLangSpecDraft.pdf 19.1 Imports p. 219 specifically defines the p part of import 'uri' as p; as the "prefix", not an "alias"

@osa1 osa1 merged commit a1dceed into google:master Nov 17, 2025
12 checks passed
@osa1 osa1 deleted the refactor branch November 17, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants