Minor: extract new line allowance check
This commit is contained in:
@@ -63,9 +63,8 @@ class TrailingCommaInspection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val last = TrailingCommaHelper.elementAfterLastElement(commaOwner)
|
val last = TrailingCommaHelper.elementAfterLastElement(commaOwner)
|
||||||
val whenEntryWithoutTrailingComma =
|
|
||||||
commaOwner is KtWhenEntry && TrailingCommaHelper.trailingCommaOrLastElement(commaOwner)?.isComma != true
|
if (last?.prevLeaf(true)?.isLineBreak() == false && !allowMissingLineBreak(commaOwner)) {
|
||||||
if (last?.prevLeaf(true)?.isLineBreak() == false && !whenEntryWithoutTrailingComma) {
|
|
||||||
registerProblemForLineBreak(
|
registerProblemForLineBreak(
|
||||||
commaOwner,
|
commaOwner,
|
||||||
last,
|
last,
|
||||||
@@ -74,6 +73,11 @@ class TrailingCommaInspection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun allowMissingLineBreak(commaOwner: KtElement): Boolean {
|
||||||
|
return commaOwner is KtWhenEntry
|
||||||
|
&& TrailingCommaHelper.trailingCommaOrLastElement(commaOwner)?.isComma != true
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkCommaPosition(commaOwner: KtElement) {
|
private fun checkCommaPosition(commaOwner: KtElement) {
|
||||||
for (invalidComma in TrailingCommaHelper.findInvalidCommas(commaOwner)) {
|
for (invalidComma in TrailingCommaHelper.findInvalidCommas(commaOwner)) {
|
||||||
reportProblem(
|
reportProblem(
|
||||||
|
|||||||
Reference in New Issue
Block a user