-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Issue #15055: Add input file for record pattern syntax in indentation… #15176
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
Conversation
@mahfouz72 CI is failing |
falling on master because of release notes violation |
e8d4822
to
27548bc
Compare
semaphoreci just stopped with no errors |
...uppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationRecordPattern.java
Outdated
Show resolved
Hide resolved
...uppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationRecordPattern.java
Outdated
Show resolved
Hide resolved
...uppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationRecordPattern.java
Show resolved
Hide resolved
…ndentation check
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.
.
...uppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationRecordPattern.java
Show resolved
Hide resolved
if (obj instanceof //indent:8 exp:8 | ||
ColoredPoint( //indent:0 exp:12 warn | ||
_, //indent:0 exp:12 warn | ||
_, //indent:0 exp:12 warn | ||
_)) {} //indent:0 exp:12 warn | ||
|
||
if (obj instanceof //indent:8 exp:8 | ||
ColoredPoint( //indent:12 exp:12 | ||
_, //indent:12 exp:12 | ||
_, //indent:12 exp:12 | ||
_)) {} //indent:12 exp:12 | ||
|
||
if (obj instanceof ColoredPoint( //indent:8 exp:8 | ||
_, //indent:12 exp:12 | ||
_, //indent:12 exp:12 | ||
_)) {} //indent:12 exp:12 | ||
|
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.
IMO, This is a bit odd I feel like the unnamed patterns should be indented further we can treat it as a RECORD_PATTERN_DEF
child. So I think it should be indented a bit after the pattern. like the pattern is indented a bit after if
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.
Show a snippet of what you think better indentation is (current versus yours).
I don't see an issue here (last example) since this is a wrapping of the previous line and all the _,
are on the same level.
I could see
ColoredPoint( //indent:12 exp:12
_, //indent:12 exp:12
needing to be indented more to:
ColoredPoint( //indent:12 exp:12
_, //indent:16 exp:16
But indentation check has issues with double line wrapping. It doesn't understand nested expressions should be indented a second time and only do them one time.
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.
if (obj instanceof
ColoredPoint( //indent:12 exp:12
_, //indent:16 exp:16
_, //indent:16 exp:16
_)) {} //indent:16 exp:16
I wanted it to be like this so basically a double-line wrapping yes, because it is nested inside the record pattern not the if
.
But indentation check has issues with double line wrapping. It doesn't understand nested expressions should be indented a second time and only do them one time.
Then I think the current behavior is acceptable if we can't achieve a double line wrapping
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 leave it as it is for now.
if (obj instanceof //indent:8 exp:8 | ||
Rectangle( //indent:16 exp:12 warn | ||
ColoredPoint( //indent:16 exp:12 warn | ||
boolean x, //indent:24 exp:12 warn | ||
int y, //indent:16 exp:12 warn | ||
_), //indent:24 exp:12 warn | ||
ColoredPoint(_,_,_) //indent:16 exp:12 warn | ||
) //indent:16 exp:8 warn | ||
) {} //indent:8 exp:8 | ||
|
||
if (obj instanceof //indent:8 exp:8 | ||
Rectangle( //indent:0 exp:12 warn | ||
ColoredPoint( //indent:0 exp:12 warn | ||
boolean x, //indent:8 exp:12 warn | ||
int y, //indent:8 exp:12 warn | ||
_), //indent:8 exp:12 warn | ||
ColoredPoint(_,_,_) //indent:0 exp:12 warn | ||
)) {} //indent:8 exp:12 warn | ||
|
||
if (obj instanceof //indent:8 exp:8 | ||
Rectangle( //indent:12 exp:12 | ||
ColoredPoint( //indent:12 exp:12 | ||
boolean x, //indent:12 exp:12 | ||
int y, //indent:12 exp:12 | ||
_), //indent:12 exp:12 | ||
ColoredPoint(_,_,_) //indent:12 exp:12 | ||
)) {} //indent:12 exp:8 warn |
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.
same here for the record pattern components named or unnamed.
I think there is a conflict here ? ( 8 -> 12) then (12 -> 8)
ColoredPoint(_,_,_) //indent:0 exp:12 warn
)) {} //indent:8 exp:12 warn
ColoredPoint(_,_,_) //indent:12 exp:12
)) {} //indent:8 exp:12 warn ( never satisified)
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.
This needs to be a new issue if it can never be satisfied.
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.
After looking carefully for this example.I think the problem is we have two parens on this line. one paren for the if
and one for the record pattern.
The record pattern paren has to be on indent 12 and the if paren has to be on 8. so putting them on the same level will always produce a violation on one of them.
Sorry, there is no conflict here the check just requires a different indentation for each paren.
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.
If you can never satisfy this so there is no violations then this IS an issue. All violations should be valid and should be solvable to some extent. Indentation is to guide users to correct indentation. It can't be correct if it is always wrong.
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 just thought that if this conflict has a valid reason then this is not an issue.but yes users still face a violation that can't be solved
#15193
...uppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationRecordPattern.java
Show resolved
Hide resolved
...uppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationRecordPattern.java
Show resolved
Hide resolved
I am good to approve after new issue at #15176 (comment) |
closes #15055