Skip to content

Commit

Permalink
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.
  • Loading branch information
sschuberth committed Apr 14, 2020
1 parent a86d1c7 commit 3096f92
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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>()
Expand Down

0 comments on commit 3096f92

Please sign in to comment.