Skip to content
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

Fix: Limit dotted chains for expressions starting with complex expression #71

Merged
merged 3 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-71.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: Limit dotted chains for expressions starting with constructor.
links:
- https://github.com/palantir/palantir-java-format/pull/71
Original file line number Diff line number Diff line change
Expand Up @@ -2600,8 +2600,13 @@ void visitDot(ExpressionTree node0) {
scan(getArrayBase(node), null);
token(".");
} else {
builder.open(
plusFour, BreakBehaviours.preferBreakingLastInnerLevel(true), LastLevelBreakability.BREAK_HERE);
builder.open(OpenOp.builder()
.debugName("visitDot")
.plusIndent(plusFour)
.breakBehaviour(BreakBehaviours.preferBreakingLastInnerLevel(true))
.breakabilityIfLastLevel(LastLevelBreakability.BREAK_HERE)
.columnLimitBeforeLastBreak(METHOD_CHAIN_COLUMN_LIMIT)
.build());
scan(getArrayBase(node), null);
builder.breakOp();
needDot = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
public class B21031147 {
{
return new StringBuilder(maxLength).append(seq, 0, truncationLength).append(truncationIndicator).toString();
return new StringBuilder(maxLength)
.append(seq, 0, truncationLength)
.append(truncationIndicator)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class B22488373 {
{
if (enumBindingKeys.contains(bindingKey)
&& (bindingKey.key().type().getKind().equals(DECLARED)
&& !((DeclaredType) bindingKey.key().type()).getTypeArguments().isEmpty())) {}
&& !((DeclaredType) bindingKey.key().type())
.getTypeArguments()
.isEmpty())) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ class M {

void f(int... x) {
M m = null;
((m.identity().identity().identity().identity()).identity().identity().identity().identity())
((m.identity().identity().identity().identity())
.identity()
.identity()
.identity()
.identity())
.identity()
.identity()
.identity()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class PalantirLongMethodChain {
private static void foo() {
new ObjectMapper().registerModule(new Jdk8Module()).readValue(file, TestCases.class).getClient();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class PalantirLongMethodChain {
private static void foo() {
new ObjectMapper()
.registerModule(new Jdk8Module())
.readValue(file, TestCases.class)
.getClient();
}
}