Skip to content

Commit 7d872a7

Browse files
committed
Fix test data validation for directives at the end of SQL files
1 parent 5f23d3a commit 7d872a7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ class SqlTestDataAfterBlockCommentVisitor(
5151
super.visitBlockComment(element)
5252
if (hasOtherBindVariable(element)) return
5353

54-
val nextElement = element.nextSibling ?: return
54+
val result = ValidationTestDataResult(element, shortName)
55+
val nextElement = element.nextSibling
56+
if (nextElement == null) {
57+
result.highlightElement(holder)
58+
return
59+
}
5560
if (isSqlLiteral(nextElement)) return
5661
if (isMatchListTestData(element)) return
5762

58-
val result = ValidationTestDataResult(element, shortName)
5963
result.highlightElement(holder)
6064
}
6165

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ SELECT e.employee_id AS employeeId
1111
AND e.age >= /*^ literalAge */99
1212
AND e.sub_id IN /* subIds */(1, 2, 3)
1313
AND e.sub_id IN /* subIds */(true, False, NULL)
14+
AND e.final IN <error descr="Test data is required after a bind variable directive or a literal variable directive">/* literalAge */</error>

0 commit comments

Comments
 (0)