Refactor AbstractHighLevelMultiFileJvmBasicCompletionTest

Use `KotlinFixtureCompletionBaseTestCase` base because it can override
`getProjectDescriptor`, so the tests will see full JDK

Without it, there were problems when classes from JDK appeared in the
completion (`Serialization`, for example)
This commit is contained in:
Roman Golyshev
2021-03-23 23:29:08 +03:00
committed by Space
parent cc7187e49b
commit fcd0168381
6 changed files with 27 additions and 16 deletions
@@ -1,3 +1,4 @@
// FIR_COMPARISON
val String.extensionProp1: Int get() = 1
val String.extensionProp2: Int get() = 1
@@ -1,4 +1,3 @@
// FIR_COMPARISON
// NUMBER: 3
// EXIST: foo.txt
// EXIST: bar.txt
@@ -1,3 +1,4 @@
// FIR_COMPARISON
// this test tests correct substitution equality checking for generic functions
import java.io.InputStreamReader
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package first
class C {
@@ -1,3 +1,4 @@
// FIR_COMPARISON
package first
fun firstFun() {
@@ -6,26 +6,34 @@
package org.jetbrains.kotlin.idea.completion
import com.intellij.codeInsight.completion.CompletionType
import org.jetbrains.kotlin.idea.completion.test.AbstractMultiFileJvmBasicCompletionTest
import org.jetbrains.kotlin.idea.completion.test.testCompletion
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.kotlin.idea.completion.test.KotlinFixtureCompletionBaseTestCase
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.uitls.IgnoreTests
import java.nio.file.Path
import java.nio.file.Paths
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
abstract class AbstractHighLevelMultiFileJvmBasicCompletionTest : AbstractMultiFileJvmBasicCompletionTest() {
private val testDataFile: Path
get() = Paths.get(testDataPath, getTestName(false) + ".kt")
abstract class AbstractHighLevelMultiFileJvmBasicCompletionTest : KotlinFixtureCompletionBaseTestCase() {
override val captureExceptions: Boolean = false
override fun doTest(testPath: String) {
IgnoreTests.runTestIfEnabledByFileDirective(testDataFile, IgnoreTests.DIRECTIVES.FIR_COMPARISON) {
configureByFile(getTestName(false) + ".kt", "")
testCompletion(file.text, JvmPlatforms.unspecifiedJvmPlatform, { completionType, invocationCount ->
setType(completionType)
complete(invocationCount)
myItems
}, CompletionType.BASIC, 0)
override fun executeTest(test: () -> Unit) {
IgnoreTests.runTestIfEnabledByFileDirective(testDataFile().toPath(), IgnoreTests.DIRECTIVES.FIR_COMPARISON) {
test()
}
}
override fun getTestDataPath(): String = Paths.get(super.getTestDataPath(), getTestName(false)).toString()
override fun fileName(): String = getTestName(false) + ".kt"
override fun setUpFixture(testPath: String) {
// We need to copy all files from the testDataPath (= "") to the tested project
myFixture.copyDirectoryToProject("", "")
super.setUpFixture(testPath)
}
override fun defaultCompletionType(): CompletionType = CompletionType.BASIC
override fun getPlatform(): TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
}