Skip to content

Commit

Permalink
Clean up CodeGenerator by moving compilation-global data and logic …
Browse files Browse the repository at this point in the history
…to `Context` (#1190)

* refactor(prost-build): Context

Move global context data and logic around it from CodeGenerator
to a new Context struct. Also move the logic of can_message_derive_copy
and can_field_derive_copy from MessageGraph where it caused some
data duplication.

* chore: make CodeGenerator::generate crate-private

It was not obvious immediately from the declaration that
CodeGenerator is private to the crate.

* docs(prost-build): life of Context, CodeGenerator

Add doc comments clarifying the lifetime of `Context` and
`CodeGenerator` in the code generation process.

* refactor: CodeGenerator::config helper

* refactor: rename Context::service_generator

Rename to service_generator_mut so it's evident that we are obtaining
a mutable reference even though the Context reference is shared.

* chore: revert can_message_derive_copy behavior

Avoid behavioral changes in the Context refactoring.

* chore: revert should_disable_comments behavior

Avoid behavioral changes in the Context refactoring.

* chore: elide a lifetime in CodeGenerator impl

To please clippy.
  • Loading branch information
mzabaluev authored Feb 7, 2025
1 parent 6445907 commit 35e3f28
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 198 deletions.
Loading

0 comments on commit 35e3f28

Please sign in to comment.