Skip to content

Update JavadocCommentsTokenTypes.java to new format of AST print #17882

@mahfouz72

Description

@mahfouz72

Continuation of #14631

We need to update the Javadoc of each token in JavadocCommentsTokenTypes.java to include an example of the new AST print format generated by the latest Checkstyle snapshot.

Each update should document how the token appears in the Javadoc AST, providing both an example input and its corresponding tree structure.


Example Task: PARAM_BLOCK_TAG

Steps to fix

  1. Build the snapshot version of Checkstyle

    Generate the latest snapshot JAR by following the steps in
    How to generate all binaries and -all.jar too.

  2. Generate the AST for the example

    Example input (src/Test.java):

    * @param value The parameter of method.

    Command to generate the Javadoc AST:

    Windows (PowerShell):

    java -jar checkstyle-12.0.0-SNAPSHOT-all.jar -j src/Test.java | ForEach-Object { $_ -replace '\[[0-9]+:[0-9]+\]', '' }

    Linux/macOS:

    java -jar checkstyle-12.0.0-SNAPSHOT-all.jar -j src/Test.java | sed "s/\[[0-9]\+:[0-9]\+\]//g"

    Output:

    JAVADOC_CONTENT -> JAVADOC_CONTENT 
    |--LEADING_ASTERISK -> * 
    |--TEXT ->   
    `--JAVADOC_BLOCK_TAG -> JAVADOC_BLOCK_TAG 
        `--PARAM_BLOCK_TAG -> PARAM_BLOCK_TAG 
            |--AT_SIGN -> @ 
            |--TAG_NAME -> param 
            |--TEXT ->   
            |--PARAMETER_NAME -> value 
            `--DESCRIPTION -> DESCRIPTION 
                `--TEXT ->  The parameter of method
    
  3. Update Javadoc for PARAM_BLOCK_TAG

    Example update:

    /**
     * {@code @param} Javadoc block tag.
     *
     * <p>Such Javadoc tag can have two children:</p>
     * <ol>
     *   <li>{@link #PARAMETER_NAME}</li>
     *   <li>{@link #DESCRIPTION}</li>
     * </ol>
     *
     * <p><b>Example:</b></p>
     * <pre>{@code * @param value The parameter of method.}</pre>
     *
     * <b>Tree:</b>
     * <pre>{@code
     * JAVADOC_CONTENT -> JAVADOC_CONTENT 
     * |--LEADING_ASTERISK -> * 
     * |--TEXT ->   
     * `--JAVADOC_BLOCK_TAG -> JAVADOC_BLOCK_TAG 
     *     `--PARAM_BLOCK_TAG -> PARAM_BLOCK_TAG 
     *         |--AT_SIGN -> @ 
     *         |--TAG_NAME -> param 
     *         |--TEXT ->   
     *         |--PARAMETER_NAME -> value 
     *         `--DESCRIPTION -> DESCRIPTION 
     *             `--TEXT ->  The parameter of method
     * }</pre>
     *
     * @see #JAVADOC_BLOCK_TAG
     */
    public static final int PARAM_BLOCK_TAG = JavadocCommentsLexer.PARAM_BLOCK_TAG;

Notes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions