diff --git a/.idea/dictionaries/Nikolay_Krasko.xml b/.idea/dictionaries/Nikolay_Krasko.xml index 6a3de022080..12359831dfd 100644 --- a/.idea/dictionaries/Nikolay_Krasko.xml +++ b/.idea/dictionaries/Nikolay_Krasko.xml @@ -5,6 +5,7 @@ goto kdoc memoized + multiline redeclarations subclassed subgraph diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java index e0cff74bebf..799df496b4c 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java @@ -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)), diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetLanguageCodeStyleSettingsProvider.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetLanguageCodeStyleSettingsProvider.java index 132d362d364..6a7967be625 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetLanguageCodeStyleSettingsProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetLanguageCodeStyleSettingsProvider.java @@ -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", diff --git a/idea/testData/formatter/DelegationList.after.inv.kt b/idea/testData/formatter/DelegationList.after.inv.kt new file mode 100644 index 00000000000..470995fba5b --- /dev/null +++ b/idea/testData/formatter/DelegationList.after.inv.kt @@ -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 \ No newline at end of file diff --git a/idea/testData/formatter/DelegationList.after.kt b/idea/testData/formatter/DelegationList.after.kt new file mode 100644 index 00000000000..c9134466e8f --- /dev/null +++ b/idea/testData/formatter/DelegationList.after.kt @@ -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 \ No newline at end of file diff --git a/idea/testData/formatter/DelegationList.kt b/idea/testData/formatter/DelegationList.kt new file mode 100644 index 00000000000..9cf8e98cce6 --- /dev/null +++ b/idea/testData/formatter/DelegationList.kt @@ -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 \ No newline at end of file diff --git a/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.inv.kt b/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.inv.kt index 644cd7702a4..a361dce8cbb 100644 --- a/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.inv.kt +++ b/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.inv.kt @@ -11,7 +11,7 @@ object Some3 : -A + A val a = object: A { } @@ -27,7 +27,7 @@ class B { class C { class object: - A { + A { } } diff --git a/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.kt b/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.kt index 979b6a363ab..f95c073f6de 100644 --- a/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.kt +++ b/idea/testData/formatter/SpaceAroundExtendColonInObjects.after.kt @@ -11,7 +11,7 @@ object Some3 : -A + A val a = object :A { } @@ -27,7 +27,7 @@ class B { class C { class object : - A { + A { } } diff --git a/idea/testData/indentationOnNewline/InDelegationListAfterColon.after.inv.kt b/idea/testData/indentationOnNewline/InDelegationListAfterColon.after.inv.kt new file mode 100644 index 00000000000..e6c0fb368f0 --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListAfterColon.after.inv.kt @@ -0,0 +1,5 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +class Simpleclass() : + + diff --git a/idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt b/idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt new file mode 100644 index 00000000000..e6c0fb368f0 --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListAfterColon.after.kt @@ -0,0 +1,5 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +class Simpleclass() : + + diff --git a/idea/testData/indentationOnNewline/InDelegationListAfterColon.kt b/idea/testData/indentationOnNewline/InDelegationListAfterColon.kt new file mode 100644 index 00000000000..842234b3dc5 --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListAfterColon.kt @@ -0,0 +1,4 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +class Simpleclass() : + diff --git a/idea/testData/indentationOnNewline/InDelegationListAfterComma.after.inv.kt b/idea/testData/indentationOnNewline/InDelegationListAfterComma.after.inv.kt new file mode 100644 index 00000000000..bae53c1620b --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListAfterComma.after.inv.kt @@ -0,0 +1,8 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +trait A1 + +class A { + class Simpleclass() : A1, + +} diff --git a/idea/testData/indentationOnNewline/InDelegationListAfterComma.after.kt b/idea/testData/indentationOnNewline/InDelegationListAfterComma.after.kt new file mode 100644 index 00000000000..e5bbca12506 --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListAfterComma.after.kt @@ -0,0 +1,8 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +trait A1 + +class A { + class Simpleclass() : A1, + +} diff --git a/idea/testData/indentationOnNewline/InDelegationListAfterComma.kt b/idea/testData/indentationOnNewline/InDelegationListAfterComma.kt new file mode 100644 index 00000000000..50b850c1e4b --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListAfterComma.kt @@ -0,0 +1,7 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +trait A1 + +class A { + class Simpleclass() : A1, +} diff --git a/idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.inv.kt b/idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.inv.kt new file mode 100644 index 00000000000..5ca4744f35b --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.inv.kt @@ -0,0 +1,8 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +trait A1 + +open class B1 + +class Simpleclass() : B1(), + A1 diff --git a/idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.kt b/idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.kt new file mode 100644 index 00000000000..50494caefad --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListNotEmpty.after.kt @@ -0,0 +1,8 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +trait A1 + +open class B1 + +class Simpleclass() : B1(), + A1 diff --git a/idea/testData/indentationOnNewline/InDelegationListNotEmpty.kt b/idea/testData/indentationOnNewline/InDelegationListNotEmpty.kt new file mode 100644 index 00000000000..d209617cf3e --- /dev/null +++ b/idea/testData/indentationOnNewline/InDelegationListNotEmpty.kt @@ -0,0 +1,7 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +trait A1 + +open class B1 + +class Simpleclass() : B1(), A1 diff --git a/idea/tests/org/jetbrains/jet/formatter/JetFormatterTestGenerated.java b/idea/tests/org/jetbrains/jet/formatter/JetFormatterTestGenerated.java index 213388c9ac4..43633407da3 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetFormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetFormatterTestGenerated.java @@ -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"); diff --git a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java index cb5a97f7c26..c7d05f6ec46 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTestBaseGenerated.java @@ -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");