-
Notifications
You must be signed in to change notification settings - Fork 49
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
Limit the max width of method chain dots #70
Conversation
Generate changelog in
|
@@ -69,7 +79,7 @@ public static Op make( | |||
|
|||
@Override | |||
public void add(DocBuilder builder) { | |||
builder.open(plusIndent(), breakBehaviour(), breakabilityIfLastLevel(), debugName()); | |||
builder.open(this); |
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've also taken the opportunity of passing through OpenOp right into Level rather than unpacking its properties through multiple methods, as it was getting laborious to add new fields.
this.optTag = optTag; | ||
} | ||
@Value.Immutable | ||
public abstract class Break extends Doc implements Op { |
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 converted this to an immutable thinking I wanted to add new fields to it but ended up not doing that.
Still, I prefer this style and it makes it easier to change in the future.
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.
LGTM
} | ||
} | ||
|
||
@Override | ||
public String toString() { |
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.
nice
if (state.column() + thisWidth <= maxWidth) { | ||
return state.withColumn(state.column() + (int) thisWidth) | ||
.withLevelState(this, ImmutableLevelState.of(true)); | ||
Optional<State> oneLine = tryToFitOnOneLine(maxWidth, state); |
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.
Optional<State> oneLine = tryToFitOnOneLine(maxWidth, state); | |
return tryToFitOnOneLine(maxWidth, state) | |
.orElseGet(() -> state.updateAfterLevel(getBreakBehaviour().match(new BreakImpl(commentsHelper, maxWidth, state)); |
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.
yep looks better, tho I kept the orElse bit on two lines as I think it looks cleaner
👍 |
Released 0.3.1 |
After this PR
==COMMIT_MSG==
Limit how far dots may appear in long method chains to 80 chars.
Note that this doesn't currently apply to prefixes (such as
foo.bar().baz().stream()
) because prefixes are also used to group together fully qualified class names and it's a bit trickier to handle that case.Fixes #69.
==COMMIT_MSG==
Possible downsides?