From 39db76b2ab1b0b44c0a09515ed72604fe4090d7b Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Thu, 7 Nov 2019 17:30:19 +0900 Subject: [PATCH] "Indent raw string" intention: do not suggest in const #KT-34784 Fixed --- .../kotlin/idea/intentions/IndentRawStringIntention.kt | 5 +++++ .../intentions/indentRawString/annotationEntry.kt | 7 +++++++ idea/testData/intentions/indentRawString/const.kt | 6 ++++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 10 ++++++++++ 4 files changed, 28 insertions(+) create mode 100644 idea/testData/intentions/indentRawString/annotationEntry.kt create mode 100644 idea/testData/intentions/indentRawString/const.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt index 1b92fa5bc5b..012ac2e8a71 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt @@ -8,9 +8,13 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.application.options.CodeStyle import com.intellij.openapi.editor.Editor import com.intellij.psi.codeStyle.CodeStyleManager +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.KtAnnotationEntry +import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtStringTemplateExpression import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver +import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.psi.psiUtil.startOffset class IndentRawStringIntention : SelfTargetingIntention( @@ -19,6 +23,7 @@ class IndentRawStringIntention : SelfTargetingIntention) +class Test + +annotation class Ann(val s: String) \ No newline at end of file diff --git a/idea/testData/intentions/indentRawString/const.kt b/idea/testData/intentions/indentRawString/const.kt new file mode 100644 index 00000000000..fbd5e825ffb --- /dev/null +++ b/idea/testData/intentions/indentRawString/const.kt @@ -0,0 +1,6 @@ +// IS_APPLICABLE: false +object Test { + const val foo = """foo +bar +baz""" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index bc850ffed78..447d5cbb4d5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -8712,6 +8712,16 @@ public class IntentionTestGenerated extends AbstractIntentionTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/indentRawString"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), true); } + @TestMetadata("annotationEntry.kt") + public void testAnnotationEntry() throws Exception { + runTest("idea/testData/intentions/indentRawString/annotationEntry.kt"); + } + + @TestMetadata("const.kt") + public void testConst() throws Exception { + runTest("idea/testData/intentions/indentRawString/const.kt"); + } + @TestMetadata("hasIndent.kt") public void testHasIndent() throws Exception { runTest("idea/testData/intentions/indentRawString/hasIndent.kt");