diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt index 0c995f13f4f..26bc024ee9e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithExpressionPrefixInsertHandler.kt @@ -34,7 +34,9 @@ class WithExpressionPrefixInsertHandler(val prefix: String) : InsertHandler +} diff --git a/idea/idea-completion/testData/handlers/multifile/ExclCharInsertImport-2.kt b/idea/idea-completion/testData/handlers/multifile/ExclCharInsertImport-2.kt new file mode 100644 index 00000000000..0b51786edc5 --- /dev/null +++ b/idea/idea-completion/testData/handlers/multifile/ExclCharInsertImport-2.kt @@ -0,0 +1,4 @@ +package foo + +val String.isXXX: Boolean + get() = true diff --git a/idea/idea-completion/testData/handlers/multifile/ExclCharInsertImport.kt.after b/idea/idea-completion/testData/handlers/multifile/ExclCharInsertImport.kt.after new file mode 100644 index 00000000000..19bfa25e190 --- /dev/null +++ b/idea/idea-completion/testData/handlers/multifile/ExclCharInsertImport.kt.after @@ -0,0 +1,9 @@ +package qqqq + +import a +import b +import foo.isXXX + +fun foo() { + !"".isXXX +} diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionMultifileHandlerTest.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionMultifileHandlerTest.java deleted file mode 100644 index 8ad4284c5f4..00000000000 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionMultifileHandlerTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.completion.test.handlers; - -import junit.framework.TestCase; -import org.jetbrains.kotlin.idea.completion.test.KotlinCompletionTestCase; -import org.jetbrains.kotlin.idea.completion.test.TestPackage; - -import java.io.File; - -public class CompletionMultifileHandlerTest extends KotlinCompletionTestCase { - public void testExtensionFunctionImport() throws Exception { - doTest(); - } - - public void testExtensionPropertyImport() throws Exception { - doTest(); - } - - public void testImportAlreadyImportedObject() throws Exception { - doTest(); - } - - public void testJetClassCompletionImport() throws Exception { - doTest(); - } - - public void testTopLevelFunctionImport() throws Exception { - doTest(); - } - - public void testTopLevelFunctionInQualifiedExpr() throws Exception { - doTest(); - } - - public void testTopLevelPropertyImport() throws Exception { - doTest(); - } - - public void testNoParenthesisInImports() throws Exception { - doTest(); - } - - public void testKeywordExtensionFunctionName() throws Exception { - doTest(); - } - - public void testInfixExtensionCallImport() throws Exception { - doTest(); - } - - public void testClassWithClassObject() throws Exception { - doTest(); - } - - public void testGlobalFunctionImportInLambda() throws Exception { - doTest(); - } - - public void testObjectInStringTemplate() throws Exception { - doTest(); - } - - public void doTest() throws Exception { - String fileName = getTestName(false); - - configureByFiles(null, fileName + "-1.kt", fileName + "-2.kt"); - complete(2); - if (myItems != null) { - TestCase.assertTrue("Multiple items in completion", myItems.length == 1); - selectItem(myItems[0]); - } - checkResultByFile(fileName + ".kt.after"); - } - - @Override - protected String getTestDataPath() { - return new File(TestPackage.getCOMPLETION_TEST_DATA_BASE_PATH(), "/handlers/multifile/").getPath() + File.separator; - } -} diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionMultifileHandlerTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionMultifileHandlerTest.kt new file mode 100644 index 00000000000..68c5546ba0b --- /dev/null +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionMultifileHandlerTest.kt @@ -0,0 +1,93 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.completion.test.handlers + +import org.jetbrains.kotlin.idea.completion.test.COMPLETION_TEST_DATA_BASE_PATH +import org.jetbrains.kotlin.idea.completion.test.KotlinCompletionTestCase +import java.io.File + +class CompletionMultiFileHandlerTest : KotlinCompletionTestCase() { + fun testExtensionFunctionImport() { + doTest() + } + + fun testExtensionPropertyImport() { + doTest() + } + + fun testImportAlreadyImportedObject() { + doTest() + } + + fun testJetClassCompletionImport() { + doTest() + } + + fun testTopLevelFunctionImport() { + doTest() + } + + fun testTopLevelFunctionInQualifiedExpr() { + doTest() + } + + fun testTopLevelPropertyImport() { + doTest() + } + + fun testNoParenthesisInImports() { + doTest() + } + + fun testKeywordExtensionFunctionName() { + doTest() + } + + fun testInfixExtensionCallImport() { + doTest() + } + + fun testClassWithClassObject() { + doTest() + } + + fun testGlobalFunctionImportInLambda() { + doTest() + } + + fun testObjectInStringTemplate() { + doTest() + } + + fun testExclCharInsertImport() { + doTest('!') + } + + fun doTest(completionChar: Char = '\n') { + val fileName = getTestName(false) + + configureByFiles(null, fileName + "-1.kt", fileName + "-2.kt") + complete(2) + if (myItems != null) { + val item = myItems.singleOrNull() ?: error("Multiple items in completion") + selectItem(item, completionChar) + } + checkResultByFile(fileName + ".kt.after") + } + + override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, "/handlers/multifile/").path + File.separator +}