From 2b51b526baba274235cd4ee3bdaaf3691d712e44 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 25 Apr 2016 17:55:10 +0300 Subject: [PATCH] Enable injection in injection tests --- .../org/jetbrains/kotlin/psi/AbstractInjectionTest.kt | 11 ++++++----- .../jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt index 2209bb683d9..bfd6e668316 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt @@ -20,6 +20,7 @@ import com.intellij.injected.editor.EditorWindow import com.intellij.psi.injection.Injectable import com.intellij.testFramework.LightProjectDescriptor import junit.framework.TestCase +import org.intellij.lang.annotations.Language import org.intellij.plugins.intelliLang.Configuration import org.intellij.plugins.intelliLang.inject.InjectLanguageAction import org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction @@ -39,7 +40,7 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { } } - protected fun doInjectionPresentTest(text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) { + protected fun doInjectionPresentTest(@Language("kotlin") text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) { myFixture.configureByText("${getTestName(true)}.kt", text.trimIndent()) assertInjectionPresent(languageId, unInjectShouldBePresent) } @@ -60,14 +61,14 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { } } - protected fun assertNoInjection(text: String) { + protected fun assertNoInjection(@Language("kotlin") text: String) { myFixture.configureByText("${getTestName(true)}.kt", text.trimIndent()) TestCase.assertTrue("Injection action is not available. There's probably some injection but nothing was expected.", InjectLanguageAction().isAvailable(project, myFixture.editor, myFixture.file)) } - protected fun doRemoveInjectionTest(before: String, after: String) { + protected fun doRemoveInjectionTest(@Language("kotlin") before: String, @Language("kotlin") after: String) { myFixture.setCaresAboutInjection(false) myFixture.configureByText("${getTestName(true)}.kt", before.trimIndent()) @@ -78,11 +79,11 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { myFixture.checkResult(after.trimIndent()) } - protected fun doFileReferenceInjectTest(before: String, after: String) { + protected fun doFileReferenceInjectTest(@Language("kotlin") before: String, @Language("kotlin") after: String) { doTest(FileReferenceInjector(), before, after) } - protected fun doTest(injectable: Injectable, before: String, after: String) { + protected fun doTest(injectable: Injectable, @Language("kotlin") before: String, @Language("kotlin") after: String) { val configuration = Configuration.getProjectInstance(project).advancedConfiguration val allowed = configuration.isSourceModificationAllowed diff --git a/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt index 5635a205df1..c0f3f397f45 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.psi +import org.intellij.lang.annotations.Language import org.intellij.lang.regexp.RegExpLanguage import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor @@ -62,7 +63,7 @@ class KotlinStdlibInjectionTest : AbstractInjectionTest() { RegExpLanguage.INSTANCE.id ) - private fun assertInjectionPresent(text: String, languageId: String) { + private fun assertInjectionPresent(@Language("kotlin") text: String, languageId: String) { doInjectionPresentTest(text, languageId = languageId, unInjectShouldBePresent = false) }