Skip to content

Commit 88e77b3

Browse files
committed
Refactor indentation handling in SqlLiteralBlock to improve block and group indent length calculations
1 parent d992d7d commit 88e77b3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,18 @@ open class SqlLiteralBlock(
4141
override fun setParentGroupBlock(lastGroup: SqlBlock?) {
4242
super.setParentGroupBlock(lastGroup)
4343
indent.indentLevel = IndentType.NONE
44-
indent.indentLen = 0
45-
indent.groupIndentLen = 0
44+
indent.indentLen = createBlockIndentLen()
45+
indent.groupIndentLen = createGroupIndentLen()
4646
}
4747

4848
override fun buildChildren(): MutableList<AbstractBlock> = mutableListOf()
4949

5050
override fun isLeaf(): Boolean = true
51+
52+
override fun createBlockIndentLen(): Int =
53+
if (isFirstChildConditionLoopDirective() || isParentConditionLoopDirective()) {
54+
parentBlock?.indent?.indentLen ?: 0
55+
} else {
56+
0
57+
}
5158
}

0 commit comments

Comments
 (0)