diff --git a/idea/testData/codeInsight/postfix/arg.kt b/idea/testData/codeInsight/postfix/arg.kt index cb9aadcc773..567cf9ccc9a 100644 --- a/idea/testData/codeInsight/postfix/arg.kt +++ b/idea/testData/codeInsight/postfix/arg.kt @@ -1,3 +1,4 @@ +// TEMPLATE: \tfunctionCall\t fun foo(s: String) { s.arg } \ No newline at end of file diff --git a/idea/testData/codeInsight/postfix/arg.kt.after b/idea/testData/codeInsight/postfix/arg.kt.after index 1ea7dd2e0a1..07dc598e78f 100644 --- a/idea/testData/codeInsight/postfix/arg.kt.after +++ b/idea/testData/codeInsight/postfix/arg.kt.after @@ -1,3 +1,4 @@ +// TEMPLATE: \tfunctionCall\t fun foo(s: String) { - (s) + functionCall(s) } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/postfix/AbstractPostfixTemplateProviderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/postfix/AbstractPostfixTemplateProviderTest.kt index bd9ad2b91f8..9aa3f5c5071 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/postfix/AbstractPostfixTemplateProviderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/postfix/AbstractPostfixTemplateProviderTest.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.codeInsight.postfix +import com.intellij.codeInsight.template.impl.TemplateManagerImpl import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor import org.jetbrains.kotlin.test.InTextDirectivesUtils @@ -24,16 +25,23 @@ abstract class AbstractPostfixTemplateProviderTest : KotlinLightCodeInsightFixtu } protected fun doTest(fileName: String) { + val fileText = File(fileName).readText() myFixture.configureByFile(fileName) - myFixture.type("\t") + val template = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// TEMPLATE:") + if (template != null) { + TemplateManagerImpl.setTemplateTesting(project, testRootDisposable) + myFixture.type(template.replace("\\t", "\t")) + } else { + myFixture.type('\t') + } val previouslySuggestedExpressions = KtPostfixTemplateProvider.previouslySuggestedExpressions - if (previouslySuggestedExpressions.size > 1 && !InTextDirectivesUtils.isDirectiveDefined(File(fileName).readText(), "ALLOW_MULTIPLE_EXPRESSIONS")) { + if (previouslySuggestedExpressions.size > 1 && !InTextDirectivesUtils.isDirectiveDefined(fileText, "ALLOW_MULTIPLE_EXPRESSIONS")) { fail("Only one expression should be suggested, but $previouslySuggestedExpressions were found") } - myFixture.checkResultByFile(fileName + ".after") + myFixture.checkResultByFile("$fileName.after") } override fun tearDown() {