Skip to content

Commit

Permalink
Align closing parentheses of method declaration parameters list
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Sep 15, 2023
1 parent b876c43 commit 44fe2ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ private void firstArgNoPrefix(String first,
private void firstArgOnNewLine(
String first,
int times,
String third) {
String third
) {
}
}
""",
Expand All @@ -122,7 +123,8 @@ private void firstArgNoPrefix(String first,
private void firstArgOnNewLine(
String first,
int times,
String third) {
String third
) {
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,15 @@ public <T> JRightPadded<T> visitRightPadded(@Nullable JRightPadded<T> right, JRi
}
case METHOD_DECLARATION_PARAMETER:
case RECORD_STATE_VECTOR: {
if (elem instanceof J.Empty) {
elem = elem.withPrefix(indentTo(elem.getPrefix(), indent, loc.getAfterLocation()));
after = right.getAfter();
break;
}
JContainer<J> container = getCursor().getParentOrThrow().getValue();
J firstArg = container.getElements().iterator().next();
List<J> elements = container.getElements();
J firstArg = elements.iterator().next();
J lastArg = elements.get(elements.size() - 1);
if (style.getMethodDeclarationParameters().getAlignWhenMultiple()) {
J.MethodDeclaration method = getCursor().firstEnclosing(J.MethodDeclaration.class);
if (method != null) {
Expand All @@ -224,13 +231,13 @@ public <T> JRightPadded<T> visitRightPadded(@Nullable JRightPadded<T> right, JRi
}
getCursor().getParentOrThrow().putMessage("lastIndent", alignTo - style.getContinuationIndent());
elem = visitAndCast(elem, p);
after = indentTo(right.getAfter(), alignTo, loc.getAfterLocation());
after = indentTo(right.getAfter(), t == lastArg ? indent : alignTo, loc.getAfterLocation());
} else {
after = right.getAfter();
}
} else {
elem = visitAndCast(elem, p);
after = indentTo(right.getAfter(), style.getContinuationIndent(), loc.getAfterLocation());
after = indentTo(right.getAfter(), t == lastArg ? indent : style.getContinuationIndent(), loc.getAfterLocation());
}
break;
}
Expand Down

0 comments on commit 44fe2ff

Please sign in to comment.