Fix 'In multiline class declaration the indent before parent's name is destroyed' (KT-3848)

#KT-3848 Fixed
This commit is contained in:
Nikolay Krasko
2014-04-24 21:13:55 +04:00
parent 850987748e
commit cd3aa06a83
19 changed files with 195 additions and 11 deletions
+1
View File
@@ -5,6 +5,7 @@
<w>goto</w>
<w>kdoc</w>
<w>memoized</w>
<w>multiline</w>
<w>redeclarations</w>
<w>subclassed</w>
<w>subgraph</w>
@@ -207,6 +207,10 @@ public class JetBlock extends AbstractBlock {
return NodeAlignmentStrategy.fromTypes(AlignmentStrategy.wrap(
createAlignment(jetCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment())));
}
else if (parentType == DELEGATION_SPECIFIER_LIST) {
return NodeAlignmentStrategy.fromTypes(AlignmentStrategy.wrap(
createAlignment(jetCommonSettings.ALIGN_MULTILINE_EXTENDS_LIST, getAlignment())));
}
else if (parentType == PARENTHESIZED) {
return new NodeAlignmentStrategy() {
Alignment bracketsAlignment = jetCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION ? Alignment.createAlignment() : null;
@@ -313,6 +317,10 @@ public class JetBlock extends AbstractBlock {
.in(DOT_QUALIFIED_EXPRESSION, SAFE_ACCESS_EXPRESSION)
.set(Indent.getContinuationWithoutFirstIndent(true)),
ASTIndentStrategy.forNode("Delegation list")
.in(DELEGATION_SPECIFIER_LIST)
.set(Indent.getContinuationIndent(false)),
ASTIndentStrategy.forNode("Binary expressions")
.in(BINARY_EXPRESSION)
.set(Indent.getContinuationWithoutFirstIndent(false)),
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -152,6 +152,7 @@ public class JetLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSetti
case WRAPPING_AND_BRACES_SETTINGS:
consumer.showStandardOptions(
// "ALIGN_MULTILINE_CHAINED_METHODS",
"ALIGN_MULTILINE_EXTENDS_LIST",
"ALIGN_MULTILINE_PARAMETERS",
"ALIGN_MULTILINE_PARAMETERS_IN_CALLS",
"ALIGN_MULTILINE_METHOD_BRACKETS",
@@ -0,0 +1,26 @@
trait A1
trait A2
trait A3
open class B1
class Simpleclass1() : B1(), A1,
A2, A3
class SimpleClass2() :
B1(), A1,
A2, A3
class Temp {
class SimpleClass3() : B1(), A1,
A2, A3
}
object SimpleObject1 : B1(), A1,
A2, A3
object SimpleObject2 : B1(),
A1,
A2, A3
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
@@ -0,0 +1,26 @@
trait A1
trait A2
trait A3
open class B1
class Simpleclass1() : B1(), A1,
A2, A3
class SimpleClass2() :
B1(), A1,
A2, A3
class Temp {
class SimpleClass3() : B1(), A1,
A2, A3
}
object SimpleObject1 : B1(), A1,
A2, A3
object SimpleObject2 : B1(),
A1,
A2, A3
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
+26
View File
@@ -0,0 +1,26 @@
trait A1
trait A2
trait A3
open class B1
class Simpleclass1() : B1(), A1,
A2, A3
class SimpleClass2() :
B1(), A1,
A2, A3
class Temp {
class SimpleClass3() : B1(), A1,
A2, A3
}
object SimpleObject1: B1(), A1,
A2, A3
object SimpleObject2: B1(),
A1,
A2, A3
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
@@ -11,7 +11,7 @@ object Some3
:
A
A
val a = object: A {
}
@@ -27,7 +27,7 @@ class B {
class C {
class object:
A {
A {
}
}
@@ -11,7 +11,7 @@ object Some3
:
A
A
val a = object :A {
}
@@ -27,7 +27,7 @@ class B {
class C {
class object :
A {
A {
}
}
@@ -0,0 +1,5 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
class Simpleclass() :
<caret>
@@ -0,0 +1,5 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
class Simpleclass() :
<caret>
@@ -0,0 +1,4 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
class Simpleclass() : <caret>
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
trait A1
class A {
class Simpleclass() : A1,
<caret>
}
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
trait A1
class A {
class Simpleclass() : A1,
<caret>
}
@@ -0,0 +1,7 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
trait A1
class A {
class Simpleclass() : A1, <caret>
}
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
trait A1
open class B1
class Simpleclass() : B1(),
<caret>A1
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
trait A1
open class B1
class Simpleclass() : B1(),
<caret>A1
@@ -0,0 +1,7 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
trait A1
open class B1
class Simpleclass() : B1(), <caret>A1
@@ -89,6 +89,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest("idea/testData/formatter/ConsecutiveSafeCallsIndent.after.kt");
}
@TestMetadata("DelegationList.after.kt")
public void testDelegationList() throws Exception {
doTest("idea/testData/formatter/DelegationList.after.kt");
}
@TestMetadata("DoWhileLineBreak.after.kt")
public void testDoWhileLineBreak() throws Exception {
doTest("idea/testData/formatter/DoWhileLineBreak.after.kt");
@@ -457,6 +462,11 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTestInverted("idea/testData/formatter/ColonSpaces.after.inv.kt");
}
@TestMetadata("DelegationList.after.inv.kt")
public void testDelegationList() throws Exception {
doTestInverted("idea/testData/formatter/DelegationList.after.inv.kt");
}
@TestMetadata("DoWhileLineBreak.after.inv.kt")
public void testDoWhileLineBreak() throws Exception {
doTestInverted("idea/testData/formatter/DoWhileLineBreak.after.inv.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("ConsecutiveCallsAfterDot.after.kt")
@@ -126,6 +124,21 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
doNewlineTest("idea/testData/indentationOnNewline/InBinaryExpressionsBeforeCloseParenthesis.after.kt");
}
@TestMetadata("InDelegationListAfterColon.after.kt")
public void testInDelegationListAfterColon() throws Exception {
doNewlineTest("idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt");
}
@TestMetadata("InDelegationListAfterComma.after.kt")
public void testInDelegationListAfterComma() throws Exception {
doNewlineTest("idea/testData/indentationOnNewline/InDelegationListAfterComma.after.kt");
}
@TestMetadata("InDelegationListNotEmpty.after.kt")
public void testInDelegationListNotEmpty() throws Exception {
doNewlineTest("idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.kt");
}
@TestMetadata("InExpressionsParentheses.after.kt")
public void testInExpressionsParentheses() throws Exception {
doNewlineTest("idea/testData/indentationOnNewline/InExpressionsParentheses.after.kt");
@@ -196,9 +209,7 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
@InnerTestClasses({})
public static class InvertedSettings extends AbstractJetTypingIndentationTestBase {
public void testAllFilesPresentInInvertedSettings() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
new File("idea/testData/indentationOnNewline"),
Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), true);
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/indentationOnNewline"), Pattern.compile("^([^\\.]+)\\.after\\.inv\\.kt.*$"), true);
}
@TestMetadata("InBinaryExpressionInMiddle.after.inv.kt")
@@ -216,6 +227,21 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
doNewlineTestWithInvert("idea/testData/indentationOnNewline/InBinaryExpressionsBeforeCloseParenthesis.after.inv.kt");
}
@TestMetadata("InDelegationListAfterColon.after.inv.kt")
public void testInDelegationListAfterColon() throws Exception {
doNewlineTestWithInvert("idea/testData/indentationOnNewline/InDelegationListAfterColon.after.inv.kt");
}
@TestMetadata("InDelegationListAfterComma.after.inv.kt")
public void testInDelegationListAfterComma() throws Exception {
doNewlineTestWithInvert("idea/testData/indentationOnNewline/InDelegationListAfterComma.after.inv.kt");
}
@TestMetadata("InDelegationListNotEmpty.after.inv.kt")
public void testInDelegationListNotEmpty() throws Exception {
doNewlineTestWithInvert("idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.inv.kt");
}
@TestMetadata("InExpressionsParentheses.after.inv.kt")
public void testInExpressionsParentheses() throws Exception {
doNewlineTestWithInvert("idea/testData/indentationOnNewline/InExpressionsParentheses.after.inv.kt");