Skip to content

Commit 0ca7c5a

Browse files
committed
Add SqlTableModificationKeyword class for SQL formatting
1 parent bc79c6f commit 0ca7c5a

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ open class SqlFileBlock(
462462
val childBlock1: SqlBlock? = child1 as? SqlBlock
463463
val childBlock2: SqlBlock = child2 as SqlBlock
464464

465+
if(childBlock1 == null) {
466+
return SqlCustomSpacingBuilder.nonSpacing
467+
}
468+
465469
// The end of a line comment element is a newline, so just add a space for the indent.
466470
if (childBlock1 is SqlLineCommentBlock) {
467471
return SqlCustomSpacingBuilder().getSpacing(childBlock2)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.domaframework.doma.intellij.formatter.block.group.keyword.top
2+
3+
import com.intellij.lang.ASTNode
4+
import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext
5+
6+
class SqlTableModificationKeyword(node: ASTNode, context: SqlBlockFormattingContext)
7+
: SqlTopQueryGroupBlock(
8+
node,context
9+
) {
10+
}

src/main/kotlin/org/domaframework/doma/intellij/formatter/util/SqlBlockGenerator.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import org.domaframework.doma.intellij.formatter.block.group.keyword.second.SqlW
5454
import org.domaframework.doma.intellij.formatter.block.group.keyword.top.SqlDeleteQueryGroupBlock
5555
import org.domaframework.doma.intellij.formatter.block.group.keyword.top.SqlJoinQueriesGroupBlock
5656
import org.domaframework.doma.intellij.formatter.block.group.keyword.top.SqlSelectQueryGroupBlock
57+
import org.domaframework.doma.intellij.formatter.block.group.keyword.top.SqlTableModificationKeyword
5758
import org.domaframework.doma.intellij.formatter.block.group.keyword.update.SqlUpdateQueryGroupBlock
5859
import org.domaframework.doma.intellij.formatter.block.group.keyword.update.SqlUpdateSetGroupBlock
5960
import org.domaframework.doma.intellij.formatter.block.group.keyword.with.SqlWithCommonTableGroupBlock
@@ -195,12 +196,12 @@ class SqlBlockGenerator(
195196
sqlBlockFormattingCtx,
196197
)
197198

198-
else ->
199-
SqlKeywordGroupBlock(
199+
else -> {
200+
SqlTableModificationKeyword(
200201
child,
201-
indentLevel,
202202
sqlBlockFormattingCtx,
203203
)
204+
}
204205
}
205206
}
206207

0 commit comments

Comments
 (0)