From 201b115ee0be4a3deef3e910b18ff408d44ed016 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Mon, 1 Jun 2020 22:27:44 +0700 Subject: [PATCH] Add hack for KotlinMultilineStringEnterHandler #KT-34566 Fixed Part of #KT-22211 --- .../lineIndent/KotlinLikeLangLineIndentProvider.kt | 9 +++++++++ tests/mute-platform.csv | 7 ------- tests/mute-platform.csv.201 | 7 ------- tests/mute-platform.csv.as40 | 7 ------- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt b/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt index ae84b752cf5..30fe761827b 100644 --- a/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt +++ b/idea/line-indent-provider/src/org/jetbrains/kotlin/idea/formatter/lineIndent/KotlinLikeLangLineIndentProvider.kt @@ -9,6 +9,7 @@ import com.intellij.formatting.Indent import com.intellij.lang.Language import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project +import com.intellij.psi.codeStyle.lineIndent.LineIndentProvider import com.intellij.psi.impl.source.codeStyle.SemanticEditorPosition import com.intellij.psi.impl.source.codeStyle.lineIndent.IndentCalculator import com.intellij.psi.impl.source.codeStyle.lineIndent.JavaLikeLangLineIndentProvider @@ -45,6 +46,14 @@ abstract class KotlinLikeLangLineIndentProvider : JavaLikeLangLineIndentProvider }\n==" } + override fun getLineIndent(project: Project, editor: Editor, language: Language?, offset: Int): String? { + // HACK: TODO: KT-34566 investigate this hack (necessary for [org.jetbrains.kotlin.idea.editor.Kotlin.MultilineStringEnterHandler]) + return if (offset > 0 && getPosition(editor, offset - 1).isAt(RegularStringPart)) + LineIndentProvider.DO_NOT_ADJUST + else + super.getLineIndent(project, editor, language, offset) + } + override fun getIndent(project: Project, editor: Editor, language: Language?, offset: Int): IndentCalculator? { val factory = IndentCalculatorFactory(project, editor) val currentPosition = getPosition(editor, offset) diff --git a/tests/mute-platform.csv b/tests/mute-platform.csv index 7f1879b4e81..cedb9480397 100644 --- a/tests/mute-platform.csv +++ b/tests/mute-platform.csv @@ -58,13 +58,6 @@ org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJ org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testSameNameInDifferentSources, KT-34542, FAIL, org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testTypeAlias, KT-34542, FAIL, org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testTypeWithSameShortName, KT-34542, FAIL, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testDontAddMarginCharWhenMultilineWithoutMargins, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testDontAddTrimCallWhenAlreadyMultilineFirstLine, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testEnterBeforeMarginChar, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testEnterInsideTextMargin, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testInsertCustomMarginInLineStart, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.WithTabs.Tabs2.testEnterInsideText, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.WithTabs.Tabs4.testEnterInsideText, KT-34566,, org.jetbrains.kotlin.idea.filters.KotlinExceptionFilterTestGenerated.testInlineFunCallInLibrary, Unprocessed,, org.jetbrains.kotlin.idea.filters.KotlinExceptionFilterTestGenerated.testInlineFunInnerClassFromLibrary, Unprocessed,, org.jetbrains.kotlin.idea.inspections.CoroutineNonBlockingContextDetectionTest.testCoroutineContextCheck, KT-34659,, diff --git a/tests/mute-platform.csv.201 b/tests/mute-platform.csv.201 index 6b47913965e..0dfcec06f3f 100644 --- a/tests/mute-platform.csv.201 +++ b/tests/mute-platform.csv.201 @@ -88,13 +88,6 @@ org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJ org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testSameNameInDifferentSources, KT-34542, FAIL, org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testTypeAlias, KT-34542, FAIL, org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testTypeWithSameShortName, KT-34542, FAIL, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testDontAddMarginCharWhenMultilineWithoutMargins, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testDontAddTrimCallWhenAlreadyMultilineFirstLine, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testEnterBeforeMarginChar, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testEnterInsideTextMargin, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testInsertCustomMarginInLineStart, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.WithTabs.Tabs2.testEnterInsideText, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.WithTabs.Tabs4.testEnterInsideText, KT-34566,, org.jetbrains.kotlin.idea.filters.KotlinExceptionFilterTestGenerated.testInlineFunCallInLibrary, Unprocessed,, org.jetbrains.kotlin.idea.filters.KotlinExceptionFilterTestGenerated.testInlineFunInnerClassFromLibrary, Unprocessed,, org.jetbrains.kotlin.idea.inspections.CoroutineNonBlockingContextDetectionTest.testCoroutineContextCheck, KT-34659,, diff --git a/tests/mute-platform.csv.as40 b/tests/mute-platform.csv.as40 index 02d810b8a75..8344df9a06a 100644 --- a/tests/mute-platform.csv.as40 +++ b/tests/mute-platform.csv.as40 @@ -60,13 +60,6 @@ org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJ org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testSameNameInDifferentSources, KT-34542, FAIL, org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testTypeAlias, KT-34542, FAIL, org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToLibrarySourceTestWithJSGenerated.testTypeWithSameShortName, KT-34542, FAIL, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testDontAddMarginCharWhenMultilineWithoutMargins, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testDontAddTrimCallWhenAlreadyMultilineFirstLine, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testEnterBeforeMarginChar, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testEnterInsideTextMargin, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.Spaces.testInsertCustomMarginInLineStart, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.WithTabs.Tabs2.testEnterInsideText, KT-34566,, -org.jetbrains.kotlin.idea.editor.MultiLineStringIndentTestGenerated.WithTabs.Tabs4.testEnterInsideText, KT-34566,, org.jetbrains.kotlin.idea.filters.KotlinExceptionFilterTestGenerated.testInlineFunCallInLibrary, Unprocessed,, org.jetbrains.kotlin.idea.filters.KotlinExceptionFilterTestGenerated.testInlineFunInnerClassFromLibrary, Unprocessed,, org.jetbrains.kotlin.idea.inspections.CoroutineNonBlockingContextDetectionTest.testCoroutineContextCheck, KT-34659,,