Skip to content

Commit 6fc5fe2

Browse files
committed
Move SqlCommaBlock
1 parent 7b39e02 commit 6fc5fe2

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.intellij.lang.ASTNode
2727
import com.intellij.psi.PsiWhiteSpace
2828
import com.intellij.psi.formatter.common.AbstractBlock
2929
import org.domaframework.doma.intellij.common.util.TypeUtil
30+
import org.domaframework.doma.intellij.formatter.block.comma.SqlCommaBlock
3031
import org.domaframework.doma.intellij.formatter.block.comment.SqlCommentBlock
3132
import org.domaframework.doma.intellij.formatter.block.comment.SqlDefaultCommentBlock
3233
import org.domaframework.doma.intellij.formatter.block.comment.SqlElBlockCommentBlock

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package org.domaframework.doma.intellij.formatter.block.comma
1818
import com.intellij.lang.ASTNode
1919
import com.intellij.psi.formatter.common.AbstractBlock
2020
import org.domaframework.doma.intellij.formatter.block.SqlBlock
21-
import org.domaframework.doma.intellij.formatter.block.SqlCommaBlock
2221
import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2322
import org.domaframework.doma.intellij.formatter.util.IndentType
2423
import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlCommaBlock.kt renamed to src/main/kotlin/org/domaframework/doma/intellij/formatter/block/comma/SqlCommaBlock.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.formatter.block
16+
package org.domaframework.doma.intellij.formatter.block.comma
1717

1818
import com.intellij.lang.ASTNode
1919
import com.intellij.psi.formatter.common.AbstractBlock
2020
import org.domaframework.doma.intellij.common.util.TypeUtil
21+
import org.domaframework.doma.intellij.formatter.block.SqlBlock
2122
import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2223
import org.domaframework.doma.intellij.formatter.block.group.column.SqlColumnRawGroupBlock
2324
import org.domaframework.doma.intellij.formatter.block.group.keyword.SqlKeywordGroupBlock
@@ -59,6 +60,7 @@ open class SqlCommaBlock(
5960
SqlFunctionParamBlock::class,
6061
SqlWithColumnGroupBlock::class,
6162
SqlKeywordGroupBlock::class,
63+
SqlFunctionParamBlock::class,
6264
SqlElConditionLoopCommentBlock::class,
6365
)
6466

@@ -135,8 +137,15 @@ open class SqlCommaBlock(
135137
}
136138
return parentIndentLen.plus(1)
137139
} else {
138-
if (parent is SqlValuesGroupBlock) return parent.indent.indentLen
139-
return parent.indent.groupIndentLen.plus(1)
140+
return when (parent) {
141+
is SqlValuesGroupBlock -> parent.indent.indentLen
142+
is SqlElConditionLoopCommentBlock -> {
143+
val firstChild = parent.childBlocks.findLast { it is SqlFunctionParamBlock && it.endPatternBlock == null }
144+
val parentIndent = firstChild?.indent ?: parent.indent
145+
parentIndent.groupIndentLen.plus(1)
146+
}
147+
else -> parent.indent.groupIndentLen.plus(1)
148+
}
140149
}
141150
}
142151
return 1

src/main/kotlin/org/domaframework/doma/intellij/formatter/handler/CommaRawClauseHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ package org.domaframework.doma.intellij.formatter.handler
1717

1818
import com.intellij.lang.ASTNode
1919
import org.domaframework.doma.intellij.formatter.block.SqlBlock
20-
import org.domaframework.doma.intellij.formatter.block.SqlCommaBlock
2120
import org.domaframework.doma.intellij.formatter.block.comma.SqlArrayCommaBlock
21+
import org.domaframework.doma.intellij.formatter.block.comma.SqlCommaBlock
2222
import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2323
import org.domaframework.doma.intellij.formatter.block.group.column.SqlColumnRawGroupBlock
2424
import org.domaframework.doma.intellij.formatter.block.group.keyword.SqlKeywordGroupBlock

src/main/kotlin/org/domaframework/doma/intellij/formatter/handler/NotQueryGroupHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package org.domaframework.doma.intellij.formatter.handler
1717

1818
import com.intellij.lang.ASTNode
1919
import org.domaframework.doma.intellij.formatter.block.SqlBlock
20-
import org.domaframework.doma.intellij.formatter.block.SqlCommaBlock
20+
import org.domaframework.doma.intellij.formatter.block.comma.SqlCommaBlock
2121
import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2222
import org.domaframework.doma.intellij.formatter.block.conflict.SqlConflictClauseBlock
2323
import org.domaframework.doma.intellij.formatter.block.conflict.SqlConflictExpressionSubGroupBlock

0 commit comments

Comments
 (0)