diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/ASTIndentStrategy.java b/idea/src/org/jetbrains/jet/plugin/formatter/ASTIndentStrategy.java index 7649dbdfefc..21c76a7dff6 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/ASTIndentStrategy.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/ASTIndentStrategy.java @@ -58,12 +58,12 @@ public abstract class ASTIndentStrategy { public static class PositionStrategy extends ASTIndentStrategy { private Indent defaultIndent = Indent.getNoneIndent(); - private List in = new ArrayList(); - private List notIn = new ArrayList(); - private List forElement = new ArrayList(); - private List notForElement = new ArrayList(); + private final List in = new ArrayList(); + private final List notIn = new ArrayList(); + private final List forElement = new ArrayList(); + private final List notForElement = new ArrayList(); - private String debugInfo; + private final String debugInfo; public PositionStrategy(@Nullable String debugInfo) { this.debugInfo = debugInfo; diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java index a24cef48284..8eb4e458289 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java @@ -145,6 +145,10 @@ public class JetBlock extends AbstractBlock { return new ChildAttributes(Indent.getNormalIndent(), null); } + else if (type == JetNodeTypes.TRY) { + // In try - try BLOCK catch BLOCK finally BLOCK + return new ChildAttributes(Indent.getNoneIndent(), null); + } else if (type == JetNodeTypes.DOT_QUALIFIED_EXPRESSION) { return new ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null); } diff --git a/idea/testData/formatter/IndentationOnNewline/AfterCatch.kt b/idea/testData/formatter/IndentationOnNewline/AfterCatch.kt new file mode 100644 index 00000000000..4bf03b726b9 --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterCatch.kt @@ -0,0 +1,6 @@ +fun some(): Int { + try { + } + catch () { + } +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/AfterCatch_after.kt b/idea/testData/formatter/IndentationOnNewline/AfterCatch_after.kt new file mode 100644 index 00000000000..f9a939d1d8d --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterCatch_after.kt @@ -0,0 +1,7 @@ +fun some(): Int { + try { + } + catch () { + } + +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/AfterFinally.kt b/idea/testData/formatter/IndentationOnNewline/AfterFinally.kt new file mode 100644 index 00000000000..e3115b06359 --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterFinally.kt @@ -0,0 +1,7 @@ +fun some(): Int { + try { + } + catch () { + } + finally {} +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/AfterFinally_after.kt b/idea/testData/formatter/IndentationOnNewline/AfterFinally_after.kt new file mode 100644 index 00000000000..4724476b5df --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterFinally_after.kt @@ -0,0 +1,8 @@ +fun some(): Int { + try { + } + catch () { + } + finally {} + +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/AfterTry.kt b/idea/testData/formatter/IndentationOnNewline/AfterTry.kt new file mode 100644 index 00000000000..84ac26984f1 --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterTry.kt @@ -0,0 +1,4 @@ +fun some(): Int { + try { + } +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/AfterTry_after.kt b/idea/testData/formatter/IndentationOnNewline/AfterTry_after.kt new file mode 100644 index 00000000000..5568e88c70c --- /dev/null +++ b/idea/testData/formatter/IndentationOnNewline/AfterTry_after.kt @@ -0,0 +1,5 @@ +fun some(): Int { + try { + } + +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java index 77e785dfce3..8a8f46c6778 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java @@ -29,10 +29,22 @@ import java.io.File; */ public class JetTypingIndentationTest extends LightCodeInsightTestCase { + public void testAfterCatch() { + doFileNewlineTest(); + } + + public void testAfterFinally() { + doFileNewlineTest(); + } + public void testAfterImport() { doFileNewlineTest(); } + public void testAfterTry() { + doFileNewlineTest(); + } + public void testConsecutiveCallsAfterDot() { doFileNewlineTest(); }