Skip to content

Issue #8023: Update grammar for initial record support#8293

Merged
pbludov merged 2 commits intocheckstyle:masterfrom
nrmancuso:initial-record-grammar
Jul 9, 2020
Merged

Issue #8023: Update grammar for initial record support#8293
pbludov merged 2 commits intocheckstyle:masterfrom
nrmancuso:initial-record-grammar

Conversation

@nrmancuso
Copy link
Copy Markdown
Contributor

@nrmancuso nrmancuso commented Jun 1, 2020

Issue #8023: Update grammar for initial record support

TO DO:

Mentors, please feel free to edit this post to add more items in TODO, or reply and I will add them.

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch 10 times, most recently from d77d8dc to 6e12ca7 Compare June 6, 2020 12:20
@nrmancuso
Copy link
Copy Markdown
Contributor Author

nrmancuso commented Jun 11, 2020

I am reducing the minimum coverage for GeneratedJavaRecognizer.java from 0.73 to 0.72. The reason for this is because the code generated by the new grammar rules I have introduced have adequate coverage. There are only two rules that don't have 100% coverage. These are:

recordComponents

image
This amount of coverage is typical for rules that use t:typeSpec[false] , like enumConstantField.

recordDeclaration

image

Other than the default option, the only branch not covered is the false comparison result of the ternary statment on line 818, and the same branch in classDefinition (which is very similar to recordDeclaration) is also not covered:

image

Below is the coverage for all of the rules I've added:

`image
image

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch 2 times, most recently from 0449997 to 4ed9792 Compare June 11, 2020 17:35
@rnveach
Copy link
Copy Markdown
Contributor

rnveach commented Jun 11, 2020

@nmancus1 FYI on how to hit the harder to reach exceptions:

public void testImpossibleExceptions() throws Exception {

@nrmancuso
Copy link
Copy Markdown
Contributor Author

nrmancuso commented Jun 11, 2020

Execution time testing on guava with google_checks.xml (I've omitted the other time outputs and just kept the total):

➜ checkstyle-tester git:(master) ✗ for run in {1..20}; do groovy diff.groovy --localGitRepo /home/nick/IdeaProjects/checkstyle --patchBranch master --patchConfig ../../google_checks.xml --listOfProjects projects-to-test-on.properties --mode single |& grep 'Total time:'; done

[INFO] Total time:  42.857 s
[INFO] Total time:  43.172 s
[INFO] Total time:  42.233 s
[INFO] Total time:  43.812 s
[INFO] Total time:  42.149 s
[INFO] Total time:  44.875 s
[INFO] Total time:  46.218 s
[INFO] Total time:  43.659 s
[INFO] Total time:  45.105 s
[INFO] Total time:  42.515 s
[INFO] Total time:  43.349 s
[INFO] Total time:  45.786 s
[INFO] Total time:  45.326 s
[INFO] Total time:  43.102 s
[INFO] Total time:  43.368 s
[INFO] Total time:  43.545 s
[INFO] Total time:  44.725 s
[INFO] Total time:  44.314 s
[INFO] Total time:  46.607 s
[INFO] Total time:  43.914 s

➜ checkstyle-tester git:(master) ✗ for run in {1..20}; do groovy diff.groovy --localGitRepo /home/nick/IdeaProjects/checkstyle --patchBranch initial-record-grammar --patchConfig ../../google_checks.xml --listOfProjects projects-to-test-on.properties --mode single |& grep 'Total time:'; done

[INFO] Total time:  44.310 s
[INFO] Total time:  43.649 s
[INFO] Total time:  42.931 s
[INFO] Total time:  43.118 s
[INFO] Total time:  44.582 s
[INFO] Total time:  44.762 s
[INFO] Total time:  43.479 s
[INFO] Total time:  43.130 s
[INFO] Total time:  43.646 s
[INFO] Total time:  42.599 s
[INFO] Total time:  42.074 s
[INFO] Total time:  42.578 s
[INFO] Total time:  42.702 s
[INFO] Total time:  42.881 s
[INFO] Total time:  42.860 s
[INFO] Total time:  44.799 s
[INFO] Total time:  45.955 s
[INFO] Total time:  43.048 s
[INFO] Total time:  43.801 s
[INFO] Total time:  43.279 s

Which gives an average time of 44.031s for master, and 43.509s for initial-record-grammar.

@nrmancuso
Copy link
Copy Markdown
Contributor Author

nrmancuso commented Jun 12, 2020

FYI on how to hit the harder to reach exceptions

@rnveach
Unless I'm missing something, these tests are for the lexer only.

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch from 4ed9792 to af2bd54 Compare June 12, 2020 14:37
@nrmancuso nrmancuso force-pushed the initial-record-grammar branch from af2bd54 to 4ea08c6 Compare June 12, 2020 15:16
@nrmancuso
Copy link
Copy Markdown
Contributor Author

nrmancuso commented Jun 12, 2020

With these grammar changes, there has been some additional nondeterminism detected:
image
Sans line numbers:
image

Aside from where nondeterminism existed previously, these are the rules in which it has been introduced:

java.g:443: warning:nondeterminism upon
java.g:443:     k==1:DOT
java.g:443:     k==2:"record"
java.g:443:     between alt 1 and exit branch of block

java.g:951: warning:nondeterminism between alts 1 and 2 of block upon
java.g:951:     k==1:AT
java.g:951:     k==2:RBRACK,IDENT,"record"

java.g:761:9: warning:nondeterminism between alts 1 and 2 of block upon
java.g:761:9:     k==1:AT,"record"
java.g:761:9:     k==2:IDENT,"record"

java.g:1045:31: warning:nondeterminism between alts 1 and 2 of block upon
java.g:1045:31:     k==1:IDENT,"record"
java.g:1045:31:     k==2:LBRACK,DOT,AT

These lines correspond to the identifierStar, declaratorBrackets, enumConstantField, and parameterDeclaration rules, respectively.

@nrmancuso nrmancuso marked this pull request as ready for review June 13, 2020 00:57
@nrmancuso nrmancuso force-pushed the initial-record-grammar branch 3 times, most recently from a6ae552 to 20015f7 Compare June 15, 2020 14:46
@nrmancuso nrmancuso marked this pull request as draft June 15, 2020 14:47
@nrmancuso nrmancuso marked this pull request as ready for review June 16, 2020 12:46
@rnveach
Copy link
Copy Markdown
Contributor

rnveach commented Jun 24, 2020

Can someone post the JLS link for records and how they specify the language?

Also I notice this isn't full record support. Is there another issue defined that will house the full record support?

@nrmancuso
Copy link
Copy Markdown
Contributor Author

Can someone post the JLS link for records and how they specify the language?

See #8023 (comment)

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch 3 times, most recently from 1b9932d to 1d7ea67 Compare June 26, 2020 04:11
Copy link
Copy Markdown
Contributor

@rnveach rnveach left a comment

Choose a reason for hiding this comment

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

Only minor things.

@rnveach rnveach assigned romani and unassigned rnveach Jul 2, 2020
@rnveach
Copy link
Copy Markdown
Contributor

rnveach commented Jul 2, 2020

I think this is ok to merge when CI passes. @romani

Copy link
Copy Markdown
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

minors:

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch from d9dd24d to bef4f03 Compare July 2, 2020 14:29
@nrmancuso nrmancuso requested a review from romani July 7, 2020 02:49
Copy link
Copy Markdown
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

item:

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch from bef4f03 to 7cc4ed5 Compare July 7, 2020 15:18
@romani
Copy link
Copy Markdown
Member

romani commented Jul 8, 2020

there are conflicts, please rebase and prepare for merge.

@nrmancuso nrmancuso force-pushed the initial-record-grammar branch from 7cc4ed5 to 73deaaa Compare July 8, 2020 15:09
@pbludov pbludov merged commit 84f33ea into checkstyle:master Jul 9, 2020
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.

5 participants