Do not guess that options expression list is multiline when options "place new line after ( " or "place on new line )" are on.

This commit is contained in:
Yaroslav Lepenkin
2015-04-21 18:27:16 +03:00
parent 4dc4e97318
commit 436dcdce22
2 changed files with 4 additions and 22 deletions
@@ -927,8 +927,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
PsiExpression[] arguments = ((PsiExpressionList)myNode.getPsi()).getExpressions();
return (JavaFormatterUtil.hasMultilineArguments(arguments) || JavaFormatterUtil.canHaveMultilineArgumentsAfterWrap(arguments, mySettings))
&& (JavaFormatterUtil.isMultilineExceptArguments(arguments) || JavaFormatterUtil.canBeMultilineExceptArgumentsAfterWrap(arguments, mySettings));
return JavaFormatterUtil.hasMultilineArguments(arguments) && JavaFormatterUtil.isMultilineExceptArguments(arguments);
}
private static boolean isAnonymousClass(@Nullable ASTNode node) {
@@ -17,7 +17,9 @@ package com.intellij.psi.formatter.java;
import com.intellij.formatting.WrapType;
import com.intellij.lang.ASTNode;
import com.intellij.psi.*;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiPolyadicExpression;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.tree.IElementType;
@@ -83,20 +85,6 @@ public class JavaFormatterUtil {
return false;
}
public static boolean canHaveMultilineArgumentsAfterWrap(@NotNull PsiExpression[] arguments, @NotNull CommonCodeStyleSettings settings) {
for (PsiExpression argument: arguments) {
ASTNode node = argument.getNode();
if (node instanceof PsiMethodCallExpression) {
if (settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE || settings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE) {
if (((PsiMethodCallExpression)node).getArgumentList().getExpressions().length > 0) return true;
}
}
}
return false;
}
public static boolean isMultilineExceptArguments(@NotNull PsiExpression[] arguments) {
for (PsiExpression argument : arguments) {
ASTNode beforeArgument = argument.getNode().getTreePrev();
@@ -109,11 +97,6 @@ public class JavaFormatterUtil {
return isWhiteSpaceWithLineFeed(afterLastArgument);
}
public static boolean canBeMultilineExceptArgumentsAfterWrap(@NotNull PsiExpression[] arguments, @NotNull CommonCodeStyleSettings settings) {
return arguments.length > 0
&& (settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE || settings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE);
}
private static boolean isWhiteSpaceWithLineFeed(@NotNull ASTNode node) {
return node instanceof PsiWhiteSpace
&& node.textContains('\n');