protoc_plugin refactors (#1082)

- 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.
8 files changed
tree: 63c75e5b302f6479575974f9f5caf4cf47ffc489
  1. .github/
  2. benchmarks/
  3. protobuf/
  4. protoc_plugin/
  5. tool/
  6. .gitignore
  7. analysis_options.yaml
  8. AUTHORS
  9. LICENSE
  10. pubspec.yaml
  11. README.md
README.md

Protobuf support for Dart

Protocol Buffers (protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.

This repository is home to packages related to protobuf support for Dart.

PackageDescriptionPublished Version
protobufRuntime library for protocol buffers support.pub package
protoc_pluginA protobuf protoc compiler plugin used to generate Dart code.pub package
benchmarksBenchmarks for various protobuf functions.

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.