From 3ef146e34b782b1afe0267c79ff1ebf44b09f8f8 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Fri, 13 Oct 2017 13:28:21 +0300 Subject: [PATCH] Fix lost indent in block statement IDEA-179073 JavaLikeIndentProvider indent miss --- .../psi/formatter/java/JavaEnterActionTest.java | 14 ++++++++++++++ .../lineIndent/JavaLikeLangLineIndentProvider.java | 3 +++ 2 files changed, 17 insertions(+) diff --git a/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaEnterActionTest.java b/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaEnterActionTest.java index f40164d03d7d..925ba007c869 100644 --- a/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaEnterActionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaEnterActionTest.java @@ -234,4 +234,18 @@ public class JavaEnterActionTest extends AbstractEnterActionTestCase { "\t\t\t\n" + ") {}"); } + + public void testIdea179073() throws IOException { + doTextTest("java", + "ArrayList strings = new ArrayList<>();\n" + + " strings.stream()\n" + + " .forEach((e) -> {\n" + + " });", + + "ArrayList strings = new ArrayList<>();\n" + + " strings.stream()\n" + + " .forEach((e) -> {\n" + + " \n" + + " });"); + } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java index 676ade4cb5c1..09f7632ce08b 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java @@ -212,12 +212,15 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid } else if (position.isAt(RightParenthesis)) { position.beforeParentheses(LeftParenthesis, RightParenthesis); + continue; } else if (position.isAt(BlockClosingBrace)) { position.beforeParentheses(BlockOpeningBrace, BlockClosingBrace); + continue; } else if (position.isAt(ArrayClosingBracket)) { position.beforeParentheses(ArrayOpeningBracket, ArrayClosingBracket); + continue; } else if (position.isAtAnyOf(Semicolon, BlockOpeningBrace,