KT-2242 Fix {<space>(a: Int) -> a } case

#KT-2242 Fixed
This commit is contained in:
Nikolay Krasko
2012-09-17 11:27:38 +04:00
parent 7b066faa9f
commit 72fb2c0d02
4 changed files with 15 additions and 2 deletions
@@ -32,8 +32,7 @@ import org.jetbrains.jet.plugin.JetLanguage;
import java.util.*;
import static org.jetbrains.jet.JetNodeTypes.BLOCK;
import static org.jetbrains.jet.JetNodeTypes.FUNCTION_LITERAL;
import static org.jetbrains.jet.JetNodeTypes.*;
import static org.jetbrains.jet.lexer.JetTokens.*;
/**
@@ -166,6 +165,14 @@ public class JetBlock extends AbstractBlock {
}
if (parentType == FUNCTION_LITERAL && child1Type == LBRACE) {
if (child2Type == VALUE_PARAMETER_LIST) {
ASTNode firstParamListNode = ((ASTBlock) child2).getNode().getFirstChildNode();
if (firstParamListNode != null && firstParamListNode.getElementType() == LPAR) {
// Don't put space for situation {<here>(a: Int) -> a }
return Spacing.createSpacing(0, 0, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
return Spacing.createSpacing(spacesInSimpleMethod, spacesInSimpleMethod, 0,
mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
@@ -2,5 +2,7 @@ fun test(some: (Int) -> Int) {
}
fun foo() = test() { it }
val function = test { (a: Int) -> a }
val function1 = test {a : Int -> a}
// SET_TRUE: INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD
@@ -2,5 +2,7 @@ fun test(some: (Int) -> Int) {
}
fun foo() = test() { it }
val function = test {(a: Int) -> a }
val function1 = test { a : Int -> a }
// SET_TRUE: INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD
@@ -2,5 +2,7 @@ fun test(some: (Int) -> Int) {
}
fun foo() = test() {it}
val function = test {(a: Int) -> a}
val function1 = test {a : Int -> a}
// SET_TRUE: INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD