Skip to content

Commit 554ab4e

Browse files
committed
Add comments to clarify logic in calculateChildTextLength function
1 parent 49d2967 commit 554ab4e

File tree

1 file changed

+3
-0
lines changed
  • src/main/kotlin/org/domaframework/doma/intellij/formatter/block

1 file changed

+3
-0
lines changed

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlBlock.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ open class SqlBlock(
8181
private fun calculateChildTextLength(child: SqlBlock): Int {
8282
val nonCommentChildren = child.childBlocks.filterNot { it is SqlDefaultCommentBlock }
8383

84+
// True only on the first loop iteration when the current element is the first child.
85+
// If the subgroup is empty, return the length of “)”;
86+
// otherwise DEFAULT_TEXT_LENGTH_INCREMENT already adds a space, so “)” needs no extra length.
8487
return when {
8588
nonCommentChildren.isNotEmpty() -> child.getChildrenTextLen() + child.getNodeText().length
8689
isExcludedFromTextLength(child) -> if (childBlocks.firstOrNull() == child) child.getNodeText().length else 0

0 commit comments

Comments
 (0)