#2951·ast-grep

outline: Java enum constants are missing from java.yml

Author: michal-michalukCreated Sep 19, 2026Updated Sep 19, 2026

Summary

The bundled Java outline rules have no rule for enum_constant, so an enum's constants never reach the outline.

Evidence

  • Grammar: tree-sitter-java 0.23.5 src/node-types.json defines enum_constant.
  • Schema: schemas/java_rule.json lists enum_constant.
  • Rules: crates/outline/src/default_rules/java.yml has no rule matching it.

Current behaviour (measured on main)

For:

java
enum E { A, B; }

the outline is:

- Enum E

A and B are dropped.

Proposed fix

A member rule scoped to the Java enum item, mirroring how other languages report enum members:

yaml
id: java-enum-constant
language: Java
role: member
parentRuleIds: [java-enum]
symbolType: enumMember
rule:
  all:
    - kind: enum_constant
    - has:
        field: name
        pattern: $NAME
name: $NAME
isPublic: true

I have this prepared with a test; a PR follows.