Skip to content

Commit ae32b37

Browse files
committed
Add check for Doma SQL annotation in PsiLiteralExpression formatting
1 parent af46287 commit ae32b37

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ import com.intellij.openapi.command.WriteCommandAction
2020
import com.intellij.openapi.fileTypes.FileTypeManager
2121
import com.intellij.openapi.project.Project
2222
import com.intellij.psi.JavaRecursiveElementVisitor
23+
import com.intellij.psi.PsiAnnotation
2324
import com.intellij.psi.PsiDocumentManager
2425
import com.intellij.psi.PsiFile
2526
import com.intellij.psi.PsiFileFactory
2627
import com.intellij.psi.PsiLiteralExpression
2728
import com.intellij.psi.codeStyle.CodeStyleManager
2829
import org.domaframework.doma.intellij.common.util.StringUtil
30+
import org.domaframework.doma.intellij.extension.psi.DomaAnnotationType
2931
import org.domaframework.doma.intellij.formatter.processor.SqlFormatPreProcessor
3032

3133
/**
@@ -56,6 +58,7 @@ class DaoInjectionSqlVisitor(
5658

5759
override fun visitLiteralExpression(expression: PsiLiteralExpression) {
5860
super.visitLiteralExpression(expression)
61+
if ((expression.parent.parent.parent as? PsiAnnotation)?.qualifiedName != DomaAnnotationType.Sql.fqdn) return
5962
expression.value?.toString()?.let { originalText ->
6063
val existExpression =
6164
formattingTasks.find { it.expression == expression && !it.isOriginalTextBlock }

0 commit comments

Comments
 (0)