Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update TokenTypes.java to new format of AST print #14516

Closed
romani opened this issue Feb 21, 2024 · 3 comments · Fixed by #14617
Closed

update TokenTypes.java to new format of AST print #14516

romani opened this issue Feb 21, 2024 · 3 comments · Fixed by #14617

Comments

@romani
Copy link
Member

romani commented Feb 21, 2024

We need to update https://checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html to reflect the current printed abstract syntax tree representation.

Example of old style (note the + and lack of ->):

 +--LITERAL_NEW (new)
     |
     +--LITERAL_FLOAT (float)
     +--ARRAY_DECLARATOR ([)
     +--ARRAY_INIT ({)
         |
         +--EXPR
             |
             +--NUM_FLOAT (3.0f)
         +--COMMA (,)
         +--EXPR
             |
             +--NUM_FLOAT (4.0f)
         +--RCURLY (})

Example of new style:

 LITERAL_NEW -> new
  |--IDENT -> ArrayList
  |--TYPE_ARGUMENTS -> TYPE_ARGUMENTS
  |   |--GENERIC_START -> <
  |   `--GENERIC_END -> >
  |--LPAREN -> (
  |--ELIST -> ELIST
  |   `--EXPR -> EXPR
  |       `--NUM_INT -> 50
  `--RPAREN -> )

Example of where we need to update: https://checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PARAMETERS , there might be more, ABSTRACT, STRICTFP, LITERAL_NEW, SINGLE_LINE_COMMENT.

How to generate our AST via command line:

➜  src cat Test.java
public class Test {
    String s = "";
}
➜  src java -jar checkstyle-10.13.0-all.jar -t Test.java | sed 's/->/-\&gt;/g; s/\[[0-9]\+:[0-9]\+\]//g'
COMPILATION_UNIT -&gt; COMPILATION_UNIT 
`--CLASS_DEF -&gt; CLASS_DEF 
    |--MODIFIERS -&gt; MODIFIERS 
    |   `--LITERAL_PUBLIC -&gt; public 
    |--LITERAL_CLASS -&gt; class 
    |--IDENT -&gt; Test 
    `--OBJBLOCK -&gt; OBJBLOCK 
        |--LCURLY -&gt; { 
        |--VARIABLE_DEF -&gt; VARIABLE_DEF 
        |   |--MODIFIERS -&gt; MODIFIERS 
        |   |--TYPE -&gt; TYPE 
        |   |   `--IDENT -&gt; String 
        |   |--IDENT -&gt; s 
        |   |--ASSIGN -&gt; = 
        |   |   `--EXPR -&gt; EXPR 
        |   |       `--STRING_LITERAL -&gt; "" 
        |   `--SEMI -&gt; ; 
        `--RCURLY -&gt; } 

Note that this sed command escapes the > character and removes the line:column numbers for our documentation. Also, please be aware that we may need to update the existing code sample to be a bit more substantial.

For more details about Checkstyle's command line usage, see: https://checkstyle.org/cmdline.html#Command_line_usage

@romani
Copy link
Member Author

romani commented Feb 21, 2024

@SteLeo1602, please help to resolve this issue.

SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 28, 2024
SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 28, 2024
SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 28, 2024
SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 28, 2024
SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 28, 2024
SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 28, 2024
@Coding-Aliens
Copy link
Contributor

Can I work on it?

@romani
Copy link
Member Author

romani commented Feb 28, 2024

@Coding-Aliens, you can , but I recommend you to take more complicated issues. Be aware of two PRs already in flight.

SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 29, 2024
SteLeo1602 added a commit to SteLeo1602/checkstyle that referenced this issue Feb 29, 2024
@github-actions github-actions bot added this to the 10.14.1 milestone Mar 3, 2024
nrmancuso pushed a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
nrmancuso pushed a commit to nrmancuso/checkstyle that referenced this issue Mar 4, 2024
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Mar 6, 2024
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Mar 6, 2024
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Mar 6, 2024
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants