Skip to content

Commit c99e3a1

Browse files
committed
Fix handling of escape characters for spaces and line breaks
1 parent 7c22324 commit c99e3a1

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package org.domaframework.doma.intellij.formatter.block.word
1818
import com.intellij.lang.ASTNode
1919
import org.domaframework.doma.intellij.formatter.block.SqlBlock
2020
import org.domaframework.doma.intellij.formatter.block.comment.SqlDefaultCommentBlock
21+
import org.domaframework.doma.intellij.formatter.block.comment.SqlElConditionLoopCommentBlock
2122
import org.domaframework.doma.intellij.formatter.block.group.subgroup.SqlFunctionParamBlock
2223
import org.domaframework.doma.intellij.formatter.block.group.subgroup.SqlSubGroupBlock
2324
import org.domaframework.doma.intellij.formatter.util.SqlBlockFormattingContext

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class SqlFormatPreProcessor : PreFormatProcessor {
254254
text: String,
255255
): String =
256256
if (prevElement?.elementType == SqlTypes.BLOCK_COMMENT ||
257+
prevElement?.elementType == SqlTypes.BLOCK_COMMENT_END ||
257258
(
258259
prevElement?.text?.contains(LINE_SEPARATE) == false &&
259260
prevElement.prevSibling != null

src/main/kotlin/org/domaframework/doma/intellij/formatter/visitor/SqlFormatVisitor.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class SqlFormatVisitor : PsiRecursiveElementVisitor() {
4242
}
4343

4444
if (PsiTreeUtil.getParentOfType(element, SqlBlockComment::class.java) == null) {
45+
val prevElement = PsiTreeUtil.prevLeaf(element)
46+
if (prevElement.elementType == SqlTypes.BLOCK_COMMENT_END && element !is PsiWhiteSpace) {
47+
replaces.add(element)
48+
return
49+
}
4550
when (element.elementType) {
4651
SqlTypes.KEYWORD, SqlTypes.COMMA, SqlTypes.LEFT_PAREN, SqlTypes.RIGHT_PAREN, SqlTypes.WORD, SqlTypes.FUNCTION_NAME -> {
4752
replaces.add(element)

0 commit comments

Comments
 (0)