From ebf20c9706cfe076a284f14d88067fd0800249e4 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 13 Jul 2020 12:06:17 +0300 Subject: [PATCH] Add multi-file tests for primitive completion - This is required to test/debug correct completion from imports --- .../kotlin/generators/tests/GenerateTests.kt | 4 +++ .../generators/tests/GenerateTests.kt.192 | 4 +++ .../generators/tests/GenerateTests.kt.as36 | 4 +++ .../generators/tests/GenerateTests.kt.as40 | 4 +++ .../generators/tests/GenerateTests.kt.as41 | 4 +++ .../NestedClassImport.dependency.kt | 7 ++++ .../NestedClassImport/NestedClassImport.kt | 8 +++++ ...AbstractMultiFileJvmBasicCompletionTest.kt | 3 +- ...mitiveJvmBasicCompletionTestGenerated.java | 35 +++++++++++++++++++ 9 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.dependency.kt create mode 100644 idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.kt create mode 100644 idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFilePrimitiveJvmBasicCompletionTestGenerated.java diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index b9131e07f55..007946df000 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1185,6 +1185,10 @@ fun main(args: Array) { model("basic/multifile", extension = null, recursive = false) } + testClass("MultiFilePrimitiveJvmBasicCompletionTestGenerated") { + model("basic/multifilePrimitive", extension = null, recursive = false) + } + testClass { model("smartMultiFile", extension = null, recursive = false) } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 index 113afc1ff6b..47dccc475f7 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 @@ -1099,6 +1099,10 @@ fun main(args: Array) { model("basic/multifile", extension = null, recursive = false) } + testClass("MultiFilePrimitiveJvmBasicCompletionTestGenerated") { + model("basic/multifilePrimitive", extension = null, recursive = false) + } + testClass { model("smartMultiFile", extension = null, recursive = false) } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 index 37a5587c0b0..7aac4b8d6b9 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as36 @@ -966,6 +966,10 @@ fun main(args: Array) { model("basic/multifile", extension = null, recursive = false) } + testClass("MultiFilePrimitiveJvmBasicCompletionTestGenerated") { + model("basic/multifilePrimitive", extension = null, recursive = false) + } + testClass { model("smartMultiFile", extension = null, recursive = false) } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 index 3bfc7007e20..be49ff0303d 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as40 @@ -1002,6 +1002,10 @@ fun main(args: Array) { model("basic/multifile", extension = null, recursive = false) } + testClass("MultiFilePrimitiveJvmBasicCompletionTestGenerated") { + model("basic/multifilePrimitive", extension = null, recursive = false) + } + testClass { model("smartMultiFile", extension = null, recursive = false) } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 index 3bfc7007e20..be49ff0303d 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.as41 @@ -1002,6 +1002,10 @@ fun main(args: Array) { model("basic/multifile", extension = null, recursive = false) } + testClass("MultiFilePrimitiveJvmBasicCompletionTestGenerated") { + model("basic/multifilePrimitive", extension = null, recursive = false) + } + testClass { model("smartMultiFile", extension = null, recursive = false) } diff --git a/idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.dependency.kt b/idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.dependency.kt new file mode 100644 index 00000000000..f8dd4fb94d6 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.dependency.kt @@ -0,0 +1,7 @@ +package dependency + +class TopLevelClass { + class NestedClass + + inner class InnerClass +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.kt b/idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.kt new file mode 100644 index 00000000000..06d458137a2 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/NestedClassImport.kt @@ -0,0 +1,8 @@ +import dependency.TopLevelClass.* + +fun usage() { + +} + +// EXIST: NestedClass +// EXIST: InnerClass \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt index 54a114df721..4be5fb5dedf 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractMultiFileJvmBasicCompletionTest.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.completion.test import com.intellij.codeInsight.completion.CompletionType import org.jetbrains.kotlin.idea.test.AstAccessControl import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.test.KotlinTestUtils abstract class AbstractMultiFileJvmBasicCompletionTest : KotlinCompletionTestCase() { protected fun doTest(testPath: String) { @@ -23,6 +24,6 @@ abstract class AbstractMultiFileJvmBasicCompletionTest : KotlinCompletionTestCas } override fun getTestDataPath(): String { - return COMPLETION_TEST_DATA_BASE_PATH + "/basic/multifile/" + getTestName(false) + "/" + return KotlinTestUtils.getTestsRoot(this::class.java) + "/" + getTestName(false) + "/" } } \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFilePrimitiveJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFilePrimitiveJvmBasicCompletionTestGenerated.java new file mode 100644 index 00000000000..88ce1a02220 --- /dev/null +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFilePrimitiveJvmBasicCompletionTestGenerated.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.completion.test; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/idea-completion/testData/basic/multifilePrimitive") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class MultiFilePrimitiveJvmBasicCompletionTestGenerated extends AbstractMultiFileJvmBasicCompletionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMultifilePrimitive() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-completion/testData/basic/multifilePrimitive"), Pattern.compile("^([^\\.]+)$"), null, false); + } + + @TestMetadata("NestedClassImport") + public void testNestedClassImport() throws Exception { + runTest("idea/idea-completion/testData/basic/multifilePrimitive/NestedClassImport/"); + } +}