KT-32368 Rework Inline hints settings // migrate tests for suspending calls

KotlinSuspendingCallHintsProvider which in now responsible for
suspending call hints is not compatible with the existing
SuspendingCallHintsTest. Because of that tests were migrated to the new
infrastructure.
This commit is contained in:
Andrei Klunnyi
2020-06-22 18:28:52 +02:00
parent b0dece756a
commit 36f3431559
5 changed files with 79 additions and 34 deletions
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateHashCodeAn
import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateTestSupportMethodActionTest
import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateToStringActionTest
import org.jetbrains.kotlin.idea.codeInsight.hints.AbstractKotlinLambdasHintsProvider
import org.jetbrains.kotlin.idea.codeInsight.hints.AbstractKotlinSuspendingCallHintsProviderTest
import org.jetbrains.kotlin.idea.codeInsight.moveUpDown.AbstractMoveLeftRightTest
import org.jetbrains.kotlin.idea.codeInsight.moveUpDown.AbstractMoveStatementTest
import org.jetbrains.kotlin.idea.codeInsight.postfix.AbstractPostfixTemplateProviderTest
@@ -884,6 +885,10 @@ fun main(args: Array<String>) {
model("codeInsight/hints/lambda")
}
testClass<AbstractKotlinSuspendingCallHintsProviderTest> {
model("codeInsight/hints/suspending")
}
testClass<AbstractScriptConfigurationHighlightingTest> {
model("script/definition/highlighting", extension = null, recursive = false)
model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest")
@@ -0,0 +1,5 @@
import kotlin.coroutines.experimental.buildSequence
val x = buildSequence {
<# # #>yield(1)
}
@@ -0,0 +1,34 @@
/*
* 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.codeInsight.hints
import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.utils.inlays.InlayHintsProviderTestCase
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import java.io.File
@Suppress("UnstableApiUsage")
abstract class AbstractKotlinSuspendingCallHintsProviderTest :
InlayHintsProviderTestCase() { // Abstract- prefix is just a convention for GenerateTests
override fun getProjectDescriptor(): LightProjectDescriptor {
return KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
}
fun doTest(testPath: String) { // named according to the convention imposed by GenerateTests
assertThatActualHintsMatch(testPath)
}
private fun assertThatActualHintsMatch(fileName: String) {
with(KotlinSuspendingCallHintsProvider()) {
val fileContents = FileUtil.loadFile(File(fileName), true)
val settings = createSettings().apply { suspendingCalls = true }
testProvider("KotlinSuspendingCallHintsProvider.kt", fileContents, this, settings)
}
}
}
@@ -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.codeInsight.hints;
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/testData/codeInsight/hints/suspending")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class KotlinSuspendingCallHintsProviderTestGenerated extends AbstractKotlinSuspendingCallHintsProviderTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSuspending() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/codeInsight/hints/suspending"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("SimpleCase.kt")
public void testSimpleCase() throws Exception {
runTest("idea/testData/codeInsight/hints/suspending/SimpleCase.kt");
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2010-2019 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.parameterInfo
import org.jetbrains.kotlin.idea.codeInsight.hints.HintType
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
import org.junit.runner.RunWith
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
class SuspendingCallHintsTest : KotlinLightCodeInsightFixtureTestCase() {
override fun getProjectDescriptor(): KotlinLightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
fun check(text: String) {
HintType.SUSPENDING_CALL.option.set(true)
myFixture.configureByText("A.kt", text)
myFixture.testInlays()
}
fun testSimple() {
check(
"""import kotlin.coroutines.experimental.buildSequence
val x = buildSequence {<hint text="this: SequenceBuilder<Int>" />
<hint text="#" />yield(1)
} """
)
}
}