File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,11 @@ class SqlInGroupBlock(
4040
4141 override fun createBlockIndentLen (): Int {
4242 parentBlock?.let { parent ->
43- if (parent is SqlElConditionLoopCommentBlock ) return parent.indent.groupIndentLen
43+ if (parent is SqlElConditionLoopCommentBlock &&
44+ parent.checkConditionLoopDirectiveParentBlock(this )
45+ ) {
46+ return parent.indent.indentLen
47+ }
4448 val prevChildren = this .prevBlocks
4549 val children = prevChildren.filter { it !is SqlDefaultCommentBlock }
4650 val firstChild = children.firstOrNull()
@@ -52,13 +56,16 @@ class SqlInGroupBlock(
5256 }
5357
5458 val dotCount = sumChildren.count { it.node.elementType == SqlTypes .DOT }
59+ val parentText = (parent as ? SqlElConditionLoopCommentBlock )?.parentBlock?.getNodeText()?.length ? : 0
60+
5561 return sumChildren
5662 .sumOf { prev ->
5763 prev
5864 .getChildrenTextLen()
5965 .plus(prev.getNodeText().length.plus(1 ))
6066 }.minus(dotCount * 2 )
6167 .plus(parent.indent.groupIndentLen)
68+ .plus(parentText)
6269 .plus(1 )
6370 }
6471 return 0
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import org.domaframework.doma.intellij.formatter.block.SqlBlock
2121import org.domaframework.doma.intellij.formatter.block.comment.SqlDefaultCommentBlock
2222import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2323import org.domaframework.doma.intellij.formatter.block.group.keyword.SqlJoinGroupBlock
24+ import org.domaframework.doma.intellij.formatter.block.group.keyword.SqlKeywordGroupBlock
2425import org.domaframework.doma.intellij.formatter.block.group.keyword.condition.SqlConditionalExpressionGroupBlock
2526import org.domaframework.doma.intellij.formatter.block.group.keyword.top.SqlJoinQueriesGroupBlock
2627import org.domaframework.doma.intellij.formatter.block.group.keyword.with.SqlWithCommonTableGroupBlock
@@ -65,7 +66,11 @@ open class SqlSubQueryGroupBlock(
6566 is SqlJoinQueriesGroupBlock -> return parent.indent.indentLen
6667 is SqlJoinGroupBlock -> return parent.indent.groupIndentLen.plus(1 )
6768 else -> {
68- val children = prevChildren?.filter { it !is SqlDefaultCommentBlock }
69+ val children =
70+ prevChildren?.filter {
71+ it !is SqlDefaultCommentBlock &&
72+ (parent as ? SqlKeywordGroupBlock )?.topKeywordBlocks?.contains(it) == false
73+ }
6974 // Retrieve the list of child blocks excluding the conditional directive that appears immediately before this block,
7075 // as it is already included as a child block.
7176 val sumChildren =
You can’t perform that action at this time.
0 commit comments