diff --git a/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt index e37e2f88a30..506559c7fba 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/AbstractInjectionTest.kt @@ -40,7 +40,7 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { } protected fun assertInjectionPresent(text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) { - myFixture.configureByText("${getTestName(true)}.kt", text.trimMargin()) + myFixture.configureByText("${getTestName(true)}.kt", text.trimIndent()) TestCase.assertFalse("Injection action is available. There's probably no injection at caret place", InjectLanguageAction().isAvailable(project, myFixture.editor, myFixture.file)) @@ -57,7 +57,7 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { } protected fun assertNoInjection(text: String) { - myFixture.configureByText("${getTestName(true)}.kt", text.trimMargin()) + 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)) @@ -66,12 +66,12 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { protected fun doRemoveInjectionTest(before: String, after: String) { myFixture.setCaresAboutInjection(false) - myFixture.configureByText("${getTestName(true)}.kt", before.trimMargin()) + myFixture.configureByText("${getTestName(true)}.kt", before.trimIndent()) TestCase.assertTrue(UnInjectLanguageAction().isAvailable(project, myFixture.editor, myFixture.file)) UnInjectLanguageAction.invokeImpl(project, myFixture.editor, myFixture.file) - myFixture.checkResult(after.trimMargin()) + myFixture.checkResult(after.trimIndent()) } protected fun doFileReferenceInjectTest(before: String, after: String) { @@ -84,9 +84,9 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() { configuration.isSourceModificationAllowed = true try { - myFixture.configureByText("${getTestName(true)}.kt", before.trimMargin()) + myFixture.configureByText("${getTestName(true)}.kt", before.trimIndent()) InjectLanguageAction.invokeImpl(project, myFixture.editor, myFixture.file, injectable) - myFixture.checkResult(after.trimMargin()) + myFixture.checkResult(after.trimIndent()) } finally { configuration.isSourceModificationAllowed = allowed diff --git a/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt index dd08cc79168..1a962e6b434 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/KotlinInjectionTest.kt @@ -46,7 +46,7 @@ class KotlinInjectionTest : AbstractInjectionTest() { fun testInjectionOnJavaPredefinedMethodWithAnnotation() = assertInjectionPresent( """ - |val test1 = java.util.regex.Pattern.compile("pattern") + val test1 = java.util.regex.Pattern.compile("pattern") """, RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false @@ -65,7 +65,7 @@ class KotlinInjectionTest : AbstractInjectionTest() { assertInjectionPresent( """ - |val stringBuilder = StringBuilder().replace(0, 0, "") + val stringBuilder = StringBuilder().replace(0, 0, "") """, HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false @@ -78,133 +78,133 @@ class KotlinInjectionTest : AbstractInjectionTest() { fun testInjectionWithCommentOnProperty() = assertInjectionPresent( """ - |//language=file-reference - |val test = "simple" + //language=file-reference + val test = "simple" """) fun testInjectionWithUsageOnReceiverWithRuntime() = assertInjectionPresent( """ - |val test = "some" - |fun foo() = test.toRegex() + val test = "some" + fun foo() = test.toRegex() """, languageId = RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false) fun testInjectionWithUsageInParameterWithRuntime() = assertInjectionPresent( """ - |val test = "some" - |fun foo() = Regex(test) + val test = "some" + fun foo() = Regex(test) """, languageId = RegExpLanguage.INSTANCE.id, unInjectShouldBePresent = false) fun testNoInjectionThoughSeveralAssignmentsWithRuntime() = assertNoInjection( """ - |val first = "some" - |val test = first - |fun foo() = Regex(test) + val first = "some" + val test = first + fun foo() = Regex(test) """) fun testInjectionWithMultipleCommentsOnFun() = assertInjectionPresent( """ - |// Some comment - |// Other comment - |//language=file-reference - |fun test() = "simple" + // Some comment + // Other comment + //language=file-reference + fun test() = "simple" """) fun testInjectionWithAnnotationOnPropertyWithAnnotation() = assertInjectionPresent( """ - |@org.intellij.lang.annotations.Language("file-reference") - |val test = "simple" + @org.intellij.lang.annotations.Language("file-reference") + val test = "simple" """) fun testInjectWithCommentOnProperty() = doFileReferenceInjectTest( """ - |val test = "simple" + val test = "simple" """, """ - |//language=file-reference - |val test = "simple" + //language=file-reference + val test = "simple" """ ) fun testInjectWithCommentOnCommentedProperty() = doFileReferenceInjectTest( """ - |// Hello - |val test = "simple" + // Hello + val test = "simple" """, """ - |// Hello - |//language=file-reference - |val test = "simple" + // Hello + //language=file-reference + val test = "simple" """ ) fun testInjectWithCommentOnPropertyWithKDoc() = doFileReferenceInjectTest( """ - |/** - | * Hi - | */ - |val test = "simple" + /** + * Hi + */ + val test = "simple" """, """ - |/** - | * Hi - | */ - |//language=file-reference - |val test = "simple" + /** + * Hi + */ + //language=file-reference + val test = "simple" """ ) fun testInjectWithCommentOnExpression() = doFileReferenceInjectTest( """ - |fun test() { - | "" - |} + fun test() { + "" + } """, """ - |fun test() { - | //language=file-reference - | "" - |} + fun test() { + //language=file-reference + "" + } """ ) fun testInjectWithCommentOnDeepExpression() = doFileReferenceInjectTest( """ - |fun test() { - | "" + "" - |} + fun test() { + "" + "" + } """, """ - |fun test() { - | "" + "" - |} + fun test() { + "" + "" + } """ ) fun testInjectOnPropertyWithAnnotation() = doFileReferenceInjectTest( """ - |val test = "simple" + val test = "simple" """, """ - |import org.intellij.lang.annotations.Language - | - |@Language("file-reference") - |val test = "simple" + import org.intellij.lang.annotations.Language + + @Language("file-reference") + val test = "simple" """ ) fun testInjectWithOnExpressionWithAnnotation() = doFileReferenceInjectTest( """ - |fun test() { - | "" - |} + fun test() { + "" + } """, """ - |fun test() { - | //language=file-reference - | "" - |} + fun test() { + //language=file-reference + "" + } """ ) @@ -212,91 +212,91 @@ class KotlinInjectionTest : AbstractInjectionTest() { fun testRemoveInjectionWithAnnotation() = doRemoveInjectionTest( """ - |import org.intellij.lang.annotations.Language - | - |@Language("file-reference") - |val test = "simple" + import org.intellij.lang.annotations.Language + + @Language("file-reference") + val test = "simple" """, """ - |import org.intellij.lang.annotations.Language - | - |val test = "simple" + import org.intellij.lang.annotations.Language + + val test = "simple" """ ) // TODO: Doesn't work. UnInjectionLanguageAction is not enabled because of absent LanguageInjectionSupport.INJECTOR_SUPPORT user data. // fun testRemoveInjectionFromOneLineFunWithAnnotation() = doRemoveInjectionTest( // """ -// |import org.intellij.lang.annotations.Language -// | -// |@Language("HTML") fun template(): String = "" +// import org.intellij.lang.annotations.Language +// +// @Language("HTML") fun template(): String = "" // """, // """ -// |import org.intellij.lang.annotations.Language -// | -// |fun template(): String = "" +// import org.intellij.lang.annotations.Language +// +// fun template(): String = "" // """ // ) // fun testRemoveInjectionOnQualifiedNameWithAnnotation() = doRemoveInjectionTest( // """ -// |import org.intellij.lang.annotations.Language -// | -// |@Language("RegExp") -// |val s = java.util.regex.Pattern.compile("Hi") +// import org.intellij.lang.annotations.Language +// +// @Language("RegExp") +// val s = java.util.regex.Pattern.compile("Hi") // """, // """ -// |val test1 = java.util.regex.Pattern.compile("Hi") +// val test1 = java.util.regex.Pattern.compile("Hi") // """ // ) fun testRemoveInjectionWithComment() = doRemoveInjectionTest( """ - |//language=file-reference - |val test = "simple" + //language=file-reference + val test = "simple" """, """ - |val test = "simple" + val test = "simple" """ ) fun testRemoveInjectionWithCommentNotFirst() = doRemoveInjectionTest( """ - |// Some comment. To do a language injection, add a line comment language=some instruction. - |// language=file-reference - |val test = "simple" + // Some comment. To do a language injection, add a line comment language=some instruction. + // language=file-reference + val test = "simple" """, """ - |// Some comment. To do a language injection, add a line comment language=some instruction. - |val test = "simple" + // Some comment. To do a language injection, add a line comment language=some instruction. + val test = "simple" """ ) fun testRemoveInjectionWithCommentAfterKDoc() = doRemoveInjectionTest( """ - |/**Property*/ - |// language=file-reference - |val test = "simple" + /**Property*/ + // language=file-reference + val test = "simple" """, """ - |/**Property*/ - |val test = "simple" + /**Property*/ + val test = "simple" """ ) fun testRemoveInjectionWithCommentInExpression() = doRemoveInjectionTest( """ - |fun test() { - | // This is my favorite part - | // language=RegExp - | "something" - |} + fun test() { + // This is my favorite part + // language=RegExp + "something" + } """, """ - |fun test() { - | // This is my favorite part - | "something" - |} + fun test() { + // This is my favorite part + "something" + } """ ) } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt b/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt index ec1f605faca..70cd3a448f3 100644 --- a/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/psi/KotlinStdlibInjectionTest.kt @@ -22,42 +22,42 @@ import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescrip class KotlinStdlibInjectionTest : AbstractInjectionTest() { fun testOnRegex0() = assertInjectionPresent( """ - |val test1 = kotlin.text.Regex("some") + val test1 = kotlin.text.Regex("some") """, RegExpLanguage.INSTANCE.id ) fun testOnRegex1() = assertInjectionPresent( """ - |val test1 = kotlin.text.Regex("some", RegexOption.COMMENTS) + val test1 = kotlin.text.Regex("some", RegexOption.COMMENTS) """, RegExpLanguage.INSTANCE.id ) fun testOnRegex2() = assertInjectionPresent( """ - |val test1 = kotlin.text.Regex("some", setOf(RegexOption.COMMENTS)) + val test1 = kotlin.text.Regex("some", setOf(RegexOption.COMMENTS)) """, RegExpLanguage.INSTANCE.id ) fun testToRegex0() = assertInjectionPresent( """ - |val test = "hi".toRegex() + val test = "hi".toRegex() """, RegExpLanguage.INSTANCE.id ) fun testToRegex1() = assertInjectionPresent( """ - |val test = "hi".toRegex(RegexOption.CANON_EQ) + val test = "hi".toRegex(RegexOption.CANON_EQ) """, RegExpLanguage.INSTANCE.id ) fun testToRegex2() = assertInjectionPresent( """ - |val test = "hi".toRegex(setOf(RegexOption.LITERAL)) + val test = "hi".toRegex(setOf(RegexOption.LITERAL)) """, RegExpLanguage.INSTANCE.id )