TrailingCommaInspection: report Missing trailing comma on argument

#KT-34744
This commit is contained in:
Dmitry Gridin
2020-01-23 17:33:09 +07:00
parent 5aa413014b
commit 7627834dd0
5 changed files with 411 additions and 411 deletions
@@ -141,10 +141,9 @@ class TrailingCommaInspection(
val textRange = textRange
if (isComma) return textRange
val resultRange = nextLeaf()?.leafIgnoringWhitespaceAndComments(false)?.endOffset?.takeIf { it > 0 }?.let {
TextRange.create(it - 1, it).intersection(parent.textRange)
return nextLeaf()?.leafIgnoringWhitespaceAndComments(false)?.endOffset?.takeIf { it > 0 }?.let {
TextRange.create(it - 1, it).intersection(textRange)
} ?: TextRange.create(textRange.endOffset - 1, textRange.endOffset)
return resultRange.shiftRight(1)
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2,4 +2,4 @@
// FIX: Add trailing comma
fun a(i: Int,
b: Boolean)<caret> = Unit
b: Boolea<caret>n) = Unit
+1 -1
View File
@@ -2,4 +2,4 @@
// PROBLEM: none
fun a(i: Int,
b: Boolea<caret>n) = Unit
b: Boole<caret>an) = Unit
+2 -1
View File
@@ -2,4 +2,5 @@
// PROBLEM: none
fun a(i: Int,
b: Boolean) <caret>= Unit
b: Boolean <caret>
) = Unit