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

Issue #9443: Updated example of AST for TokenTypes.FOR_EACH_CLAUSE #9708

Merged
merged 1 commit into from
Mar 28, 2021
Merged

Issue #9443: Updated example of AST for TokenTypes.FOR_EACH_CLAUSE #9708

merged 1 commit into from
Mar 28, 2021

Conversation

theanmolsharma
Copy link
Contributor

fixes #9443 :

Screenshot 2021-03-23 at 5 22 19 PM

Java Code used to generate AST:

public class MyClass {
    public static void main(String args[]) {
        int[] values = new int[10];
        for (int value : values) {
            doSmth();
        }
    }
}

Generated AST:

CLASS_DEF -> CLASS_DEF [1:0]
|--MODIFIERS -> MODIFIERS [1:0]
|   `--LITERAL_PUBLIC -> public [1:0]
|--LITERAL_CLASS -> class [1:7]
|--IDENT -> MyClass [1:13]
`--OBJBLOCK -> OBJBLOCK [1:21]
    |--LCURLY -> { [1:21]
    |--METHOD_DEF -> METHOD_DEF [2:4]
    |   |--MODIFIERS -> MODIFIERS [2:4]
    |   |   |--LITERAL_PUBLIC -> public [2:4]
    |   |   `--LITERAL_STATIC -> static [2:11]
    |   |--TYPE -> TYPE [2:18]
    |   |   `--LITERAL_VOID -> void [2:18]
    |   |--IDENT -> main [2:23]
    |   |--LPAREN -> ( [2:27]
    |   |--PARAMETERS -> PARAMETERS [2:39]
    |   |   `--PARAMETER_DEF -> PARAMETER_DEF [2:39]
    |   |       |--MODIFIERS -> MODIFIERS [2:39]
    |   |       |--TYPE -> TYPE [2:39]
    |   |       |   `--ARRAY_DECLARATOR -> [ [2:39]
    |   |       |       |--IDENT -> String [2:28]
    |   |       |       `--RBRACK -> ] [2:40]
    |   |       `--IDENT -> args [2:35]
    |   |--RPAREN -> ) [2:41]
    |   `--SLIST -> { [2:43]
    |       |--VARIABLE_DEF -> VARIABLE_DEF [3:11]
    |       |   |--MODIFIERS -> MODIFIERS [3:11]
    |       |   |--TYPE -> TYPE [3:11]
    |       |   |   `--ARRAY_DECLARATOR -> [ [3:11]
    |       |   |       |--LITERAL_INT -> int [3:8]
    |       |   |       `--RBRACK -> ] [3:12]
    |       |   |--IDENT -> values [3:14]
    |       |   `--ASSIGN -> = [3:21]
    |       |       `--EXPR -> EXPR [3:23]
    |       |           `--LITERAL_NEW -> new [3:23]
    |       |               |--LITERAL_INT -> int [3:27]
    |       |               `--ARRAY_DECLARATOR -> [ [3:30]
    |       |                   |--EXPR -> EXPR [3:31]
    |       |                   |   `--NUM_INT -> 10 [3:31]
    |       |                   `--RBRACK -> ] [3:33]
    |       |--SEMI -> ; [3:34]
    |       |--LITERAL_FOR -> for [4:8]
    |       |   |--LPAREN -> ( [4:12]
    |       |   |--FOR_EACH_CLAUSE -> FOR_EACH_CLAUSE [4:13]
    |       |   |   |--VARIABLE_DEF -> VARIABLE_DEF [4:13]
    |       |   |   |   |--MODIFIERS -> MODIFIERS [4:13]
    |       |   |   |   |--TYPE -> TYPE [4:13]
    |       |   |   |   |   `--LITERAL_INT -> int [4:13]
    |       |   |   |   `--IDENT -> value [4:17]
    |       |   |   |--COLON -> : [4:23]
    |       |   |   `--EXPR -> EXPR [4:25]
    |       |   |       `--IDENT -> values [4:25]
    |       |   |--RPAREN -> ) [4:31]
    |       |   `--SLIST -> { [4:33]
    |       |       |--EXPR -> EXPR [5:18]
    |       |       |   `--METHOD_CALL -> ( [5:18]
    |       |       |       |--IDENT -> doSmth [5:12]
    |       |       |       |--ELIST -> ELIST [5:19]
    |       |       |       `--RPAREN -> ) [5:19]
    |       |       |--SEMI -> ; [5:20]
    |       |       `--RCURLY -> } [6:8]
    |       `--RCURLY -> } [7:4]
    `--RCURLY -> } [8:0]

Expected update for JavaDoc:

LITERAL_FOR -> for [4:8]
|--LPAREN -> ( [4:12]
|--FOR_EACH_CLAUSE -> FOR_EACH_CLAUSE [4:13]
|--VARIABLE_DEF -> VARIABLE_DEF [4:13]
|   |--MODIFIERS -> MODIFIERS [4:13]
|   |--TYPE -> TYPE [4:13]
|   |   `--LITERAL_INT -> int [4:13]
|   `--IDENT -> value [4:17]
|--COLON -> : [4:23]
`--EXPR -> EXPR [4:25]
     `--IDENT -> values [4:25]
|--RPAREN -> ) [4:31]
`--SLIST -> { [4:33]
    |--EXPR -> EXPR [5:18]
    |   `--METHOD_CALL -> ( [5:18]
    |       |--IDENT -> doSmth [5:12]
    |       |--ELIST -> ELIST [5:19]
    |       `--RPAREN -> ) [5:19]
    |--SEMI -> ; [5:20]
    `--RCURLY -> } [6:8]

@theanmolsharma
Copy link
Contributor Author

@pbludov @timurt @romani please review this

* |--SEMI (;)
* `--RCURLY (})
*
* --LITERAL_FOR -> for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we discussed before, delete preceding -- and indents

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@romani romani merged commit 63d764c into checkstyle:master Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update example of AST for TokenTypes.FOR_EACH_CLAUSE
3 participants