Minor: extract new line allowance check
This commit is contained in:
@@ -63,9 +63,8 @@ class TrailingCommaInspection(
|
||||
}
|
||||
|
||||
val last = TrailingCommaHelper.elementAfterLastElement(commaOwner)
|
||||
val whenEntryWithoutTrailingComma =
|
||||
commaOwner is KtWhenEntry && TrailingCommaHelper.trailingCommaOrLastElement(commaOwner)?.isComma != true
|
||||
if (last?.prevLeaf(true)?.isLineBreak() == false && !whenEntryWithoutTrailingComma) {
|
||||
|
||||
if (last?.prevLeaf(true)?.isLineBreak() == false && !allowMissingLineBreak(commaOwner)) {
|
||||
registerProblemForLineBreak(
|
||||
commaOwner,
|
||||
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) {
|
||||
for (invalidComma in TrailingCommaHelper.findInvalidCommas(commaOwner)) {
|
||||
reportProblem(
|
||||
|
||||
Reference in New Issue
Block a user