From 47ff88e2fa3c8c6cf5e909782b9749555cef0999 Mon Sep 17 00:00:00 2001 From: Paul Dingemans Date: Sat, 23 Nov 2024 16:18:03 +0100 Subject: [PATCH] Format with Ktlint 1.4.1 --- .../src/main/kotlin/com/nbadal/ktlint/KtlintAnnotator.kt | 4 +++- .../main/kotlin/com/nbadal/ktlint/KtlintErrorHandler.kt | 1 + plugin/src/main/kotlin/com/nbadal/ktlint/KtlintFormat.kt | 9 ++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintAnnotator.kt b/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintAnnotator.kt index 4201df04..eaf142e3 100644 --- a/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintAnnotator.kt +++ b/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintAnnotator.kt @@ -58,7 +58,9 @@ internal class KtlintAnnotator : ExternalAnnotator, List null + else -> { + null + } } override fun doAnnotate(collectedInfo: List?): List? = diff --git a/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintErrorHandler.kt b/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintErrorHandler.kt index e9c4d072..aa57f6ad 100644 --- a/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintErrorHandler.kt +++ b/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintErrorHandler.kt @@ -41,6 +41,7 @@ class KtlintErrorHandler : ErrorReportSubmitter() { is IdeaReportingEvent -> { rollbar.error(event.data.throwable, extras) } + else -> { rollbar.error(event.throwable, extras, event.message) } diff --git a/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintFormat.kt b/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintFormat.kt index d989c7a7..68d596e7 100644 --- a/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintFormat.kt +++ b/plugin/src/main/kotlin/com/nbadal/ktlint/KtlintFormat.kt @@ -114,7 +114,7 @@ private fun executeKtlint( } else { val formattedCode = when (ktlintFormatAutoCorrectHandler) { - is KtlintFileAutocorrectHandler -> + is KtlintFileAutocorrectHandler -> { ktlintRuleEngine.format(code) { lintError -> if (lintError.isIgnoredInBaseline(baselineErrors)) { AutocorrectDecision.NO_AUTOCORRECT @@ -123,8 +123,9 @@ private fun executeKtlint( AutocorrectDecision.ALLOW_AUTOCORRECT } } + } - is KtlintBlockAutocorrectHandler -> + is KtlintBlockAutocorrectHandler -> { ktlintRuleEngine.format(code) { lintError -> if (lintError.isIgnoredInBaseline(baselineErrors)) { AutocorrectDecision.NO_AUTOCORRECT @@ -139,8 +140,9 @@ private fun executeKtlint( } } } + } - is KtlintViolationAutocorrectHandler -> + is KtlintViolationAutocorrectHandler -> { ktlintRuleEngine.format(code) { lintError -> if (lintError == ktlintFormatAutoCorrectHandler.lintError) { AutocorrectDecision.ALLOW_AUTOCORRECT @@ -148,6 +150,7 @@ private fun executeKtlint( AutocorrectDecision.NO_AUTOCORRECT } } + } } if (formattedCode != code.content) { psiFile.viewProvider.document.setText(formattedCode)