Skip to content

Commit 2b8e055

Browse files
authored
Merge pull request #371 from domaframework/fix/used-dao-paramtype-selectoptions
Fix DAO parameter type select options handling
2 parents 35ae19d + bd6f0c8 commit 2b8e055

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/kotlin/org/domaframework/doma/intellij/extension/psi/PsiParameterExtension.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ private val ignoreUsageCheckType =
2929

3030
fun PsiParameter.isIgnoreUsageCheck(): Boolean =
3131
ignoreUsageCheckType.any { type ->
32-
getSuperClassType(type) != null
32+
when (type) {
33+
DomaClassName.SELECT_OPTIONS -> {
34+
// Only ignore the exact SelectOptions class, not its subtypes
35+
val clazzType = this.typeElement?.type as? PsiClassType
36+
clazzType?.rawType()?.canonicalText == type.className
37+
}
38+
else -> getSuperClassType(type) != null
39+
}
3340
}
3441

3542
fun PsiParameter.getSuperClassType(superClassType: DomaClassName): PsiClassType? {

src/test/testData/src/main/java/doma/example/dao/DaoMethodVariableInspectionTestDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Project selectOptionDoesNotCauseError(Employee <error descr="There are unused pa
5656
@Sql("SELECT * FROM project WHERE name = /* searchName */'test'")
5757
Project selectHogeOption(Employee <error descr="There are unused parameters in the SQL [employee]">employee</error>,
5858
String searchName,
59-
HogeSelectOptions options);
59+
HogeSelectOptions <error descr="There are unused parameters in the SQL [options]">options</error>);
6060

6161
@Select(strategy = SelectType.COLLECT)
6262
Project collectDoesNotCauseError(Employee <error descr="There are unused parameters in the SQL [employee]">employee</error>,

0 commit comments

Comments
 (0)