@@ -36,7 +36,7 @@ class DaoInjectionSqlVisitor(
3636 private val element : PsiFile ,
3737 private val project : Project ,
3838) : JavaRecursiveElementVisitor() {
39- private data class FormattingTask (
39+ data class FormattingTask (
4040 val expression : PsiLiteralExpression ,
4141 val formattedText : String ,
4242 )
@@ -58,8 +58,7 @@ class DaoInjectionSqlVisitor(
5858 if (injected != null ) {
5959 // Format SQL and store the task
6060 val originalText = expression.value?.toString() ? : return
61- val removeIndent = removeIndentLines(originalText)
62- formattingTasks.add(FormattingTask (expression, removeIndent))
61+ formattingTasks.add(FormattingTask (expression, originalText))
6362 }
6463 }
6564
@@ -88,7 +87,7 @@ class DaoInjectionSqlVisitor(
8887 * Processes all collected formatting tasks in a single write action.
8988 * @param removeSpace Function to remove trailing spaces from formatted text
9089 */
91- fun processAll (removeSpace : (String , Boolean ) -> String ) {
90+ fun processAll (removeSpace : (String ) -> String ) {
9291 if (formattingTasks.isEmpty()) return
9392
9493 // Apply all formatting tasks in a single write action
@@ -130,9 +129,9 @@ class DaoInjectionSqlVisitor(
130129 /* *
131130 * Replaces the host Java string literal with formatted SQL text.
132131 */
133- private fun replaceHostStringLiteral (
132+ fun replaceHostStringLiteral (
134133 task : FormattingTask ,
135- sqlPostProcessorProcess : (String , Boolean ) -> String ,
134+ sqlPostProcessorProcess : (String ) -> String ,
136135 ) {
137136 try {
138137 // Keep the current top line indent
@@ -145,11 +144,12 @@ class DaoInjectionSqlVisitor(
145144
146145 private fun createFormattedLiteral (
147146 task : FormattingTask ,
148- sqlPostProcessorProcess : (String , Boolean ) -> String ,
147+ sqlPostProcessorProcess : (String ) -> String ,
149148 ): String {
150149 // Retrieve the same formatted string as when formatting a regular SQL file.
151- val formattedSql = formatAsTemporarySqlFile(task.formattedText)
152- val cleanedText = sqlPostProcessorProcess(formattedSql, false )
150+ val removeIndent = removeIndentLines(task.formattedText)
151+ val formattedSql = formatAsTemporarySqlFile(removeIndent)
152+ val cleanedText = sqlPostProcessorProcess(formattedSql)
153153 // Generate text aligned with the literal element using the formatted string.
154154 val newLiteralText = createFormattedLiteralText(cleanedText)
155155 val normalizedText = normalizeIndentation(newLiteralText)
0 commit comments