-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add Check Support for Java 21 Unnamed Variables & Patterns Syntax: AnnotationOnSameLineCheck #15061
Comments
Show a violation on this line if possible. I am ok to add an input if there is no concern. |
I guess this should be ok this is all technically in the same |
This seems to cover local variables but all examples look to be class/javadoc level related.
To me it seems we need to support this and print a violation. These pattern variables are almost a combination of local variables and field variables. @mahfouz72 Please add all examples to first post. |
done first post is updated |
This should not be a violation. This is a style check, so we should follow logic similar to conceptually/structurally similar code (in record component list in record definitions, constructors definition parameters, method definition parameters). Example:
I am approving for new test case only. |
So you are saying this should be treated similarly to parameters in a method and not as a local variable? |
If this check doesn't place violations on record components, it shouldn't place them on record component patterns. Not only are these constructs conceptually similar, but in the case of a style check (where we care about aesthetics), it is good enough that they look similar. If we are talking about coding checks, then we should probably consider these to be local variables in most cases. |
By |
See https://docs.oracle.com/javase/specs/jls/se21/html/jls-8.html#jls-8.10.1 |
I am good. |
child of #14942
Check documentation: https://checkstyle.org/checks/annotation/annotationonsameline.html#AnnotationOnSameLine
This is not very specific to unnamed patterns. but for patterns in general.
I expect a violation on the annotations on the pattern variable. The annotation should be on the same line as the pattern. We should add
PATTERN_VARIABLE_DEF
in the tokensThe text was updated successfully, but these errors were encountered: