Skip to content

Good practice on how to update AST in TokenTypes

Roman Ivanov edited this page Mar 28, 2021 · 9 revisions

Source to be updated: https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/api/TokenTypes.java

AST can be printed by our CLI: https://checkstyle.org/cmdline.html option -t Try to be concise and brief in java code sample, use only compile-able code.

Example of AST for other token: https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_DEF ATTENTION: there should be no wrapping by "(" and ")".

RECORD_DEF -> RECORD_DEF
|--MODIFIERS -> MODIFIERS
|   `--LITERAL_PUBLIC -> public
|--LITERAL_RECORD -> record
|--IDENT -> myRecord
|--LPAREN -> (
|--RECORD_COMPONENTS -> RECORD_COMPONENTS
|--RPAREN -> )
`--OBJBLOCK -> OBJBLOCK
    |--LCURLY -> {
    `--RCURLY -> }

So as you see we show in example not only a token but a context (tokens around) to clearly show user how it might looks in AST. Good example how PR(Pull request) should looks like and how to update code - https://github.com/checkstyle/checkstyle/pull/9378

When you provide PR (Pull Request) please share image/screenshot of how javadoc is rendered. you can generate javadoc by command mvn javadoc:javadoc and then opening related html file in folder target/site/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html Example of page on web site https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html

Please prove in PR description that output that you placed to javadoc is matching content from CLI by sharing print of java file and cli output with AST (abstract syntax tree).

Clone this wiki locally