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 #3238: Java 8 Grammar: annotations on arrays and varargs #7407
Conversation
We should expand regression on more than 1 check to ensure none are broken. I recommend all checks, separated into multiple reports to make it easier. |
src/main/resources/com/puppycrawl/tools/checkstyle/grammar/java.g
Outdated
Show resolved
Hide resolved
@@ -386,8 +394,8 @@ builtInTypeSpec[boolean addImagNode] | |||
// A type name. which is either a (possibly qualified and parameterized) | |||
// class name or a primitive (builtin) type | |||
type | |||
: classOrInterfaceType[false] | |||
| builtInType | |||
: ({LA(1) == AT}? annotations | ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: type
is only used in newExpression
reference: in the spec, PrimitiveType
allows an annotation (similar to ClassOrInterfaceTypeToInstantiate
)
PrimitiveType:
{Annotation} NumericType
{Annotation} boolean
but while checkstyle's classOrInterfaceType
allows annotations, builtInType
by itself doesn't.
My thinking was to allow the annotation here in type
for either case, rather than update builtInType
which is used in several other places, so hoping to minimize changes.
@@ -256,6 +256,14 @@ typeSpec[boolean addImagNode] | |||
| builtInTypeSpec[addImagNode] | |||
; | |||
|
|||
// A type specification for a variable length parameter is a type name with | |||
// possible brackets afterwards that can end with an annotation. | |||
variableLengthParameterTypeSpec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference: LastFormalParameter
which allows zero or more Annotation
just before the ...
0122845
to
f7f9af5
Compare
I've updated the PR description with links to regression reports trying to test all checks, almost all using the default configuration. So far I have only seen differences for files that fail to parse on master because of array/vararg annotations -- they have added violations in the patch branch, which I think is what we'd want to see. Let me know if there are other reports we should run and I will be happy to do it! |
From http://esilkensen.github.io/checkstyle-tester/3238-modifiers-whitespace/guava28/index.html There is a nuance with NoWhitespaceBefore: For |
Ah yes, nice catch, will look into it |
Same for http://esilkensen.github.io/checkstyle-tester/3238-modifiers-whitespace/openjdk10/index.html#A3
This is strange, the doc says
|
@pbludov for What do you think about
|
f7f9af5
to
e768767
Compare
src/main/resources/com/puppycrawl/tools/checkstyle/grammar/java.g
Outdated
Show resolved
Hide resolved
e768767
to
b986a1b
Compare
Updated the PR description with new regression reports using the latest code |
src/test/resources/com/puppycrawl/tools/checkstyle/grammar/InputRegressionJava8Class1Ast.txt
Outdated
Show resolved
Hide resolved
b986a1b
to
5150e7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments @pbludov - I will be happy to run regression reports again if this looks good, or else continue iterating on the implementation
src/test/resources/com/puppycrawl/tools/checkstyle/grammar/InputRegressionJava8Class1Ast.txt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok to merge. Regression with NoWhitespaceBefore can be fixed in separate issue.
@rnveach please do second review
src/test/resources/com/puppycrawl/tools/checkstyle/grammar/InputRegressionJava8Class1Ast.txt
Outdated
Show resolved
Hide resolved
@esilkensen @pbludov There is alot of review comments that are still open and not clicked as resolved. Are they all completed? |
Done. I marked my comments as resolved. |
src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheck.java
Outdated
Show resolved
Hide resolved
746b70c
to
d9df42d
Compare
I think the Travis failures are connectivity issues / unrelated to the changes in this PR |
Sounds good, I will run the regression tonight. |
New regression report: http://esilkensen.github.io/checkstyle-tester/3238-errors/index.html <module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="haltOnException" value="false"/>
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>
<module name="TreeWalker">
<module name="FinalLocalVariable">
<property name="severity" value="ignore"/>
</module>
</module>
</module> I think this report shows what we want?
|
Yes, this is a sad side effect, and the main reason these exceptions are suppressed in the default regression config.
I agree. Exceptions going away and no new ones being generated. This was the main focus of this type of report. |
@romani This is a big change to antlr, so please finalize review. |
Hi @romani, just checking in on this PR, if you get a chance to review, let me know if there’s anything I can do :) |
d9df42d
to
cfc4404
Compare
@esilkensen , please pull latest code of contribution repo, reports now are good at mobile browsers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
items:
src/test/resources/com/puppycrawl/tools/checkstyle/grammar/InputRegressionJava8Class1Ast.txt
Outdated
Show resolved
Hide resolved
cfc4404
to
d8882be
Compare
@esilkensen , thanks a lot for such big update and sorry for delay in review. ATTENTION: I rebased and pushed new commit that will use contribution repo (special) with latest guava. We will not merge this commit to master, we just need to know that all working. related PR: checkstyle/contribution#444 that will be merged after this PR. sevntu Checks looks like ok with such modification (tests are passed).
|
wercker is failed at |
should be fixed by checkstyle/contribution@35d455d |
d8882be
to
3b749ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove first commit .... CI all green, so we a good to go further.
minor update:
src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheck.java
Outdated
Show resolved
Hide resolved
3b749ba
to
5419e22
Compare
Just notes of my review to show AST tree of new items:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to merge ones CI pass (we should merge PR in contribution too)
@esilkensen , thanks a lot for your work on this.
This PR adds support for parsing annotations on arrays and varargs, with the goal of resolving:
new
array expressionsIf this looks like a reasonable approach, I would be happy to try and split it up into separate PR's addressing arrays and varargs separately if that would be better.
Since the changes are relatively small (and kind of overlapping? if thinking of varargs as a kind of array), I thought I would open the PR as it is now for initial feedback.
Regression Reports
Ran on all the projects-to-test-on.properties, also including the latest version of Guava. The only differences in the reports should be new violations for files that previously failed to parse.