mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
[Java. Code Formatting] Use united range for the creating dependent spaces after '(' for method declarations
IDEA-165216 GitOrigin-RevId: 2e6e426364f2533eee9693d557fa97f99e1d8282
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5813964716
commit
cf75eec6ff
@@ -1287,7 +1287,7 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
|
||||
private void createParenthSpaceInMethodParameters(@NotNull PsiParameterList list, boolean shouldUseDependentSpacing) {
|
||||
if (shouldUseDependentSpacing && list.getParametersCount() > 1) {
|
||||
createSpaceWithLinefeedIfListWrapped(list.getParameters(), mySettings.SPACE_WITHIN_METHOD_PARENTHESES);
|
||||
createSpaceWithLinefeedIfListWrapped(list.getParameters(), mySettings.SPACE_WITHIN_METHOD_PARENTHESES, true);
|
||||
} else {
|
||||
createParenthSpace(shouldUseDependentSpacing, mySettings.SPACE_WITHIN_METHOD_PARENTHESES);
|
||||
}
|
||||
@@ -1380,7 +1380,7 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
else if (myRole2 == ChildRole.RPARENTH) {
|
||||
boolean space = myRole1 == ChildRole.COMMA || mySettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES;
|
||||
if (mySettings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE && list.getExpressionCount() > 1) {
|
||||
createSpaceWithLinefeedIfListWrapped(list.getExpressions(), space);
|
||||
createSpaceWithLinefeedIfListWrapped(list.getExpressions(), space, false);
|
||||
return;
|
||||
}
|
||||
createSpaceInCode(space);
|
||||
@@ -1388,7 +1388,7 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
else if (myRole1 == ChildRole.LPARENTH) {
|
||||
boolean space = mySettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES;
|
||||
if (mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE && list.getExpressionCount() > 1) {
|
||||
createSpaceWithLinefeedIfListWrapped(list.getExpressions(), space);
|
||||
createSpaceWithLinefeedIfListWrapped(list.getExpressions(), space, false);
|
||||
return;
|
||||
}
|
||||
createSpaceInCode(space);
|
||||
@@ -1411,19 +1411,25 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
private void createSpaceWithLinefeedIfListWrapped(PsiElement @NotNull[] psiElementList, boolean space) {
|
||||
private void createSpaceWithLinefeedIfListWrapped(PsiElement @NotNull[] psiElementList, boolean space, boolean shouldCreateSingleRange) {
|
||||
int length = psiElementList.length;
|
||||
assert length > 1;
|
||||
|
||||
List<TextRange> ranges = new ArrayList<>();
|
||||
for (int i = 0; i < length - 1; i++) {
|
||||
int startOffset = psiElementList[i].getTextRange().getEndOffset();
|
||||
int endOffset = psiElementList[i + 1].getTextRange().getStartOffset();
|
||||
ranges.add(new TextRange(startOffset, endOffset));
|
||||
}
|
||||
|
||||
int spaces = space ? 1 : 0;
|
||||
myResult = Spacing.createDependentLFSpacing(spaces, spaces, ranges, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
|
||||
if (shouldCreateSingleRange) {
|
||||
int startOffset = psiElementList[0].getTextRange().getStartOffset();
|
||||
int endOffset = psiElementList[length - 1].getTextRange().getEndOffset();
|
||||
myResult = Spacing.createDependentLFSpacing(spaces, spaces, new TextRange(startOffset, endOffset), mySettings.KEEP_LINE_BREAKS,
|
||||
mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
} else {
|
||||
List<TextRange> ranges = new ArrayList<>();
|
||||
for (int i = 0; i < length - 1; i++) {
|
||||
int startOffset = psiElementList[i].getTextRange().getEndOffset();
|
||||
int endOffset = psiElementList[i + 1].getTextRange().getStartOffset();
|
||||
ranges.add(new TextRange(startOffset, endOffset));
|
||||
}
|
||||
myResult = Spacing.createDependentLFSpacing(spaces, spaces, ranges, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user