-
Notifications
You must be signed in to change notification settings - Fork 337
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 test case to illustrate issue with unsolicited indentation. #4548
base: main
Are you sure you want to change the base?
Conversation
"custom style", | ||
null, | ||
emptySet(), | ||
singletonList( |
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.
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 the pointer! I expected that not defining a TabsAndIndentsStyle
in the first place would leave every indent as it is but apparently not. When I set the 4th parameter continuationIndent
to
4
the test works, but then every continuation is indented by a fixed value which is not what I wantnull
the apparent default value of8
is used0
there is no indentation at all-1
the token is lifted to the line before-2
or less the original indentation is kept.
So, with some configuration, namely setting continuationIndent
to -2
it can be done already. Unfortunately this behavior is not documented at all and I worry that it will be "fixed" in the future, so I modified my test to confirm it. Please merge it in and do consider adding javadoc to at least continuationIndent
.
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.
@timtebeek is currently unavailable until Tuesday, Let's wait for his response on whether this is expected behavior and if it is we can merge the PR as regression test 👍
Adding something like this to the @Override
public <T> JLeftPadded<T> visitLeftPadded(@Nullable JLeftPadded<T> left, JLeftPadded.Location loc, P p) {
if (getCursor().getNearestMessage("stop") != null) {
return left;
}
return super.visitLeftPadded(left, loc, p);
} Background: While the stopping mechanism works, it short-circuits any calls to |
What's changed?
This PR adds a test to illustrate a bug.
What's your motivation?
I want to enforce a custom order of imports on new PRs through a custom style.
As I report in "observation 2" of #4165 custom styles also change indentation. I don't think they should do that.
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
I've marked this PR ready for review in he hope of triggering a build, but it seems a manual approval is necessary.
I won't be available to work on a fix.
Checklist