findLastMatchingRowIndex

private fun findLastMatchingRowIndex(parsedString: String): Int

Compares the target parsed string to the un-parsed lines of the original dependencies block, and returns the index of the last row which matches the parsed string.

So, given the target:

api(projects.foo.bar) {
exclude(group = "androidx.appcompat")
}

And given the dependencies lines:

<blank line>
// Remove leaking AppCompat dependency
api(projects.foo.bar) {
exclude(group = "androidx.appcompat")
} // this is index 4
api(libs.junit)

This function would return index 4, because rows 2-4 match the target parsed string.

From this value, getOriginalString will return a multi-line string which includes the blank line and the comment.

Sources

Link copied to clipboard