Repository navigation
feat(engine): capture Java enums, records and annotation types - #703
Merged
vibgrate-team merged 1 commit intoNov 26, 2026
Merged
Conversation
The JAVA block only captured methods, constructors, classes and interfaces, so a status enum, a DTO record or a custom annotation had no definition of its own and the methods inside them were indexed as bare top-level names. Capture enum_declaration and record_declaration as 'class', as the C# block does, and annotation_type_declaration as 'interface'. Closes vibgrate#372 Signed-off-by: Noah Khomer <108771853+noahkhomer18@users.noreply.github.com>
Contributor
|
Thanks so much @noahkhomer18 — Java enums, records and annotation types showing up in the engine's output is a really nice step forward, and the fixtures and tests made this a pleasure to review. Merged, and we'd love to see more from you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
The
JAVAblock insrc/engine/queries.tsnow captures enums, records and annotation types, sovg buildgives a status enum, a DTO record or a custom annotation like@Auditedits own definition.enum_declarationandrecord_declarationmap toclass, matching the C# block and its comment (classis the engine's kind for enum-like types).annotation_type_declarationmaps tointerface. An@interfacedeclares a type that other code refers to by name and carries no implementation, which is closer to an interface than to a class, andvibgratehas no separate annotation kind.All three node names exist in the bundled tree-sitter-java grammar, so nothing had to be left out.
A side effect worth knowing: methods declared inside an enum or record were indexed as bare top-level names before, because nothing captured their enclosing type. They are now qualified by it (
labelbecomesStatus.label,distanceSquaredbecomesPoint.distanceSquared), the same way methods inside a class already are.Related issues
Closes #372
Checklist
pnpm testpasses: 596 files, 5923 tests.pnpm lintis clean: 0 errors. The 5 warnings are insrc/code/agent.ts,src/code/vgd-code.test.ts,src/engine/duties.tsandsrc/engine/haile/adapter.ts, none touched here.pnpm typecheckis clean.graph.jsontwice and from a reversed fixture write, and all three are byte-identical.Tests
New fixture
test/fixtures/java-defs/(an enum with a constant-specific method body, a record with a compact constructor and a method, and an@interface) andtest/java-defs.test.ts:every definition with its kind, qualified name, file and line:
graph.jsonbyte-identical across two runs and a reversed write.The first test fails with the
queries.tschange reverted.vg showthrough the built CLI (pnpm build, thenvg buildon a copy of the fixture):packages/test-solutions/java-spring: 232 Java nodes before, 240 after, nothing lost (compared by kind, qualified name and file). The 8 new ones are its records and nested enums:Notes for reviewers
Auditedstarts at line 8, its@Retentionline, not atpublic @interfaceon line 10. The annotations are part of the declaration node, and an annotated class starts at its first annotation in the same way, so I kept it consistent.SUSPENDED'slabel()body (line 11) has no node of its own, before or after this change. It has the same qualified name, file and signature asACTIVE's body, so the two most likely hash to the same node id and only one is kept.public Point { ... }) is acompact_constructor_declaration, which the block does not capture. Happy to add it here or in a follow-up if you'd like it.