Skip to content

Commit 1b6db0b

Browse files
committed
Refactor function resolution logic and improve SQL validation reporting
1 parent c9133fc commit 1b6db0b

15 files changed

+48
-52
lines changed

src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ import com.intellij.openapi.project.Project
2121
import com.intellij.psi.PsiMethod
2222
import com.intellij.psi.PsiModifier
2323
import org.domaframework.doma.intellij.common.helper.ExpressionFunctionsHelper
24-
import org.domaframework.doma.intellij.common.psi.PsiParentClass
2524
import org.domaframework.doma.intellij.extension.getJavaClazz
26-
import org.domaframework.doma.intellij.extension.psi.psiClassType
2725
import org.domaframework.doma.intellij.setting.state.DomaToolsCustomFunctionSettings
28-
import kotlin.collections.mutableSetOf
2926

3027
class StaticBuildFunctionCollector(
3128
private val project: Project,
@@ -46,14 +43,12 @@ class StaticBuildFunctionCollector(
4643
if (expressionClazz != null &&
4744
ExpressionFunctionsHelper.isInheritor(expressionClazz)
4845
) {
49-
val psiParent = PsiParentClass(expressionClazz.psiClassType)
50-
psiParent.searchMethod("")?.let { methods ->
51-
functions.addAll(
52-
methods.filter {
53-
isPublicFunction(it)
54-
},
55-
)
56-
}
46+
val methods = expressionClazz.allMethods
47+
functions.addAll(
48+
methods.filter {
49+
isPublicFunction(it)
50+
},
51+
)
5752
}
5853
}
5954

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationClassPathResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.bundle.MessageBundle
@@ -34,7 +33,6 @@ open class ValidationClassPathResult(
3433
identify: PsiElement,
3534
holder: ProblemsHolder,
3635
parent: PsiParentClass?,
37-
project: Project,
3836
) {
3937
val project = identify.project
4038
holder.registerProblem(

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationCompleteResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.common.psi.PsiParentClass
@@ -33,7 +32,6 @@ class ValidationCompleteResult(
3332
identify: PsiElement,
3433
holder: ProblemsHolder,
3534
parent: PsiParentClass?,
36-
project: Project,
3735
) {
3836
}
3937
}

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationDaoParamResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.bundle.MessageBundle
@@ -35,7 +34,6 @@ open class ValidationDaoParamResult(
3534
identify: PsiElement,
3635
holder: ProblemsHolder,
3736
parent: PsiParentClass?,
38-
project: Project,
3937
) {
4038
val project = identify.project
4139
holder.registerProblem(

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationForDirectiveItemTypeResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.bundle.MessageBundle
@@ -31,7 +30,6 @@ class ValidationForDirectiveItemTypeResult(
3130
identify: PsiElement,
3231
holder: ProblemsHolder,
3332
parent: PsiParentClass?,
34-
project: Project,
3533
) {
3634
val project = identify.project
3735
holder.registerProblem(

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationInvalidFunctionCallResult.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.bundle.MessageBundle
2322
import org.domaframework.doma.intellij.common.psi.PsiParentClass
2423

2524
/**
26-
* Non-existent package name or class
25+
* Reports invalid function calls in SQL validation.
2726
*/
2827
open class ValidationInvalidFunctionCallResult(
2928
override val identify: PsiElement,
@@ -34,7 +33,6 @@ open class ValidationInvalidFunctionCallResult(
3433
identify: PsiElement,
3534
holder: ProblemsHolder,
3635
parent: PsiParentClass?,
37-
project: Project,
3836
) {
3937
val project = identify.project
4038
holder.registerProblem(

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationNotFoundStaticPropertyResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.bundle.MessageBundle
@@ -33,7 +32,6 @@ class ValidationNotFoundStaticPropertyResult(
3332
identify: PsiElement,
3433
holder: ProblemsHolder,
3534
parent: PsiParentClass?,
36-
project: Project,
3735
) {
3836
val project = identify.project
3937
holder.registerProblem(

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationNotFoundTopTypeResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiElement
2221
import org.domaframework.doma.intellij.bundle.MessageBundle
@@ -31,7 +30,6 @@ class ValidationNotFoundTopTypeResult(
3130
identify: PsiElement,
3231
holder: ProblemsHolder,
3332
parent: PsiParentClass?,
34-
project: Project,
3533
) {
3634
val project = identify.project
3735
holder.registerProblem(

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationPropertyResult.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.domaframework.doma.intellij.common.sql.validator.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
19-
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.TextRange
2120
import com.intellij.psi.PsiClassType
2221
import com.intellij.psi.PsiElement
@@ -36,7 +35,6 @@ class ValidationPropertyResult(
3635
identify: PsiElement,
3736
holder: ProblemsHolder,
3837
parent: PsiParentClass?,
39-
project: Project,
4038
) {
4139
val project = identify.project
4240
val parentName =

src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationResult.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ abstract class ValidationResult(
3535
val element = identify ?: return
3636
if (identify is PsiErrorElement) return
3737

38-
val project = element.project
3938
val highlightElm = element.originalElement
4039
val highlightRange =
4140
TextRange(0, element.textRange.length)
@@ -45,7 +44,6 @@ abstract class ValidationResult(
4544
highlightElm,
4645
holder,
4746
parentClass,
48-
project,
4947
)
5048
}
5149

@@ -54,7 +52,6 @@ abstract class ValidationResult(
5452
identify: PsiElement,
5553
holder: ProblemsHolder,
5654
parent: PsiParentClass?,
57-
project: Project,
5855
)
5956

6057
/**

0 commit comments

Comments
 (0)