Skip to content

Enhancement: capture Java enums, records, and annotation types as definitions in vg build #372

Done

Description

@vibgrate-team

Context

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

  1. 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)
  2. 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.
  3. 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

Activity

  1. added
    enhancement
    good first issue
    on Oct 6, 2026
  2. vibgrate-team commented on Oct 13, 2026

    @vibgrate-team
    ContributorAuthor

    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:

    1. 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.
    2. Add a fixture with an enum that has a constant-specific body, a record and an @interface.
    3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions