Fix error alignment for binary expression parts
This commit is contained in:
@@ -67,7 +67,7 @@ public class JetBlock extends AbstractBlock {
|
||||
|
||||
public JetBlock(
|
||||
@NotNull ASTNode node,
|
||||
NodeAlignmentStrategy alignmentStrategy,
|
||||
@NotNull NodeAlignmentStrategy alignmentStrategy,
|
||||
Indent indent,
|
||||
Wrap wrap,
|
||||
CodeStyleSettings settings,
|
||||
@@ -233,6 +233,10 @@ public class JetBlock extends AbstractBlock {
|
||||
else if (parentType == WHEN) {
|
||||
return getAlignmentForCaseBranch(jetSettings.ALIGN_IN_COLUMNS_CASE_BRANCH);
|
||||
}
|
||||
else if (parentType == WHEN_ENTRY) {
|
||||
// Propagate when alignment for ->
|
||||
return myAlignmentStrategy;
|
||||
}
|
||||
else if (BINARY_EXPRESSIONS.contains(parentType) && ALIGN_FOR_BINARY_OPERATIONS.contains(getOperationType(getNode()))) {
|
||||
return NodeAlignmentStrategy.fromTypes(AlignmentStrategy.wrap(
|
||||
createAlignment(jetCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment())));
|
||||
@@ -264,7 +268,7 @@ public class JetBlock extends AbstractBlock {
|
||||
};
|
||||
}
|
||||
|
||||
return myAlignmentStrategy;
|
||||
return NodeAlignmentStrategy.getNullStrategy();
|
||||
}
|
||||
|
||||
private static NodeAlignmentStrategy getAlignmentForChildInParenthesis(
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
fun some(f: (String) -> Unit) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
3 + object {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
2 ?: some {
|
||||
s ->
|
||||
val a = 12
|
||||
}
|
||||
}
|
||||
|
||||
// SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION
|
||||
@@ -0,0 +1,16 @@
|
||||
fun some(f: (String) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
3 + object {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
2 ?: some {
|
||||
s ->
|
||||
val a = 12
|
||||
}
|
||||
}
|
||||
|
||||
// SET_TRUE: ALIGN_MULTILINE_BINARY_OPERATION
|
||||
@@ -44,6 +44,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
||||
doTest("idea/testData/formatter/ArrayAccess.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("BinaryExpressionAlignmentSpread.after.kt")
|
||||
public void testBinaryExpressionAlignmentSpread() throws Exception {
|
||||
doTest("idea/testData/formatter/BinaryExpressionAlignmentSpread.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("BinaryExpressions.after.kt")
|
||||
public void testBinaryExpressions() throws Exception {
|
||||
doTest("idea/testData/formatter/BinaryExpressions.after.kt");
|
||||
|
||||
@@ -61,9 +61,7 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDirectSettings() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
|
||||
new File("idea/testData/indentationOnNewline"),
|
||||
Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), true);
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/indentationOnNewline"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("AssignmentAfterEq.after.kt")
|
||||
|
||||
Reference in New Issue
Block a user