File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed
src/main/kotlin/org/domaframework/doma/intellij/formatter/block Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -109,16 +109,10 @@ abstract class SqlSubGroupBlock(
109109 return offset
110110 }
111111
112- override fun createGroupIndentLen (): Int {
113- return parentBlock?.let { parent ->
112+ override fun createGroupIndentLen (): Int =
113+ parentBlock?.let { parent ->
114114 parent.indent.indentLen.plus(parent.getNodeText().length.plus(1 ))
115115 } ? : indent.indentLen.plus(getNodeText().length)
116- // parentBlock?.let { parent ->
117- // // The parent groupIndent includes the number of characters in the group itself.
118- // val baseGroupLen = parent.indent.groupIndentLen
119- // return if (parent is SqlSubGroupBlock) baseGroupLen.plus(2) else baseGroupLen
120- // } ?: return 1
121- }
122116
123117 override fun isSaveSpace (lastGroup : SqlBlock ? ): Boolean {
124118 lastGroup?.let { lastBlock ->
Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ class SqlEscapeBlock(
3434 }
3535
3636 override fun createBlockIndentLen (): Int {
37- isEndEscape = parentBlock?.childBlocks?.count { it is SqlEscapeBlock }?.let { it % 2 == 0 } == true || getNodeText() == " ]"
37+ val hasEvenEscapeBlocks = parentBlock?.childBlocks?.count { it is SqlEscapeBlock }?.let { it % 2 == 0 } == true
38+ isEndEscape = hasEvenEscapeBlocks || getNodeText() == " ]"
3839 return if (isEndEscape) {
3940 0
4041 } else {
Original file line number Diff line number Diff line change @@ -48,7 +48,11 @@ open class SqlArrayWordBlock(
4848
4949 override fun buildChildren (): MutableList <AbstractBlock > = mutableListOf ()
5050
51- override fun createBlockIndentLen (): Int = (parentBlock as ? SqlElConditionLoopCommentBlock )?.indent?.groupIndentLen ? : 1
51+ override fun createBlockIndentLen (): Int =
52+ when (val parent = parentBlock) {
53+ is SqlElConditionLoopCommentBlock -> parent.indent.groupIndentLen
54+ else -> 1
55+ }
5256
5357 override fun createGroupIndentLen (): Int =
5458 parentBlock
You can’t perform that action at this time.
0 commit comments