@@ -26,7 +26,6 @@ import com.intellij.psi.PsiLiteralExpression
2626import com.intellij.psi.codeStyle.CodeStyleManager
2727import org.domaframework.doma.intellij.common.util.InjectionSqlUtil
2828import org.domaframework.doma.intellij.common.util.StringUtil
29- import org.domaframework.doma.intellij.common.util.StringUtil.SINGLE_SPACE
3029import kotlin.text.isBlank
3130
3231/* *
@@ -49,7 +48,6 @@ class DaoInjectionSqlVisitor(
4948 private const val WRITE_COMMAND_NAME = " Format Injected SQL"
5049 private const val BASE_INDENT = " \t\t\t "
5150 private val COMMENT_START_REGEX = Regex (" ^[ \t ]*/[*][ \t ]*\\ *" )
52- private val COMMENT_END_REGEX = Regex (" \\ */.*$" )
5351 }
5452
5553 private val formattingTasks = mutableListOf<FormattingTask >()
@@ -71,23 +69,16 @@ class DaoInjectionSqlVisitor(
7169 var blockComment = false
7270 val removeIndentLines =
7371 lines.map { line ->
74- if (blockComment) {
75- if (COMMENT_END_REGEX .containsMatchIn(line)) {
76- blockComment = false
72+ val baseLine =
73+ if (COMMENT_START_REGEX .containsMatchIn(line)) {
74+ blockComment = true
75+ // Exclude spaces between `/*` and the comment content element,
76+ // as IntelliJ IDEA's Java formatter may insert a space there during formatting.
77+ line.replace(COMMENT_START_REGEX , " /**" )
78+ } else {
79+ line
7780 }
78- " $SINGLE_SPACE${line.dropWhile { it.isWhitespace() }} "
79- } else {
80- val baseLine =
81- if (COMMENT_START_REGEX .containsMatchIn(line)) {
82- blockComment = true
83- // Exclude spaces between `/*` and the comment content element,
84- // as IntelliJ IDEA's Java formatter may insert a space there during formatting.
85- line.replace(COMMENT_START_REGEX , " /**" )
86- } else {
87- line
88- }
89- baseLine.dropWhile { it.isWhitespace() }
90- }
81+ baseLine.dropWhile { it.isWhitespace() }
9182 }
9283
9384 return removeIndentLines.joinToString(StringUtil .LINE_SEPARATE )
0 commit comments