From 703e934506e8bcb273c12c67670304cbeef4a161 Mon Sep 17 00:00:00 2001 From: "vlad.koshkin" Date: Mon, 11 Dec 2023 12:35:25 +0000 Subject: [PATCH] [kotlin] IndentRawStringIntention to k2 ^KTIJ-22963 Fixed GitOrigin-RevId: 4f627ead2f85e2c81a6fe85fb0bf62e2fa87d1ba --- .../after.kt.template | 0 .../before.kt.template | 0 .../IndentRawStringIntention/description.html | 0 .../kotlin.code-insight.intentions-shared.xml | 6 +++ .../shared}/IndentRawStringIntention.kt | 11 ++--- .../SharedK1IntentionTestGenerated.java | 43 +++++++++++++++++++ .../SharedK2IntentionTestGenerated.java | 43 +++++++++++++++++++ .../intentions/indentRawString/.intention | 1 + .../indentRawString/annotationEntry.kt | 0 .../intentions/indentRawString/const.kt | 0 .../intentions/indentRawString/hasIndent.kt | 0 .../indentRawString/notRawString.kt | 0 .../intentions/indentRawString/receiver.kt | 0 .../intentions/indentRawString/simple.kt | 0 .../indentRawString/simple.kt.after | 0 .../intentions/indentRawString/singleLine.kt | 0 .../intentions/K1IntentionTestGenerated.java | 43 ------------------- .../intentions/indentRawString/.intention | 1 - .../j2k/post/processing/allProcessings.kt | 1 + .../resources/META-INF/inspections-fe10.xml | 7 --- 20 files changed, 100 insertions(+), 56 deletions(-) rename plugins/kotlin/code-insight/{descriptions => intentions-shared}/resources-en/intentionDescriptions/IndentRawStringIntention/after.kt.template (100%) rename plugins/kotlin/code-insight/{descriptions => intentions-shared}/resources-en/intentionDescriptions/IndentRawStringIntention/before.kt.template (100%) rename plugins/kotlin/code-insight/{descriptions => intentions-shared}/resources-en/intentionDescriptions/IndentRawStringIntention/description.html (100%) rename plugins/kotlin/{idea/src/org/jetbrains/kotlin/idea/intentions => code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared}/IndentRawStringIntention.kt (88%) create mode 100644 plugins/kotlin/code-insight/intentions-shared/tests/testData/intentions/indentRawString/.intention rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/annotationEntry.kt (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/const.kt (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/hasIndent.kt (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/notRawString.kt (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/receiver.kt (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/simple.kt (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/simple.kt.after (100%) rename plugins/kotlin/{idea => code-insight/intentions-shared}/tests/testData/intentions/indentRawString/singleLine.kt (100%) delete mode 100644 plugins/kotlin/idea/tests/testData/intentions/indentRawString/.intention diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/IndentRawStringIntention/after.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/IndentRawStringIntention/after.kt.template similarity index 100% rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/IndentRawStringIntention/after.kt.template rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/IndentRawStringIntention/after.kt.template diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/IndentRawStringIntention/before.kt.template b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/IndentRawStringIntention/before.kt.template similarity index 100% rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/IndentRawStringIntention/before.kt.template rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/IndentRawStringIntention/before.kt.template diff --git a/plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/IndentRawStringIntention/description.html b/plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/IndentRawStringIntention/description.html similarity index 100% rename from plugins/kotlin/code-insight/descriptions/resources-en/intentionDescriptions/IndentRawStringIntention/description.html rename to plugins/kotlin/code-insight/intentions-shared/resources-en/intentionDescriptions/IndentRawStringIntention/description.html diff --git a/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions-shared.xml b/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions-shared.xml index b9d8e048e361..0ab8c37b38ba 100644 --- a/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions-shared.xml +++ b/plugins/kotlin/code-insight/intentions-shared/resources/kotlin.code-insight.intentions-shared.xml @@ -189,5 +189,11 @@ group.names.kotlin + + kotlin + org.jetbrains.kotlin.idea.codeInsight.intentions.shared.IndentRawStringIntention + messages.KotlinBundle + group.names.kotlin + \ No newline at end of file diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt b/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/IndentRawStringIntention.kt similarity index 88% rename from plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt rename to plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/IndentRawStringIntention.kt index eb454bedb4aa..0b602d1d085f 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/IndentRawStringIntention.kt +++ b/plugins/kotlin/code-insight/intentions-shared/src/org/jetbrains/kotlin/idea/codeInsight/intentions/shared/IndentRawStringIntention.kt @@ -1,6 +1,6 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.kotlin.idea.intentions +package org.jetbrains.kotlin.idea.codeInsight.intentions.shared import com.intellij.application.options.CodeStyle import com.intellij.openapi.editor.Editor @@ -16,11 +16,13 @@ import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.psi.psiUtil.startOffset +private const val QTS = "\"\"\"" + class IndentRawStringIntention : SelfTargetingOffsetIndependentIntention( KtStringTemplateExpression::class.java, KotlinBundle.lazyMessage("indent.raw.string") ) { override fun isApplicableTo(element: KtStringTemplateExpression): Boolean { - if (!element.text.startsWith("\"\"\"")) return false + if (!element.text.startsWith(QTS)) return false if (element.parents.any { it is KtAnnotationEntry || (it as? KtProperty)?.hasModifier(KtTokens.CONST_KEYWORD) == true }) return false if (element.getQualifiedExpressionForReceiver() != null) return false val entries = element.entries @@ -44,7 +46,6 @@ class IndentRawStringIntention : SelfTargetingOffsetIndependentIntentiongroup.names.kotlin - - kotlin - org.jetbrains.kotlin.idea.intentions.IndentRawStringIntention - messages.KotlinBundle - group.names.kotlin - - kotlin org.jetbrains.kotlin.idea.intentions.ConvertVarargParameterToArrayIntention