highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

(java) Improve detection of types, including generic and array types

Open hns opened this issue 2 months ago • 0 comments

This improves detection of types in Java variable and method declarations, including support for generic and array types.

Resolves #3678 Resolves #4017 Resolves #4345

Changes

  • The regexes for type name and type parameters for generic types are split so they can be highlighted independently.
  • The regex for type parameters in generic types is improved to support wildcards and bounded types.
  • A regex for array brackets is added to support array types.
  • Regexes for type parameters and array brackets are added to variable and method declarations so they support generic and array types.
  • Like types of variable declarations, return types in methods are highlighted as hljs-type, including the void type.

Checklist

  • [ ] Added markup tests, or they don't apply here because...
  • [ ] Updated the changelog at CHANGES.md

hns avatar Dec 05 '25 11:12 hns