Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Jun 23, 2025

Implemented return type checking for DAO methods annotated with @select and @function.

@xterao xterao added this to the 1.1.0 Release milestone Jun 23, 2025
@xterao xterao requested a review from Copilot June 23, 2025 02:35
@xterao xterao self-assigned this Jun 23, 2025

This comment was marked as outdated.

@xterao xterao force-pushed the feature/dao-method-inspection-return-type-select branch from 643da87 to a28f638 Compare June 23, 2025 02:38
@xterao xterao force-pushed the feature/dao-method-inspection-return-type-select branch from 5883cf8 to 712849b Compare June 23, 2025 02:44
@xterao xterao force-pushed the feature/dao-method-inspection-return-type-select branch from 1ae816d to 3649cfb Compare June 23, 2025 07:06
@xterao xterao requested a review from Copilot June 23, 2025 07:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Implements return type validation for DAO methods annotated with @select and @function, and refactors related processors and tests.

  • Introduce SelectAnnotationReturnTypeCheckProcessor and FunctionAnnotationReturnTypeCheckProcessor to enforce correct return types.
  • Update DaoMethodReturnTypeInspectionVisitor to register new processors and adjust base class logic (ReturnTypeCheckerProcessorTypeCheckerProcessor).
  • Refactor SelectParamTypeCheckProcessor, add StrategyParam, and extend test fixtures (addOtherJavaFile) and message bundles.

Reviewed Changes

Copilot reviewed 20 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/test/testData/src/main/java/doma/example/dao/inspection/paramtype/SelectParamTestDao.java Added new stream/collector return‐type and parameter‐type test cases
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/visitor/DaoMethodReturnTypeInspectionVisitor.kt Registered processors for @select and @function annotations
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/returntype/SelectAnnotationReturnTypeCheckProcessor.kt New processor to check @select return types based on strategy
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/returntype/FunctionAnnotationReturnTypeCheckProcessor.kt New processor to check @function return types
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/TypeCheckerProcessor.kt Refactored base class; centralized parameter and annotation option lookup
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/paramtype/SelectParamTypeCheckProcessor.kt Updated stream/collector parameter validation; removed duplication
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/StrategyParam.kt Introduced helper for reading annotation strategy parameters
src/main/resources/messages/DomaToolsBundle*.properties Added new i18n keys for invalid return type and strategy mismatch
src/test/kotlin/org/domaframework/doma/intellij/inspection/dao/AnnotationReturnTypeCheckInspectionTest.kt Adjusted test DAO names and paths for new return‐type tests
src/test/kotlin/org/domaframework/doma/intellij/DomaSqlTest.kt Added addOtherJavaFile helper for including additional test files
Comments suppressed due to low confidence (5)

src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/cheker/ProcedureFunctionResultSetParamAnnotationTypeChecker.kt:1

  • The directory name 'cheker' is misspelled; consider renaming it to 'checker' to maintain consistency and avoid confusion.
/*

src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/cheker/ProcedureFunctionInOutParamAnnotationTypeChecker.kt:1

  • The directory name 'cheker' is misspelled; consider renaming it to 'checker' to maintain consistency.
/*

src/test/testData/src/main/java/doma/example/dao/inspection/paramtype/SelectParamTestDao.java:36

  • [nitpick] The parameter name 'stream' is misleading for a BigDecimal; consider renaming it to reflect its purpose or type (e.g., 'value' or 'amount').
  BigDecimal selectFunctionInvalidParam(Function<Stream<Map<String, Pckt>>,BigDecimal> <error descr="\"java.util.Map<java.lang.String,doma.example.entity.Pckt>\" is illegal as the type argument of \"java.util.stream.Stream\"">function</error>, BigDecimal stream);

src/test/kotlin/org/domaframework/doma/intellij/inspection/dao/AnnotationParamTypeCheckInspectionTest.kt:43

  • Consider adding tests to cover parameter type inspection for @function methods, similar to existing @select parameter type tests, to ensure FunctionAnnotationReturnTypeCheckProcessor rules are validated.
        addOtherJavaFile("function", "HogeFunction.java")

src/test/kotlin/org/domaframework/doma/intellij/DomaSqlTest.kt:178

  • [nitpick] The path used in addOtherJavaFile may be missing the 'java' segment compared to addDaoJavaFile; consider aligning path conventions to ensure test files are correctly recognized.
            "main/$sourceRoot/$packagePath/$packageName/$fileName",

@xterao xterao linked an issue Jun 23, 2025 that may be closed by this pull request
@xterao xterao merged commit 09168cc into main Jun 23, 2025
5 checks passed
@xterao xterao deleted the feature/dao-method-inspection-return-type-select branch June 23, 2025 07:26
@xterao xterao linked an issue Jun 23, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement DAO method checks for methods annotated with @Select. Return Type Validation for Procedure and Function Methods

2 participants