Skip to content

Commit 03da144

Browse files
committed
Fixed check for List type test data
1 parent 5b5f561 commit 03da144

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/kotlin/org/domaframework/doma/intellij/inspection/sql/visitor/SqlTestDataAfterBlockCommentVisitor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiComment
2020
import com.intellij.psi.PsiElement
2121
import com.intellij.psi.PsiFile
2222
import com.intellij.psi.PsiLiteralExpression
23-
import com.intellij.psi.PsiWhiteSpace
2423
import com.intellij.psi.util.PsiTreeUtil
2524
import com.intellij.psi.util.nextLeafs
2625
import org.domaframework.doma.intellij.common.isInjectionSqlFile
@@ -102,13 +101,14 @@ class SqlTestDataAfterBlockCommentVisitor(
102101
* These values can be separated by commas, and the entire list must be enclosed in parentheses.
103102
*/
104103
private fun isMatchListTestData(element: PsiElement): Boolean {
104+
if (element.nextSibling?.elementType != SqlTypes.LEFT_PAREN) return false
105105
val parenthesesListPattern =
106106
Regex(
107107
"""^\(\s*(?:(?:"[^"]*"|'[^']*'|\d+|true|false|null)\s*(?:,\s*(?:"[^"]*"|'[^']*'|\d+|true|false|null)\s*)*)?\)$""",
108108
)
109109
val testDataText =
110110
element.nextLeafs
111-
.takeWhile { it !is PsiWhiteSpace }
111+
.takeWhile { it.prevSibling?.elementType != SqlTypes.RIGHT_PAREN }
112112
.toList()
113113
.joinToString("") { it.text }
114114
return testDataText.matches(parenthesesListPattern)

src/test/testData/src/main/resources/META-INF/doma/example/dao/inspection/TestDataCheckDao/commentBlock.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ SELECT e.employee_id AS employeeId
99
/*%! This comment will be removed */
1010
WHERE e.employee_id = <error descr="Bind variables must be followed by test data">/*^ id */</error>
1111
AND e.age >= /*^ literalAge */99
12-
AND e.sub_id IN /* subIds */(1,2,3)
12+
AND e.sub_id IN /* subIds */(1, 2, 3)

0 commit comments

Comments
 (0)