From 36f34315590e9fd5ce63b850d34055c62418b4ac Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Mon, 22 Jun 2020 18:28:52 +0200 Subject: [PATCH] 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. --- .../kotlin/generators/tests/GenerateTests.kt | 5 +++ .../hints/suspending/SimpleCase.kt | 5 +++ ...ctKotlinSuspendingCallHintsProviderTest.kt | 34 ++++++++++++++++++ ...pendingCallHintsProviderTestGenerated.java | 35 +++++++++++++++++++ .../parameterInfo/SuspendingCallHintsTest.kt | 34 ------------------ 5 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 idea/testData/codeInsight/hints/suspending/SimpleCase.kt create mode 100644 idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinSuspendingCallHintsProviderTest.kt create mode 100644 idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinSuspendingCallHintsProviderTestGenerated.java delete mode 100644 idea/tests/org/jetbrains/kotlin/idea/parameterInfo/SuspendingCallHintsTest.kt diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index e6e7dcf0654..fd984305d9c 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -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) { model("codeInsight/hints/lambda") } + testClass { + model("codeInsight/hints/suspending") + } + testClass { model("script/definition/highlighting", extension = null, recursive = false) model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest") diff --git a/idea/testData/codeInsight/hints/suspending/SimpleCase.kt b/idea/testData/codeInsight/hints/suspending/SimpleCase.kt new file mode 100644 index 00000000000..7159a9dd9dc --- /dev/null +++ b/idea/testData/codeInsight/hints/suspending/SimpleCase.kt @@ -0,0 +1,5 @@ +import kotlin.coroutines.experimental.buildSequence + +val x = buildSequence { + <# # #>yield(1) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinSuspendingCallHintsProviderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinSuspendingCallHintsProviderTest.kt new file mode 100644 index 00000000000..37e87191da5 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinSuspendingCallHintsProviderTest.kt @@ -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) + } + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinSuspendingCallHintsProviderTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinSuspendingCallHintsProviderTestGenerated.java new file mode 100644 index 00000000000..cc17b741663 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinSuspendingCallHintsProviderTestGenerated.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.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"); + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/SuspendingCallHintsTest.kt b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/SuspendingCallHintsTest.kt deleted file mode 100644 index 7bf4112bf21..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/SuspendingCallHintsTest.kt +++ /dev/null @@ -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 { - yield(1) - } """ - ) - } -}