diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java index d52b7ea66a7..a53a57c8ef4 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java @@ -112,7 +112,21 @@ public class JetBlock extends AbstractBlock { childIndent = Indent.getNormalIndent(); } else if (childParent != null && childParent.getElementType() == JetNodeTypes.DOT_QUALIFIED_EXPRESSION) { - if (childParent.getFirstChildNode() != this) { + if (childParent.getFirstChildNode() != child && childParent.getLastChildNode() != child) { + childIndent = Indent.getContinuationWithoutFirstIndent(false); + } + } + else if (childParent != null && childParent.getElementType() == JetNodeTypes.VALUE_PARAMETER_LIST) { + String childText = child.getText(); + + if (!(childText.equals("(") || childText.equals(")"))) { + childIndent = Indent.getContinuationWithoutFirstIndent(false); + } + } + else if (childParent != null && childParent.getElementType() == JetNodeTypes.TYPE_PARAMETER_LIST) { + String childText = child.getText(); + + if (!(childText.equals("<") || childText.equals(">"))) { childIndent = Indent.getContinuationWithoutFirstIndent(false); } } @@ -157,7 +171,7 @@ public class JetBlock extends AbstractBlock { return new ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null); } - return super.getChildAttributes(newChildIndex); + return new ChildAttributes(Indent.getNoneIndent(), null); } @Override diff --git a/idea/testData/formatter/IndentationOnNewline/AfterImport.after.kt b/idea/testData/formatter/IndentationOnNewline/AfterImport.after.kt new file mode 100644 index 00000000000..66d6d13c67f --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterImport.after.kt @@ -0,0 +1,2 @@ +import java.util.ArrayList + \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/AfterImport.kt b/idea/testData/formatter/IndentationOnNewline/AfterImport.kt new file mode 100644 index 00000000000..47b0a0a6f15 --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterImport.kt @@ -0,0 +1 @@ +import java.util.ArrayList \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/EmptyParameters.after.kt b/idea/testData/formatter/IndentationOnNewline/EmptyParameters.after.kt new file mode 100644 index 00000000000..1bf709254af --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/EmptyParameters.after.kt @@ -0,0 +1,3 @@ +fun testParam( + ) { +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/EmptyParameters.kt b/idea/testData/formatter/IndentationOnNewline/EmptyParameters.kt new file mode 100644 index 00000000000..1bf709254af --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/EmptyParameters.kt @@ -0,0 +1,3 @@ +fun testParam( + ) { +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/NotFirstParameter.after.kt b/idea/testData/formatter/IndentationOnNewline/NotFirstParameter.after.kt new file mode 100644 index 00000000000..7024e7dc4c7 --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/NotFirstParameter.after.kt @@ -0,0 +1,3 @@ +fun testParam(a : String, b : Int, + ) { +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/NotFirstParameter.kt b/idea/testData/formatter/IndentationOnNewline/NotFirstParameter.kt new file mode 100644 index 00000000000..4a3649b5f91 --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/NotFirstParameter.kt @@ -0,0 +1,2 @@ +fun testParam(a : String, b : Int,) { +} \ No newline at end of file diff --git a/idea/testData/formatter/Parameters.kt b/idea/testData/formatter/Parameters.kt new file mode 100644 index 00000000000..a9decafd29c --- /dev/null +++ b/idea/testData/formatter/Parameters.kt @@ -0,0 +1,6 @@ +fun some( +a: Int, +b: String, c: Int, +d: String, e: Int +) { +} \ No newline at end of file diff --git a/idea/testData/formatter/Parameters_after.kt b/idea/testData/formatter/Parameters_after.kt new file mode 100644 index 00000000000..81446e03a80 --- /dev/null +++ b/idea/testData/formatter/Parameters_after.kt @@ -0,0 +1,6 @@ +fun some( + a: Int, + b: String, c: Int, + d: String, e: Int +) { +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java b/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java index 5710cb4afbe..3903e21a68b 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetFormatterTest.java @@ -24,6 +24,10 @@ public class JetFormatterTest extends AbstractJetFormatterTest { doTest(); } + public void testParameters() throws Exception { + doTest(); + } + public void testWhen() throws Exception { doTest(); } diff --git a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java index cedef07d1c2..5847dc089f6 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java @@ -10,6 +10,10 @@ import java.io.File; */ public class JetTypingIndentationTest extends LightCodeInsightTestCase { + public void testAfterImport() { + doFileNewlineTest(); + } + public void testConsecutiveCallsAfterDot() { doFileNewlineTest(); }