diff --git a/idea/idea-completion/testData/handlers/FunctionLiteralInsertWhenNoSpacesForBraces.kt b/idea/idea-completion/testData/handlers/FunctionLiteralInsertWhenNoSpacesForBraces.kt deleted file mode 100644 index 85ac1a0c19a..00000000000 --- a/idea/idea-completion/testData/handlers/FunctionLiteralInsertWhenNoSpacesForBraces.kt +++ /dev/null @@ -1,5 +0,0 @@ -fun Array.filter(predicate : (T) -> Boolean) : java.util.List = throw UnsupportedOperationException() - -fun main(args: Array) { - args.fil -} diff --git a/idea/idea-completion/testData/handlers/FunctionLiteralInsertWhenNoSpacesForBraces.kt.after b/idea/idea-completion/testData/handlers/FunctionLiteralInsertWhenNoSpacesForBraces.kt.after deleted file mode 100644 index cd03878995e..00000000000 --- a/idea/idea-completion/testData/handlers/FunctionLiteralInsertWhenNoSpacesForBraces.kt.after +++ /dev/null @@ -1,5 +0,0 @@ -fun Array.filter(predicate : (T) -> Boolean) : java.util.List = throw UnsupportedOperationException() - -fun main(args: Array) { - args.filter {} -} diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArg.kt b/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArg.kt deleted file mode 100644 index 3d59d4bd26b..00000000000 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArg.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun Array.filter(predicate : (T) -> Boolean) : java.util.List = throw UnsupportedOperationException() - -fun Array.filterNot(predicate : (T) -> Boolean) : java.util.List = throw UnsupportedOperationException() - -fun main(args: Array) { - args.filter {it != ""} -} diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArg.kt.after b/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArg.kt.after deleted file mode 100644 index 56ce34573dc..00000000000 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArg.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -fun Array.filter(predicate : (T) -> Boolean) : java.util.List = throw UnsupportedOperationException() - -fun Array.filterNot(predicate : (T) -> Boolean) : java.util.List = throw UnsupportedOperationException() - -fun main(args: Array) { - args.filterNot {it != ""} -} diff --git a/idea/idea-completion/testData/handlers/ForceParenthesisForTabChar.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt similarity index 75% rename from idea/idea-completion/testData/handlers/ForceParenthesisForTabChar.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt index 1320a4b0fe7..1b972dcbee1 100644 --- a/idea/idea-completion/testData/handlers/ForceParenthesisForTabChar.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt @@ -6,3 +6,6 @@ fun other() = 12 fun test() { somother() } + +// ELEMENT: some +// CHAR: '\t' diff --git a/idea/idea-completion/testData/handlers/ForceParenthesisForTabChar.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt.after similarity index 75% rename from idea/idea-completion/testData/handlers/ForceParenthesisForTabChar.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt.after index 2bbaada051e..cc5f2217746 100644 --- a/idea/idea-completion/testData/handlers/ForceParenthesisForTabChar.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt.after @@ -6,3 +6,6 @@ fun other() = 12 fun test() { some() } + +// ELEMENT: some +// CHAR: '\t' diff --git a/idea/idea-completion/testData/handlers/FunctionLiteralInsertOnSpace.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt similarity index 82% rename from idea/idea-completion/testData/handlers/FunctionLiteralInsertOnSpace.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt index bb9cb8b4481..81db3d13f7c 100644 --- a/idea/idea-completion/testData/handlers/FunctionLiteralInsertOnSpace.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt @@ -1,7 +1,10 @@ class Some + fun Some.filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException() fun main(args: Array) { Some().fil } +// ELEMENT: filter +// CHAR: ' ' diff --git a/idea/idea-completion/testData/handlers/FunctionLiteralInsertOnSpace.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt.after similarity index 83% rename from idea/idea-completion/testData/handlers/FunctionLiteralInsertOnSpace.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt.after index 2300a2ac509..c50c669fc66 100644 --- a/idea/idea-completion/testData/handlers/FunctionLiteralInsertOnSpace.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt.after @@ -1,7 +1,10 @@ class Some + fun Some.filter(predicate : (T) -> Boolean) = throw UnsupportedOperationException() fun main(args: Array) { Some().filter { } } +// ELEMENT: filter +// CHAR: ' ' diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt new file mode 100644 index 00000000000..701f67f739a --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt @@ -0,0 +1,7 @@ +// INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD: false + +fun main(args: Array) { + args.fil +} + +// ELEMENT: filter diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt.after new file mode 100644 index 00000000000..660ad3bff57 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt.after @@ -0,0 +1,7 @@ +// INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD: false + +fun main(args: Array) { + args.filter {} +} + +// ELEMENT: filter diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunction.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt similarity index 91% rename from idea/idea-completion/testData/handlers/HigherOrderFunction.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt index 85ac1a0c19a..61dff845b2c 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunction.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt @@ -3,3 +3,5 @@ fun Array.filter(predicate : (T) -> Boolean) : java.util.List = throw fun main(args: Array) { args.fil } + +// ELEMENT: * diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunction.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt.after similarity index 92% rename from idea/idea-completion/testData/handlers/HigherOrderFunction.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt.after index 7b6f91a883c..8b7a93a5302 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunction.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt.after @@ -3,3 +3,5 @@ fun Array.filter(predicate : (T) -> Boolean) : java.util.List = throw fun main(args: Array) { args.filter { } } + +// ELEMENT: * diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt new file mode 100644 index 00000000000..963e9f70541 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt @@ -0,0 +1,5 @@ +fun main(args: Array) { + args.filter {it != ""} +} + +// ELEMENT: filterNot \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt.after new file mode 100644 index 00000000000..9b4c7f8093f --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt.after @@ -0,0 +1,5 @@ +fun main(args: Array) { + args.filterNot {it != ""} +} + +// ELEMENT: filterNot \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs1.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt similarity index 57% rename from idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs1.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt index 00d5a177f5f..4f853bc548d 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs1.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt @@ -3,3 +3,6 @@ fun foo(p : (String, Char) -> Boolean){} fun main(args: Array) { fo } + +// ELEMENT: foo +// TAIL_TEXT: " { String, Char -> ... } ()" diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs1.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after similarity index 60% rename from idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs1.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after index dea6b2f41a6..dcc55fac961 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs1.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after @@ -3,3 +3,6 @@ fun foo(p : (String, Char) -> Boolean){} fun main(args: Array) { foo { s, c -> } } + +// ELEMENT: foo +// TAIL_TEXT: " { String, Char -> ... } ()" diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs2.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt similarity index 55% rename from idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs2.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt index 00d5a177f5f..fe214cb8106 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs2.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt @@ -3,3 +3,6 @@ fun foo(p : (String, Char) -> Boolean){} fun main(args: Array) { fo } + +// ELEMENT: foo +// TAIL_TEXT: "(p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs2.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt.after similarity index 56% rename from idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs2.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt.after index 67549ef5cda..804ad537ec4 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs2.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt.after @@ -3,3 +3,6 @@ fun foo(p : (String, Char) -> Boolean){} fun main(args: Array) { foo() } + +// ELEMENT: foo +// TAIL_TEXT: "(p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs3.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt similarity index 66% rename from idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs3.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt index ed6199850d7..f8ece805cfb 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs3.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt @@ -4,3 +4,7 @@ fun foo(p : (String, Boolean) -> Boolean){} fun main(args: Array) { fo } + +// ELEMENT: foo +// TAIL_TEXT: " { String, Char -> ... } ()" + diff --git a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs3.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after similarity index 70% rename from idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs3.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after index b556b37ff54..bc480d4e9e9 100644 --- a/idea/idea-completion/testData/handlers/HigherOrderFunctionWithArgs3.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after @@ -4,3 +4,7 @@ fun foo(p : (String, Boolean) -> Boolean){} fun main(args: Array) { foo { s: String, c: Char -> } } + +// ELEMENT: foo +// TAIL_TEXT: " { String, Char -> ... } ()" + diff --git a/idea/idea-completion/testData/handlers/InsertFunctionWithSingleParameterWithBrace.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt similarity index 67% rename from idea/idea-completion/testData/handlers/InsertFunctionWithSingleParameterWithBrace.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt index a27e169ac0c..a1a8166d780 100644 --- a/idea/idea-completion/testData/handlers/InsertFunctionWithSingleParameterWithBrace.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt @@ -2,4 +2,7 @@ fun some(f: () -> Unit) { f() } fun test() { some -} \ No newline at end of file +} + +// ELEMENT: some +// CHAR: { \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/InsertFunctionWithSingleParameterWithBrace.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt.after similarity index 69% rename from idea/idea-completion/testData/handlers/InsertFunctionWithSingleParameterWithBrace.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt.after index 49ea16e4543..357d8e93bdc 100644 --- a/idea/idea-completion/testData/handlers/InsertFunctionWithSingleParameterWithBrace.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt.after @@ -2,4 +2,7 @@ fun some(f: () -> Unit) { f() } fun test() { some { } -} \ No newline at end of file +} + +// ELEMENT: some +// CHAR: { \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/basic/ReplaceByLambdaTemplateNoClosingParenth.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt similarity index 100% rename from idea/idea-completion/testData/handlers/basic/ReplaceByLambdaTemplateNoClosingParenth.kt rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt diff --git a/idea/idea-completion/testData/handlers/basic/ReplaceByLambdaTemplateNoClosingParenth.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt.after similarity index 100% rename from idea/idea-completion/testData/handlers/basic/ReplaceByLambdaTemplateNoClosingParenth.kt.after rename to idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt.after diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt index e33fa75812c..9f6265c08b0 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt @@ -18,6 +18,8 @@ package org.jetbrains.kotlin.idea.completion.test.handlers import com.intellij.codeInsight.completion.CompletionType import com.intellij.openapi.util.io.FileUtil +import com.intellij.psi.codeStyle.CodeStyleSettingsManager +import org.jetbrains.kotlin.idea.core.formatter.JetCodeStyleSettings import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor import org.jetbrains.kotlin.test.InTextDirectivesUtils import java.io.File @@ -29,32 +31,45 @@ public abstract class AbstractCompletionHandlerTest(private val defaultCompletio private val TAIL_TEXT_PREFIX = "TAIL_TEXT:" private val COMPLETION_CHAR_PREFIX = "CHAR:" private val COMPLETION_TYPE_PREFIX = "COMPLETION_TYPE:" + private val INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD = "INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD:" protected open fun doTest(testPath: String) { setUpFixture(testPath) - val fileText = FileUtil.loadFile(File(testPath)) - val invocationCount = InTextDirectivesUtils.getPrefixedInt(fileText, INVOCATION_COUNT_PREFIX) ?: 1 - val lookupString = InTextDirectivesUtils.findStringWithPrefixes(fileText, LOOKUP_STRING_PREFIX) - val itemText = InTextDirectivesUtils.findStringWithPrefixes(fileText, ELEMENT_TEXT_PREFIX) - val tailText = InTextDirectivesUtils.findStringWithPrefixes(fileText, TAIL_TEXT_PREFIX) + val settingManager = CodeStyleSettingsManager.getInstance() + val tempSettings = settingManager.getCurrentSettings().clone() + settingManager.setTemporarySettings(tempSettings) + try { + val fileText = FileUtil.loadFile(File(testPath)) + val invocationCount = InTextDirectivesUtils.getPrefixedInt(fileText, INVOCATION_COUNT_PREFIX) ?: 1 + val lookupString = InTextDirectivesUtils.findStringWithPrefixes(fileText, LOOKUP_STRING_PREFIX) + val itemText = InTextDirectivesUtils.findStringWithPrefixes(fileText, ELEMENT_TEXT_PREFIX) + val tailText = InTextDirectivesUtils.findStringWithPrefixes(fileText, TAIL_TEXT_PREFIX) - val completionCharString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_CHAR_PREFIX) - val completionChar = when(completionCharString) { - "\\n", null -> '\n' - "\\t" -> '\t' - else -> completionCharString.singleOrNull() ?: error("Incorrect completion char: \"$completionCharString\"") + val completionCharString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_CHAR_PREFIX) + val completionChar = when(completionCharString) { + "\\n", null -> '\n' + "\\t" -> '\t' + else -> completionCharString.singleOrNull() ?: error("Incorrect completion char: \"$completionCharString\"") + } + + val completionTypeString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_TYPE_PREFIX) + val completionType = when (completionTypeString) { + "BASIC" -> CompletionType.BASIC + "SMART" -> CompletionType.SMART + null -> defaultCompletionType + else -> error("Unknown completion type: $completionTypeString") + } + + InTextDirectivesUtils.getPrefixedBoolean(fileText, INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD)?.let { + JetCodeStyleSettings.getInstance(getProject()).INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD = it + } + + doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, testPath + ".after") } - - val completionTypeString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_TYPE_PREFIX) - val completionType = when (completionTypeString) { - "BASIC" -> CompletionType.BASIC - "SMART" -> CompletionType.SMART - null -> defaultCompletionType - else -> error("Unknown completion type: $completionTypeString") + finally { + settingManager.dropTemporarySettings() } - - doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, testPath + ".after") } protected open fun setUpFixture(testPath: String) { diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt index 14555530f31..0cd608d3030 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTest.kt @@ -83,24 +83,10 @@ public class BasicCompletionHandlerTest : CompletionHandlerTestBase(){ fun testExtFunction() = doTest() - fun testFunctionLiteralInsertOnSpace() = doTest(2, null, null, ' ') - fun testInsertImportOnTab() = doTest(2, "ArrayList", null, '\t') - fun testHigherOrderFunction() = doTest() - fun testInsertFqnForJavaClass() = doTest(2, "SortedSet", " (java.util)", '\n') - fun testHigherOrderFunctionWithArg() = doTest(2, "filterNot", null, '\n') - - fun testHigherOrderFunctionWithArgs1() = doTest(1, "foo", "foo", " { String, Char -> ... } ()", '\n') - - fun testHigherOrderFunctionWithArgs2() = doTest(1, "foo", "foo", "(p: (String, Char) -> Boolean) ()", '\n') - - fun testHigherOrderFunctionWithArgs3() = doTest(1, "foo", "foo", " { String, Char -> ... } ()", '\n') - - fun testForceParenthesisForTabChar() = doTest(0, "some", null, '\t') - fun testTabInsertAtTheFileEnd() = doTest(0, "vvvvv", null, '\t') fun testTabInsertBeforeBraces() = doTest(0, "vvvvv", null, '\t') @@ -121,8 +107,6 @@ public class BasicCompletionHandlerTest : CompletionHandlerTestBase(){ fun testTabInsertInSimpleName() = doTest(0, "vvvvv", null, '\t') - fun testInsertFunctionWithSingleParameterWithBrace() = doTest(0, "some", null, '{') - fun testTabReplaceIdentifier() = doTest(1, "sss", null, '\t') fun testTabReplaceIdentifier2() = doTest(1, "sss", null, '\t') fun testTabReplaceThis() = doTest(1, "sss", null, '\t') @@ -142,19 +126,6 @@ public class BasicCompletionHandlerTest : CompletionHandlerTestBase(){ checkResult() } - fun testFunctionLiteralInsertWhenNoSpacesForBraces() { - val settings = CodeStyleSettingsManager.getSettings(getProject()) - val jetSettings = settings.getCustomSettings(javaClass())!! - - try { - jetSettings.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD = false - doTest() - } - finally { - jetSettings.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD = true - } - } - fun testObject() = doTest() fun testEnumMember() = doTest(1, "A", null, '\n') diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java index c458a472f7b..612699542e5 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java @@ -119,12 +119,6 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } - @TestMetadata("ReplaceByLambdaTemplateNoClosingParenth.kt") - public void testReplaceByLambdaTemplateNoClosingParenth() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/ReplaceByLambdaTemplateNoClosingParenth.kt"); - doTest(fileName); - } - @TestMetadata("ReplaceFunctionCallByProperty.kt") public void testReplaceFunctionCallByProperty() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/ReplaceFunctionCallByProperty.kt"); @@ -155,6 +149,75 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } + @TestMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class HighOrderFunctions extends AbstractBasicCompletionHandlerTest { + public void testAllFilesPresentInHighOrderFunctions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/basic/highOrderFunctions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ForceParenthesisForTabChar.kt") + public void testForceParenthesisForTabChar() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/ForceParenthesisForTabChar.kt"); + doTest(fileName); + } + + @TestMetadata("FunctionLiteralInsertOnSpace.kt") + public void testFunctionLiteralInsertOnSpace() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertOnSpace.kt"); + doTest(fileName); + } + + @TestMetadata("FunctionLiteralInsertWhenNoSpacesForBraces.kt") + public void testFunctionLiteralInsertWhenNoSpacesForBraces() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/FunctionLiteralInsertWhenNoSpacesForBraces.kt"); + doTest(fileName); + } + + @TestMetadata("HigherOrderFunction.kt") + public void testHigherOrderFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.kt"); + doTest(fileName); + } + + @TestMetadata("HigherOrderFunctionWithArg.kt") + public void testHigherOrderFunctionWithArg() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArg.kt"); + doTest(fileName); + } + + @TestMetadata("HigherOrderFunctionWithArgs1.kt") + public void testHigherOrderFunctionWithArgs1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt"); + doTest(fileName); + } + + @TestMetadata("HigherOrderFunctionWithArgs2.kt") + public void testHigherOrderFunctionWithArgs2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs2.kt"); + doTest(fileName); + } + + @TestMetadata("HigherOrderFunctionWithArgs3.kt") + public void testHigherOrderFunctionWithArgs3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt"); + doTest(fileName); + } + + @TestMetadata("InsertFunctionWithSingleParameterWithBrace.kt") + public void testInsertFunctionWithSingleParameterWithBrace() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/InsertFunctionWithSingleParameterWithBrace.kt"); + doTest(fileName); + } + + @TestMetadata("ReplaceByLambdaTemplateNoClosingParenth.kt") + public void testReplaceByLambdaTemplateNoClosingParenth() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/handlers/basic/stringTemplate") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)