Skip to content

Implement Annotation Option Parameter Validation #234

@xterao

Description

@xterao

This update adds a code inspection feature that validates the correctness of include and exclude options used in Doma annotations by ensuring the specified field names exist in the argument type.


✅ Supported Annotations

The following Doma annotations are covered:

  • @Insert
  • @Update
  • @BatchInsert
  • @BatchUpdate
  • @MultiInsert
  • @Returning

🔍 Validation Logic

  • The inspection checks that all field names listed in the include or exclude options are defined within the method’s argument type.

  • If the argument type contains embedded types (classes annotated with @Embeddable), fields from those types are also considered valid.

  • In cases where nested fields are specified (e.g., "address.city"), the logic follows the field chain:

    • Verifies that the top-level field exists in the parameter type.
    • Resolves the field type and checks that the nested field exists within it.

🧾 Example

For the method below:

@Update(include = {"name", "salary"})
int update(Employee employee);

The inspection verifies that:

  • The parameter employee is of type Employee
  • Employee has fields name and salary
  • If not, an error highlight is shown on the invalid field name

This feature helps catch incorrect annotation parameter values early and ensures reliable mapping between annotation metadata and data model structure.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions