Skip to content

Reuse package+imports header in Clazz#148

Open
adamw7 wants to merge 1 commit into
mainfrom
claude/fix-clazz-dup-header
Open

Reuse package+imports header in Clazz#148
adamw7 wants to merge 1 commit into
mainfrom
claude/fix-clazz-dup-header

Conversation

@adamw7
Copy link
Copy Markdown
Owner

@adamw7 adamw7 commented Apr 19, 2026

Summary

Clazz computed generatePackage() + generateImports() twice: once in the constructor (to hand to Interfaces/Implementations) and again at the top of generate(). The two values are computed from the same inputs with no state change between them, so the second call is dead work — and if they ever diverged, we'd silently emit different imports in the main class than in the sibling interfaces/impls.

Store the header once on the instance and reuse it.

Test plan

  • mvn install passes
  • Generated output byte-for-byte identical (regression tests under protogen-maven-plugin-test)

Clazz built the package declaration and imports once in the constructor
(to hand to Interfaces/Implementations) and then rebuilt the identical
string in generate(). The two strings were computed from the same inputs
with no intervening state change, so the second computation was dead
work — and if the two ever diverged it would have been a subtle bug.
Store the header once and reuse it.
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