Skip to content

Commit 74ac9f2

Browse files
authored
Merge pull request #247 from domaframework/feature/check-dao-method-return-type
Check DAO Method Return Type
2 parents e8ab255 + 5084a4e commit 74ac9f2

File tree

74 files changed

+1249
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1249
-182
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ The plugin also provides quick fixes for DAO methods where the required SQL file
3535
![quickfix.png](images/quickfix.png)
3636
- Checks for unused DAO method arguments.
3737
![inspection.png](images/inspection.png)
38+
- Checks that the return type of DAO method matches the expected type based on its annotation.
39+
![returnTypeInspection.png](images/returnTypeInspection.png)
3840
- Checks for undefined bind variable names.
3941
- Checks the class name and package name for static property calls.
4042
![inspectionPackageName.png](images/inspectionPackageName.png)
4143
- Optional types are recognized as their element type (e.g., a parameter of type `Optional<String>` is treated as type `String`).
4244
- For custom functions, checks for methods that are not defined in the configured ExpressionFunctions implementation class.
4345

46+
4447
## Completion
4548
Code completion is available to assist you in coding within directives.
4649

images/returnTypeInspection.png

14.2 KB
Loading

src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiDaoMethod.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class PsiDaoMethod(
6161
psiMethod.containingFile.virtualFile
6262
?: psiMethod.containingFile.originalFile.virtualFile
6363
var daoType: DomaAnnotationType = DomaAnnotationType.Unknown
64-
private var sqlFileOption: Boolean = false
64+
var sqlFileOption: Boolean = false
6565

6666
init {
6767
setDaoAnnotationType()
@@ -77,8 +77,7 @@ class PsiDaoMethod(
7777

7878
private fun setSqlFileOption() {
7979
val useSqlFileOptionAnnotation = daoType.getPsiAnnotation(psiMethod) ?: return
80-
val isSqlFile = daoType.getSqlFileVal(useSqlFileOptionAnnotation)
81-
sqlFileOption = isSqlFile == true
80+
sqlFileOption = daoType.getSqlFileVal(useSqlFileOptionAnnotation)
8281
}
8382

8483
@OptIn(ExperimentalStdlibApi::class)

src/main/kotlin/org/domaframework/doma/intellij/common/util/ForDirectiveUtil.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ import org.domaframework.doma.intellij.common.psi.PsiStaticElement
3434
import org.domaframework.doma.intellij.common.sql.PsiClassTypeUtil
3535
import org.domaframework.doma.intellij.common.sql.cleanString
3636
import org.domaframework.doma.intellij.common.sql.foritem.ForItem
37-
import org.domaframework.doma.intellij.common.sql.validator.result.ValidationCompleteResult
38-
import org.domaframework.doma.intellij.common.sql.validator.result.ValidationNotFoundTopTypeResult
39-
import org.domaframework.doma.intellij.common.sql.validator.result.ValidationPropertyResult
40-
import org.domaframework.doma.intellij.common.sql.validator.result.ValidationResult
37+
import org.domaframework.doma.intellij.common.validation.result.ValidationCompleteResult
38+
import org.domaframework.doma.intellij.common.validation.result.ValidationNotFoundTopTypeResult
39+
import org.domaframework.doma.intellij.common.validation.result.ValidationPropertyResult
40+
import org.domaframework.doma.intellij.common.validation.result.ValidationResult
4141
import org.domaframework.doma.intellij.extension.expr.accessElements
4242
import org.domaframework.doma.intellij.extension.psi.findParameter
4343
import org.domaframework.doma.intellij.extension.psi.findStaticField
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.common.sql.validator.result
16+
package org.domaframework.doma.intellij.common.validation.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
1919
import com.intellij.openapi.util.TextRange
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.common.sql.validator.result
16+
package org.domaframework.doma.intellij.common.validation.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
1919
import com.intellij.openapi.util.TextRange
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.common.sql.validator.result
16+
package org.domaframework.doma.intellij.common.validation.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
1919
import com.intellij.openapi.util.TextRange
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.common.sql.validator.result
16+
package org.domaframework.doma.intellij.common.validation.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
1919
import com.intellij.openapi.util.TextRange
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.common.sql.validator.result
16+
package org.domaframework.doma.intellij.common.validation.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
1919
import com.intellij.openapi.util.TextRange
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.domaframework.doma.intellij.common.sql.validator.result
16+
package org.domaframework.doma.intellij.common.validation.result
1717

1818
import com.intellij.codeInspection.ProblemsHolder
1919
import com.intellij.openapi.util.TextRange

0 commit comments

Comments
 (0)