outline: Java annotation types and elements are missing from java.yml
Author: michal-michalukCreated Sep 19, 2026Updated Sep 19, 2026
Summary
Java annotation declarations produce no outline elements at all: neither the @interface type (annotation_type_declaration) nor its elements (annotation_type_element_declaration).
Evidence
- Grammar:
tree-sitter-java0.23.5src/node-types.jsondefines bothannotation_type_declarationandannotation_type_element_declaration. - Schema:
schemas/java_rule.jsonlists both kinds. - Rules:
crates/outline/src/default_rules/java.ymlhas no rule for either.
Current behaviour (measured on main)
For:
public @interface A {
String value();
int count() default 0;
}the outline is empty - the declaration produces no item and no members.
Proposed fix
Two rules that ship together, because the element rule is scoped to the annotation type item:
id: java-annotation-type
language: Java
role: item
symbolType: interface
rule:
all:
- kind: annotation_type_declaration
- has:
field: name
pattern: $NAME
name: $NAME
isExported:
has:
kind: modifiers
has:
pattern: public
---
id: java-annotation-element
language: Java
role: member
parentRuleIds: [java-annotation-type]
symbolType: method
rule:
all:
- kind: annotation_type_element_declaration
- has:
field: name
pattern: $NAME
name: $NAME
isPublic: truesymbolType: interface for the type mirrors how other languages map their annotation/decorator declarations; method for the elements mirrors how annotation-type members read as callables. Happy to adjust either mapping if you prefer a different one.
I have this prepared with a test; a PR follows.
Source: ast-grep/ast-grep