mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Do not wrap first parameter in expression list
This commit is contained in:
@@ -446,7 +446,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
if (nodeType == JavaElementType.POLYADIC_EXPRESSION) nodeType = JavaElementType.BINARY_EXPRESSION;
|
if (nodeType == JavaElementType.POLYADIC_EXPRESSION) nodeType = JavaElementType.BINARY_EXPRESSION;
|
||||||
|
|
||||||
if (childType == JavaTokenType.LBRACE && nodeType == JavaElementType.ARRAY_INITIALIZER_EXPRESSION) {
|
if (childType == JavaTokenType.LBRACE && nodeType == JavaElementType.ARRAY_INITIALIZER_EXPRESSION) {
|
||||||
final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.ARRAY_INITIALIZER_WRAP), false);
|
final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.ARRAY_INITIALIZER_WRAP), true);
|
||||||
child = processParenthesisBlock(JavaTokenType.LBRACE, JavaTokenType.RBRACE,
|
child = processParenthesisBlock(JavaTokenType.LBRACE, JavaTokenType.RBRACE,
|
||||||
result,
|
result,
|
||||||
child,
|
child,
|
||||||
@@ -454,7 +454,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
mySettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION);
|
mySettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION);
|
||||||
}
|
}
|
||||||
else if (childType == JavaTokenType.LBRACE && nodeType == JavaElementType.ANNOTATION_ARRAY_INITIALIZER) {
|
else if (childType == JavaTokenType.LBRACE && nodeType == JavaElementType.ANNOTATION_ARRAY_INITIALIZER) {
|
||||||
final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.ARRAY_INITIALIZER_WRAP), false);
|
final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.ARRAY_INITIALIZER_WRAP), true);
|
||||||
child = processParenthesisBlock(JavaTokenType.LBRACE, JavaTokenType.RBRACE,
|
child = processParenthesisBlock(JavaTokenType.LBRACE, JavaTokenType.RBRACE,
|
||||||
result,
|
result,
|
||||||
child,
|
child,
|
||||||
@@ -462,7 +462,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
mySettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION);
|
mySettings.ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION);
|
||||||
}
|
}
|
||||||
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.EXPRESSION_LIST) {
|
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.EXPRESSION_LIST) {
|
||||||
final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.CALL_PARAMETERS_WRAP), false);
|
final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.CALL_PARAMETERS_WRAP), true);
|
||||||
if (mySettings.PREFER_PARAMETERS_WRAP && !isInsideMethodCall(myNode.getPsi())) {
|
if (mySettings.PREFER_PARAMETERS_WRAP && !isInsideMethodCall(myNode.getPsi())) {
|
||||||
wrap.ignoreParentWraps();
|
wrap.ignoreParentWraps();
|
||||||
}
|
}
|
||||||
@@ -478,13 +478,13 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
child = processParenthesisBlock(result, child, wrapStrategy, mySettings.ALIGN_MULTILINE_PARAMETERS);
|
child = processParenthesisBlock(result, child, wrapStrategy, mySettings.ALIGN_MULTILINE_PARAMETERS);
|
||||||
}
|
}
|
||||||
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.RESOURCE_LIST) {
|
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.RESOURCE_LIST) {
|
||||||
Wrap wrap = Wrap.createWrap(getWrapType(mySettings.RESOURCE_LIST_WRAP), false);
|
Wrap wrap = Wrap.createWrap(getWrapType(mySettings.RESOURCE_LIST_WRAP), true);
|
||||||
child = processParenthesisBlock(result, child,
|
child = processParenthesisBlock(result, child,
|
||||||
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
|
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
|
||||||
mySettings.ALIGN_MULTILINE_RESOURCES);
|
mySettings.ALIGN_MULTILINE_RESOURCES);
|
||||||
}
|
}
|
||||||
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.ANNOTATION_PARAMETER_LIST) {
|
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.ANNOTATION_PARAMETER_LIST) {
|
||||||
Wrap wrap = Wrap.createWrap(getWrapType(myJavaSettings.ANNOTATION_PARAMETER_WRAP), false);
|
Wrap wrap = Wrap.createWrap(getWrapType(myJavaSettings.ANNOTATION_PARAMETER_WRAP), true);
|
||||||
child = processParenthesisBlock(result, child,
|
child = processParenthesisBlock(result, child,
|
||||||
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
|
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
|
||||||
myJavaSettings.ALIGN_MULTILINE_ANNOTATION_PARAMETERS);
|
myJavaSettings.ALIGN_MULTILINE_ANNOTATION_PARAMETERS);
|
||||||
@@ -560,9 +560,9 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
private Wrap getMethodParametersWrap() {
|
private Wrap getMethodParametersWrap() {
|
||||||
Wrap preferredWrap = getModifierListWrap();
|
Wrap preferredWrap = getModifierListWrap();
|
||||||
if (preferredWrap == null) {
|
if (preferredWrap == null) {
|
||||||
return Wrap.createWrap(getWrapType(mySettings.METHOD_PARAMETERS_WRAP), false);
|
return Wrap.createWrap(getWrapType(mySettings.METHOD_PARAMETERS_WRAP), true);
|
||||||
} else {
|
} else {
|
||||||
return Wrap.createChildWrap(preferredWrap, getWrapType(mySettings.METHOD_PARAMETERS_WRAP), false);
|
return Wrap.createChildWrap(preferredWrap, getWrapType(mySettings.METHOD_PARAMETERS_WRAP), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,6 +840,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
ASTNode prev = child;
|
ASTNode prev = child;
|
||||||
boolean afterAnonymousClass = false;
|
boolean afterAnonymousClass = false;
|
||||||
final boolean enforceIndent = shouldEnforceIndentToChildren();
|
final boolean enforceIndent = shouldEnforceIndentToChildren();
|
||||||
|
boolean isFirstParam = true;
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
isAfterIncomplete = isAfterIncomplete || child.getElementType() == TokenType.ERROR_ELEMENT ||
|
isAfterIncomplete = isAfterIncomplete || child.getElementType() == TokenType.ERROR_ELEMENT ||
|
||||||
child.getElementType() == JavaElementType.EMPTY_EXPRESSION;
|
child.getElementType() == JavaElementType.EMPTY_EXPRESSION;
|
||||||
@@ -859,7 +860,11 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
|||||||
final IElementType elementType = child.getElementType();
|
final IElementType elementType = child.getElementType();
|
||||||
Indent indentToUse = enforceIndent ? internalIndentEnforcedToChildren : internalIndent;
|
Indent indentToUse = enforceIndent ? internalIndentEnforcedToChildren : internalIndent;
|
||||||
AlignmentStrategy alignmentStrategyToUse = canUseAnonymousClassAlignment(child) ? anonymousClassStrategy : alignmentStrategy;
|
AlignmentStrategy alignmentStrategyToUse = canUseAnonymousClassAlignment(child) ? anonymousClassStrategy : alignmentStrategy;
|
||||||
processChild(result, child, alignmentStrategyToUse.getAlignment(elementType), wrappingStrategy.getWrap(elementType), indentToUse);
|
|
||||||
|
processChild(result, child, alignmentStrategyToUse.getAlignment(elementType),
|
||||||
|
isFirstParam ? Wrap.createWrap(WrapType.NONE, true) : wrappingStrategy.getWrap(elementType), indentToUse);
|
||||||
|
isFirstParam = false;
|
||||||
|
|
||||||
if (to == null) {//process only one statement
|
if (to == null) {//process only one statement
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
public class BrokenAlignment {
|
public class BrokenAlignment {
|
||||||
|
|
||||||
public BrokenAlignment(String errorMessage) {
|
public BrokenAlignment(String errorMessage) {
|
||||||
if (StringUtils.contains(<caret>errorMessage,
|
if (StringUtils.contains(errorMessage, "'UK_ACCOUNT_USERNAME'")
|
||||||
"'UK_ACCOUNT_USERNAME'")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ import com.intellij.psi.JavaCodeFragmentFactory;
|
|||||||
import com.intellij.psi.JavaPsiFacade;
|
import com.intellij.psi.JavaPsiFacade;
|
||||||
import com.intellij.psi.PsiCodeFragment;
|
import com.intellij.psi.PsiCodeFragment;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.codeStyle.*;
|
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||||
|
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||||
import com.intellij.util.IncorrectOperationException;
|
import com.intellij.util.IncorrectOperationException;
|
||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
|
|
||||||
@@ -949,14 +952,13 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
|||||||
public void testFirstArgumentWrapping() throws Exception {
|
public void testFirstArgumentWrapping() throws Exception {
|
||||||
getSettings().RIGHT_MARGIN = 20;
|
getSettings().RIGHT_MARGIN = 20;
|
||||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||||
doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1);" + " }\n" + "}",
|
doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1);" + " }\n" + "}",
|
||||||
"class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(\n" + " 1);\n" + " }\n" + "}");
|
"class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1);\n" + " }\n" + "}");
|
||||||
|
|
||||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
||||||
doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1,2);" + " }\n" + "}", "class Foo {\n" +
|
doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1,2);" + " }\n" + "}", "class Foo {\n" +
|
||||||
" void foo() {\n" +
|
" void foo() {\n" +
|
||||||
" fooFooFooFoo(\n" +
|
" fooFooFooFoo(1,\n" +
|
||||||
" 1,\n" +
|
|
||||||
" 2);\n" +
|
" 2);\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}");
|
"}");
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
|||||||
"class Foo {\n" +
|
"class Foo {\n" +
|
||||||
"}",
|
"}",
|
||||||
|
|
||||||
"@AttributeOverrides({\n" +
|
"@AttributeOverrides({@AttributeOverride(name = \"id\", column = @Column(name = \"recovery_id\")),\n" +
|
||||||
" @AttributeOverride(name = \"id\", column = @Column(name = \"recovery_id\")),\n" +
|
|
||||||
" @AttributeOverride(name = \"transactionReference\", column = @Column(name = \"deal_reference\")),\n" +
|
" @AttributeOverride(name = \"transactionReference\", column = @Column(name = \"deal_reference\")),\n" +
|
||||||
" @AttributeOverride(name = \"eventDate\", column = @Column(name = \"recovery_date\")),\n" +
|
" @AttributeOverride(name = \"eventDate\", column = @Column(name = \"recovery_date\")),\n" +
|
||||||
" @AttributeOverride(name = \"amount\", column = @Column(name = \"recovery_amount\")),\n" +
|
" @AttributeOverride(name = \"amount\", column = @Column(name = \"recovery_amount\")),\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user