Skip to content

Commit 5883cf8

Browse files
committed
Add validation results for invalid return types and select strategy in DAO methods
1 parent a28f638 commit 5883cf8

File tree

4 files changed

+97
-4
lines changed

4 files changed

+97
-4
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
*/
16+
package org.domaframework.doma.intellij.common.validation.result
17+
18+
import com.intellij.codeInspection.ProblemsHolder
19+
import com.intellij.openapi.util.TextRange
20+
import com.intellij.psi.PsiElement
21+
import org.domaframework.doma.intellij.bundle.MessageBundle
22+
import org.domaframework.doma.intellij.common.psi.PsiParentClass
23+
24+
class ValidationMethodInvalidReturnTypeResult(
25+
override val identify: PsiElement?,
26+
override val shortName: String = "",
27+
private val returnTypeName: String,
28+
) : ValidationResult(identify, null, shortName) {
29+
override fun setHighlight(
30+
highlightRange: TextRange,
31+
identify: PsiElement,
32+
holder: ProblemsHolder,
33+
parent: PsiParentClass?,
34+
) {
35+
val project = identify.project
36+
holder.registerProblem(
37+
identify,
38+
MessageBundle.message("inspection.invalid.dao.returnType.invalid", returnTypeName),
39+
problemHighlightType(project, shortName),
40+
highlightRange,
41+
)
42+
}
43+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiElement
2121
import org.domaframework.doma.intellij.bundle.MessageBundle
2222
import org.domaframework.doma.intellij.common.psi.PsiParentClass
2323

24-
class ValidationMethodProcedureParamsSupportGenericParamResult(
24+
class ValidationMethodParamsSupportGenericParamResult(
2525
override val identify: PsiElement?,
2626
override val shortName: String = "",
2727
private val paramTypeName: String,

src/main/kotlin/org/domaframework/doma/intellij/common/validation/result/ValidationMethodSelectStrategyParamResult.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import org.domaframework.doma.intellij.common.psi.PsiParentClass
2424
class ValidationMethodSelectStrategyParamResult(
2525
override val identify: PsiElement?,
2626
override val shortName: String = "",
27-
private val selectTypeName: String,
28-
private val requireClassName: String,
27+
private val genericTypeName: String,
28+
private val parentParamTypeName: String,
2929
) : ValidationResult(identify, null, shortName) {
3030
override fun setHighlight(
3131
highlightRange: TextRange,
@@ -36,7 +36,11 @@ class ValidationMethodSelectStrategyParamResult(
3636
val project = identify.project
3737
holder.registerProblem(
3838
identify,
39-
MessageBundle.message("inspection.invalid.dao.select.param.strategy.require.type", selectTypeName, requireClassName),
39+
MessageBundle.message(
40+
"inspection.invalid.dao.select.param.strategy.require.type",
41+
genericTypeName,
42+
parentParamTypeName,
43+
),
4044
problemHighlightType(project, shortName),
4145
highlightRange,
4246
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
*/
16+
package org.domaframework.doma.intellij.common.validation.result
17+
18+
import com.intellij.codeInspection.ProblemsHolder
19+
import com.intellij.openapi.util.TextRange
20+
import com.intellij.psi.PsiElement
21+
import org.domaframework.doma.intellij.bundle.MessageBundle
22+
import org.domaframework.doma.intellij.common.psi.PsiParentClass
23+
24+
class ValidationMethodSelectStrategyReturnTypeResult(
25+
override val identify: PsiElement?,
26+
override val shortName: String = "",
27+
private val resultType: String,
28+
) : ValidationResult(identify, null, shortName) {
29+
override fun setHighlight(
30+
highlightRange: TextRange,
31+
identify: PsiElement,
32+
holder: ProblemsHolder,
33+
parent: PsiParentClass?,
34+
) {
35+
val project = identify.project
36+
holder.registerProblem(
37+
identify,
38+
MessageBundle.message(
39+
"inspection.invalid.dao.select.returnType.strategy",
40+
resultType,
41+
),
42+
problemHighlightType(project, shortName),
43+
highlightRange,
44+
)
45+
}
46+
}

0 commit comments

Comments
 (0)