Skip to content

Commit 763c80f

Browse files
committed
Line break correction for conditional directives is handled separately
1 parent 6321d05 commit 763c80f

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,7 @@ open class SqlBlock(
136136
(prevBlock.conditionType.isElse() || prevBlock.conditionType.isEnd())
137137
val hasNoChildrenExceptLast = parent.childBlocks.dropLast(1).isEmpty()
138138

139-
if (parent.conditionType.isElse()) {
140-
return prevBlocks.isEmpty()
141-
}
142-
143-
val isConditionDirectiveParentGroup =
144-
parent.parentBlock?.let { grand ->
145-
grand is SqlNewGroupBlock
146-
} == true
147-
148-
return isPrevBlockElseOrEnd || (hasNoChildrenExceptLast && isConditionDirectiveParentGroup)
139+
return isPrevBlockElseOrEnd || hasNoChildrenExceptLast
149140
}
150141

151142
private fun shouldSaveSpaceForNewGroup(parent: SqlNewGroupBlock): Boolean {

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/keyword/condition/SqlConditionalExpressionGroupBlock.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package org.domaframework.doma.intellij.formatter.block.group.keyword.condition
1717

1818
import com.intellij.lang.ASTNode
1919
import org.domaframework.doma.intellij.formatter.block.SqlBlock
20-
import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2120
import org.domaframework.doma.intellij.formatter.block.group.keyword.SqlKeywordGroupBlock
2221
import org.domaframework.doma.intellij.formatter.block.group.subgroup.SqlSubGroupBlock
2322
import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext
@@ -46,15 +45,7 @@ class SqlConditionalExpressionGroupBlock(
4645
}
4746
}
4847

49-
override fun createBlockIndentLen(): Int =
50-
parentBlock?.let { parent ->
51-
if (parent is SqlElConditionLoopCommentBlock) {
52-
parent.indent.groupIndentLen
53-
} else {
54-
parent.indent.groupIndentLen.plus(1)
55-
}
56-
}
57-
?: offset
48+
override fun createBlockIndentLen(): Int = parentBlock?.indent?.groupIndentLen?.plus(1) ?: 1
5849

5950
override fun createGroupIndentLen(): Int = indent.indentLen.plus(1)
6051
}

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/subgroup/SqlSubGroupBlock.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ abstract class SqlSubGroupBlock(
5050
SqlWithCommonTableGroupBlock::class,
5151
SqlWithColumnGroupBlock::class,
5252
SqlCreateViewGroupBlock::class,
53-
SqlElConditionLoopCommentBlock::class,
5453
)
5554
}
5655

src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlFormatPostProcessor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import org.domaframework.doma.intellij.setting.SqlLanguage
2929

3030
class SqlFormatPostProcessor : SqlPostProcessor() {
3131
override fun processElement(
32-
source: PsiElement,
32+
element: PsiElement,
3333
settings: CodeStyleSettings,
34-
): PsiElement = source
34+
): PsiElement = element
3535

3636
override fun processText(
3737
source: PsiFile,

0 commit comments

Comments
 (0)