From a387c0f9833ac1b81bd60f3ab9029d24057f8322 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 14 Apr 2020 10:20:49 +0200 Subject: [PATCH] KtLint: Make functions needed to calculate line / column public In order to avoid duplicating code, make these functions public for use by tools that use KtLint programmatically and need to convert an offset to line / column, like detekt. --- .../src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt b/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt index e83a4a5238..eca8aa8f6c 100644 --- a/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt +++ b/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt @@ -170,7 +170,7 @@ object KtLint { .forEach { e -> params.cb(e, false) } } - private fun normalizeText(text: String): String { + fun normalizeText(text: String): String { return text .replace("\r\n", "\n") .replace("\r", "\n") @@ -317,7 +317,7 @@ object KtLint { return rootNode.getUserData(DISABLED_RULES)?.contains(fqRuleId) == false } - private fun calculateLineColByOffset(text: String): (offset: Int) -> Pair { + fun calculateLineColByOffset(text: String): (offset: Int) -> Pair { var i = -1 val e = text.length val arr = ArrayList()