From 5ac866ba3c239c9bc3e5ea338b443df332c09297 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 11 May 2012 18:22:27 +0400 Subject: [PATCH] KT-1912 Formatter: smart indent doesn't work in a function literal #KT-1099 fixed #KT-1912 fixed --- .../org/jetbrains/jet/plugin/formatter/JetBlock.java | 3 ++- .../formatter/IndentationOnNewline/FunctionBlock.kt | 10 +++------- .../IndentationOnNewline/FunctionBlock_after.kt | 8 ++------ .../jet/formatter/JetTypingIndentationTest.java | 3 +-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java index 5286b584591..0dcfca95f28 100644 --- a/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java +++ b/idea/src/org/jetbrains/jet/plugin/formatter/JetBlock.java @@ -46,7 +46,8 @@ public class JetBlock extends AbstractBlock { private static final TokenSet CODE_BLOCKS = TokenSet.create( JetNodeTypes.BLOCK, JetNodeTypes.CLASS_BODY, - JetNodeTypes.FUNCTION_LITERAL_EXPRESSION); + JetNodeTypes.FUNCTION_LITERAL_EXPRESSION, + JetNodeTypes.FUNCTION_LITERAL); // private static final List diff --git a/idea/testData/formatter/IndentationOnNewline/FunctionBlock.kt b/idea/testData/formatter/IndentationOnNewline/FunctionBlock.kt index 9a06cb4c001..c65baae700d 100644 --- a/idea/testData/formatter/IndentationOnNewline/FunctionBlock.kt +++ b/idea/testData/formatter/IndentationOnNewline/FunctionBlock.kt @@ -1,11 +1,7 @@ package testing -private fun times(times : Int, body : () -> T) { - for (var i in 1..times) { - body() - } -} +private fun times(times : Int, body : () -> T) {} fun main(args: Array) { - times(3) { -} + times(3) {} +} \ No newline at end of file diff --git a/idea/testData/formatter/IndentationOnNewline/FunctionBlock_after.kt b/idea/testData/formatter/IndentationOnNewline/FunctionBlock_after.kt index c9d693643da..f7b57785a17 100644 --- a/idea/testData/formatter/IndentationOnNewline/FunctionBlock_after.kt +++ b/idea/testData/formatter/IndentationOnNewline/FunctionBlock_after.kt @@ -1,13 +1,9 @@ package testing -private fun times(times : Int, body : () -> T) { - for (var i in 1..times) { - body() - } -} +private fun times(times : Int, body : () -> T) {} fun main(args: Array) { times(3) { } -} +} \ 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 df528a40841..5aec6c4bdf6 100644 --- a/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java +++ b/idea/tests/org/jetbrains/jet/formatter/JetTypingIndentationTest.java @@ -49,8 +49,7 @@ public class JetTypingIndentationTest extends LightCodeInsightTestCase { doFileNewlineTest(); } - // TODO - public void enabletestFunctionBlock() { + public void testFunctionBlock() { doFileNewlineTest(); }