Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KtLint: Make functions needed to calculate line / column public
Browse files Browse the repository at this point in the history
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.
sschuberth committed May 20, 2020
1 parent 5fa5262 commit a387c0f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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<Int, Int> {
fun calculateLineColByOffset(text: String): (offset: Int) -> Pair<Int, Int> {
var i = -1
val e = text.length
val arr = ArrayList<Int>()

0 comments on commit a387c0f

Please sign in to comment.