File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
src/main/kotlin/org/domaframework/doma/intellij/formatter/visitor Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ class DaoInjectionSqlVisitor(
4848 private const val TRIPLE_QUOTE = " \"\"\" "
4949 private const val WRITE_COMMAND_NAME = " Format Injected SQL"
5050 private const val BASE_INDENT = " \t\t\t "
51+ private val COMMENT_START_REGEX = Regex (" ^[ \t ]*/[*][ \t ]*\\ *" )
52+ private val COMMENT_END_REGEX = Regex (" \\ */.*$" )
5153 }
5254
5355 private val formattingTasks = mutableListOf<FormattingTask >()
@@ -65,23 +67,22 @@ class DaoInjectionSqlVisitor(
6567
6668 private fun removeIndentLines (sqlText : String ): String {
6769 val lines = sqlText.lines()
68- val commentStartRegex = Regex (" ^[ \t ]*/[*][ \t ]*\\ *" )
69- val commentEndRegex = Regex (" \\ */.*$" )
70+
7071 var blockComment = false
7172 val removeIndentLines =
7273 lines.map { line ->
7374 if (blockComment) {
74- if (commentEndRegex .containsMatchIn(line)) {
75+ if (COMMENT_END_REGEX .containsMatchIn(line)) {
7576 blockComment = false
7677 }
7778 " $SINGLE_SPACE${line.dropWhile { it.isWhitespace() }} "
7879 } else {
7980 val baseLine =
80- if (commentStartRegex .containsMatchIn(line)) {
81+ if (COMMENT_START_REGEX .containsMatchIn(line)) {
8182 blockComment = true
8283 // Exclude spaces between `/*` and the comment content element,
8384 // as IntelliJ IDEA's Java formatter may insert a space there during formatting.
84- line.replace(commentStartRegex , " /**" )
85+ line.replace(COMMENT_START_REGEX , " /**" )
8586 } else {
8687 line
8788 }
You can’t perform that action at this time.
0 commit comments