You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement: capture Java enums, records, and annotation types as definitions in vg build #372
Java definitions in vg build come from the JAVA block in src/engine/queries.ts. Today that block captures methods, constructors, classes and interfaces, but not enums, records, or annotation types. In a typical Spring codebase those are real lookup targets: status/permission enums, DTO records, and custom annotations like @Audited.
C# already handles the same gap. Its block captures enum_declaration and record_declaration as kind class, with a comment explaining why (class is the engine's established kind for enum-like types, matching Rust enum_item and C enum_specifier). Java should be consistent.
What to do
In the JAVA.defs list, add captures for:
enum_declaration (kind class)
record_declaration (kind class)
annotation_type_declaration (kind interface seems the closest fit, but say which you chose and why in the PR)
Check that the bundled tree-sitter-java grammar actually has these node names (records arrived in later grammar versions). If one is missing, leave it out and note it in the PR.
Add a small fixture under test/fixtures/ with one enum (including a constant-specific method body), one record, and one @interface. Then add a test that runs vg build and asserts the definitions.
Acceptance
vg show <EnumName>, vg show <RecordName> and vg show <AnnotationName> resolve to the right file and line on the fixture
Methods declared inside an enum or record are still captured as methods
graph.json for the fixture is byte-identical across two runs (see the determinism checklist in CONTRIBUTING)
Existing Java fixtures (packages/test-solutions/java-spring) show no lost definitions
pnpm test, pnpm lint, pnpm typecheck green; Conventional Commit such as feat(engine): capture Java enums, records and annotation types
Lovely, well-scoped first issue, and confirmed on main. In src/engine/queries.ts the JAVA block (line ~165) captures only method_declaration, constructor_declaration, class_declaration and interface_declaration. The C_SHARP block a few lines below (around lines 220–227) already captures enum_declaration and record_declaration as kind class, and its comment explains why. That's the pattern to mirror.
Steps:
Add the enum_declaration, record_declaration and annotation_type_declaration captures to JAVA.defs. Check that the vendored tree-sitter-java grammar has those node names, since records arrived later.
Add a fixture with an enum that has a constant-specific body, a record and an @interface.
Assert that vg show <Name> resolves each one to the right file and line, and that methods inside are still captured as methods.
#373 changes the same block's calls / typeRefs, so a quick rebase may be needed if it lands first.
Activity
vibgrate-team commentedon Oct 13, 2026
Lovely, well-scoped first issue, and confirmed on
main. Insrc/engine/queries.tstheJAVAblock (line ~165) captures onlymethod_declaration,constructor_declaration,class_declarationandinterface_declaration. TheC_SHARPblock a few lines below (around lines 220–227) already capturesenum_declarationandrecord_declarationas kindclass, and its comment explains why. That's the pattern to mirror.Steps:
enum_declaration,record_declarationandannotation_type_declarationcaptures toJAVA.defs. Check that the vendored tree-sitter-java grammar has those node names, since records arrived later.@interface.vg show <Name>resolves each one to the right file and line, and that methods inside are still captured as methods.#373 changes the same block's
calls/typeRefs, so a quick rebase may be needed if it lands first.