diff --git a/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt index bfd6e668316..54bc898cffa 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt @@ -40,12 +40,18 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { } } - protected fun doInjectionPresentTest(@Language("kotlin") text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) { + protected fun doInjectionPresentTest( + @Language("kotlin") text: String, @Language("Java") javaText: String? = null, + languageId: String? = null, unInjectShouldBePresent: Boolean = true) { + if (javaText != null) { + myFixture.configureByText("${getTestName(true)}.java", javaText.trimIndent()) + } + myFixture.configureByText("${getTestName(true)}.kt", text.trimIndent()) + assertInjectionPresent(languageId, unInjectShouldBePresent) } - protected fun assertInjectionPresent(languageId: String?, unInjectShouldBePresent: Boolean) { TestCase.assertFalse("Injection action is available. There's probably no injection at caret place", InjectLanguageAction().isAvailable(project, myFixture.editor, myFixture.file)) diff --git a/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt index dd6215f936e..a2cc19d8c96 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt @@ -379,4 +379,35 @@ class KotlinInjectionTest : AbstractInjectionTest() { // """, // languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false // ) + + + fun testInjectionOfCustomParameterInJavaConstructorWithAnnotationWithAnnotation() = doInjectionPresentTest( + """ + fun bar() { Test("some") } + """, + javaText = + """ + import org.intellij.lang.annotations.Language; + + public class Test { + public Test(@Language("HTML") String str) {} + } + """, + languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false + ) + + fun testInjectionOfCustomParameterJavaWithAnnotation() = doInjectionPresentTest( + """ + fun bar() { Test.foo("some") } + """, + javaText = + """ + import org.intellij.lang.annotations.Language; + + public class Test { + public static void foo(@Language("HTML") String str) {} + } + """, + languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false + ) } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/psi/KotlinMultifileInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/KotlinMultifileInjectionTest.kt deleted file mode 100644 index f2c9bd7c732..00000000000 --- a/idea/tests/org/jetbrains/kotlin/psi/KotlinMultifileInjectionTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.psi - -import com.intellij.lang.html.HTMLLanguage -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase - -class KotlinMultiFileInjectionTest : AbstractInjectionTest() { - public override fun setUp() { - super.setUp() - myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/injection" - } - - fun testInjectionOfCustomParameterInJavaConstructorWithAnnotation() = doMultiFileInjectionPresentTest(HTMLLanguage.INSTANCE.id, false) - - fun testInjectionOfCustomParameterJavaWithAnnotation() = doMultiFileInjectionPresentTest(HTMLLanguage.INSTANCE.id, false) - - override fun getTestDataPath(): String? { - return "idea/testData/injection/" - } - - private fun doMultiFileInjectionPresentTest(languageId: String? = null, unInjectShouldBePresent: Boolean = true) { - val testName = getTestName(false) - - myFixture.configureByFile("$testName.java") - myFixture.configureByFile("$testName.kt") - - assertInjectionPresent(languageId, unInjectShouldBePresent) - } -} -