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) - } """ - ) - } -}