tree-sitter-java icon indicating copy to clipboard operation
tree-sitter-java copied to clipboard

Various fixes for parsing type use annotations

Open theawless opened this issue 7 months ago • 3 comments

Fix type use annotations before spread parameter

Closes https://github.com/tree-sitter/tree-sitter-java/issues/205

The original fix was here https://github.com/tree-sitter/tree-sitter-java/pull/195/commits/0d79d9fe934a5f159e3136c64388c5b94f750a0a but there's a typo in that. Java doesn't allow annotations after the ellipsis at all. The original issue https://github.com/tree-sitter/tree-sitter-java/issues/184 as well as the minimal sample found by the maintainer https://github.com/tree-sitter/tree-sitter-java/issues/184#issuecomment-2558188511 is for annotations before the ellipsis.

Fix type use annotations in catch types

Closes https://github.com/tree-sitter/tree-sitter-java/issues/208

According to the spec https://docs.oracle.com/javase/specs/jls/se24/html/jls-14.html#jls-CatchType, catch types can be annotated. Note that modifiers and _type can both accept annotations, but I have maintained the existing behaviour - by parsing annotations as part of the modifiers for the first type.

theawless avatar Jun 05 '25 20:06 theawless