Enable injection in injection tests
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user