Skip to content

Commit 1b71ea7

Browse files
committed
Refactor TypeProcessor
1 parent 210d717 commit 1b71ea7

File tree

3 files changed

+27
-49
lines changed

3 files changed

+27
-49
lines changed

src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/option/DaoAnnotationOptionParameterCheckProcessor.kt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright Doma Tools Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.domaframework.doma.intellij.inspection.dao.processor.option
217

318
import com.intellij.codeInspection.ProblemsHolder
@@ -52,16 +67,23 @@ class DaoAnnotationOptionParameterCheckProcessor(
5267
return
5368
}
5469

55-
checkArrayOption(annotation, "include", entityClass, holder)
56-
checkArrayOption(annotation, "exclude", entityClass, holder)
70+
checkAnnotationOptions(annotation, entityClass, holder)
5771

5872
val returningOption = getDaoAnnotationOption(annotation, "returning") ?: return
5973
if (hasReturingOption()) {
60-
checkArrayOption(returningOption, "include", entityClass, holder)
61-
checkArrayOption(returningOption, "exclude", entityClass, holder)
74+
checkAnnotationOptions(returningOption, entityClass, holder)
6275
}
6376
}
6477

78+
private fun checkAnnotationOptions(
79+
annotation: PsiAnnotation,
80+
entityClass: PsiClass,
81+
holder: ProblemsHolder,
82+
) {
83+
checkArrayOption(annotation, "include", entityClass, holder)
84+
checkArrayOption(annotation, "exclude", entityClass, holder)
85+
}
86+
6587
private fun checkArrayOption(
6688
annotation: PsiAnnotation,
6789
optionName: String,

src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/returntype/ReturnTypeCheckerProcessor.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.domaframework.doma.intellij.inspection.dao.processor.returntype
1717

18-
import com.intellij.psi.PsiAnnotation
1918
import com.intellij.psi.PsiType
2019
import org.domaframework.doma.intellij.common.psi.PsiDaoMethod
2120
import org.domaframework.doma.intellij.common.util.DomaClassName
@@ -27,21 +26,13 @@ import org.domaframework.doma.intellij.extension.psi.getSuperClassType
2726
import org.domaframework.doma.intellij.inspection.dao.processor.TypeCheckerProcessor
2827

2928
abstract class ReturnTypeCheckerProcessor(
30-
private val psiDaoMethod: PsiDaoMethod,
29+
psiDaoMethod: PsiDaoMethod,
3130
private val shortName: String,
3231
) : TypeCheckerProcessor(psiDaoMethod) {
33-
protected val returningFqn = DomaClassName.RETURNING.className
3432
protected val returnType = psiDaoMethod.psiMethod.returnType
3533

3634
abstract fun checkReturnType(): ValidationResult?
3735

38-
protected fun hasReturingOption(): Boolean {
39-
val methodAnnotation: PsiAnnotation =
40-
getAnnotation(psiDaoMethod.daoType.fqdn) ?: return false
41-
val returningOption: PsiAnnotation? = getDaoAnnotationOption(methodAnnotation, "returning")
42-
return returningOption?.nameReferenceElement?.qualifiedName == returningFqn
43-
}
44-
4536
protected fun generatePsiTypeReturnTypeResult(methodOtherReturnType: PsiType): ValidationResult? =
4637
if (returnType != methodOtherReturnType) {
4738
ValidationReturnTypeResult(

src/test/kotlin/org/domaframework/doma/intellij/inspection/dao/DaoAnnotationOptionParameterInspectionTest.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)