KEMBAR78
New ANTLR Grammar for Javadoc Comments · Issue #17514 · checkstyle/checkstyle · GitHub
Skip to content

New ANTLR Grammar for Javadoc Comments #17514

@mahfouz72

Description

@mahfouz72

Related to the GSoC '25 project.

This issue will serve as the central discussion for integrating the work completed in my fork. We need to discuss the steps required to merge the new Javadoc grammar and its related changes into the main repository. We also need to make sure that we outline any changes to google style.


Project Final Report: https://mahfouz72.github.io/gsoc-report/2025

Key Changes

  • Implemented a new Javadoc lexer and parser in ANTLR with full coverage of the Javadoc Specification
  • Added a visitor-based AST construction layer to map ANTLR parse trees into Checkstyle’s internal AST.
  • Integrated the new parser into Checkstyle’s APIs.
  • Updated all AbstractJavadocCheck subclasses and Javadoc-related checks to work with the new AST.
  • Added extensive AST tests and regression tests to ensure correctness and stability.

Impact

  • Improves maintainability and long-term stability of Javadoc parsing.
  • Provides a cleaner and more consistent AST structure for checks.
  • Backward compatibility preserved, existing checks continue to work after migration.
  • Expected minor differences in parsing behavior compared to the old parser (verified through regressions).

Testing

  • Unit tests cover the full grammar and AST conversion layer.
  • Regression testing performed on large projects confirmed correctness and identified only expected differences.

Issue includes:


Migration Notes

  1. NonEmptyAtclauseDescriptionCheck

The following token names have been updated to better reflect their purpose:
XXXXX_LITERALXXXXX_BLOCK_TAG.

If your configuration currently uses the old token names:

<module name="Checker">
  <module name="TreeWalker">
    <module name="NonEmptyAtclauseDescription">
      <property name="javadocTokens" value="PARAM_LITERAL,THROWS_LITERAL"/>
    </module>
  </module>
</module>

You should update it to use the new token names:

<module name="Checker">
  <module name="TreeWalker">
    <module name="NonEmptyAtclauseDescription">
      <property name="javadocTokens" value="PARAM_BLOCK_TAG,THROWS_BLOCK_TAG"/>
    </module>
  </module>
</module>
  1. Custom Javadoc Checks

All custom javadoc checks should be reimplemented because the AST structure and token names have changed

Examples:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions