Skip to content

SourceCodeScan: scan the code of an enum constant - #162

Merged
bnaudts merged 1 commit into
develfrom
fix/scan-enum-constant-code
Oct 20, 2026
Merged

bnaudts merged 1 commit into
develfrom
fix/scan-enum-constant-code

Conversation

@tomtourwe

@tomtourwe tomtourwe commented Oct 20, 2026 •

Copy link
Copy Markdown
  • This PR's base branch is devel.

What this changes, and why

SourceCodeScan recorded only the comments of an enum constant. It never scanned the constant's code: its arguments (for example an anonymous class passed to the enum's constructor, ONE(new Handler() { ... })) and a constant's own class body (TWO { ... }). So a call written there had no END_OF_ARGUMENT_LIST. A consumer that adds an argument to such a call has no position for the closing parenthesis and falls back to the start of the call: in a closed-core enum whose constants each get an anonymous handler, adding the argument x1 to Util.label() produced x1til.label(). scanEnumConstant now also scans the constant's code, the same way a field's initializer is scanned (scanCodeBlock).

An enum constant's arguments -- an anonymous class passed to the constructor, a call -- and its own class body were
never scanned: only its comments were. A call there had no END_OF_ARGUMENT_LIST, and a consumer adding an argument
fell back to the start of the call: codelaser bean.migrate turned `Util.label()` into `x1til.label()` in an enum of
closed-core whose constants each get an anonymous handler. Test: TestSourceCodeScan.test8_enumConstants.

Signed-off-by: Tom Tourwe <Tom.Tourwe@codelaser.io>
@bnaudts
bnaudts merged commit 8ed2ab6 into devel Oct 20, 2026
3 checks passed
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