Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented May 14, 2025

Add case-specific error messages for exceptional scenarios during field-access element parsing. Errors are now reported for:

  • The source of a for directive element isn’t an Iterable type.
  • A static-property call whose first property isn’t declared both static and public.
  • DAO-parameter usage validation when a parameter name duplicates a for directive element name and isn’t used.
  • the top of the field access element is of a type that cannot be converted to PsiClassType

Additionally, refactor the SQL inspection Visitor by extracting each processing task into separate Processor classes.

@xterao xterao added this to the 0.7.0 Release milestone May 14, 2025
@xterao xterao requested a review from Copilot May 14, 2025 08:57
@xterao xterao self-assigned this May 14, 2025
@xterao xterao added enhancement New feature or request feature labels May 14, 2025
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@xterao xterao requested a review from Copilot May 14, 2025 09:14
@xterao xterao linked an issue May 14, 2025 that may be closed by this pull request
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

This PR introduces case-specific error messages during field-access element parsing and refactors the SQL inspection visitor code by extracting distinct processing tasks into dedicated processor classes. Key changes include:

  • Enhanced error messages and validations in both SQL and Java/Kotlin inspection components.
  • Extraction of processor classes (e.g. InspectionStaticFieldAccessVisitorProcessor, InspectionPrimaryVisitorProcessor, etc.) to modularize SQL processing tasks.
  • Updates to test data and message bundles to support the new error cases.

Reviewed Changes

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

Show a summary per file
File Description
duplicateForDirectiveDefinitionNames.sql Added test SQL with duplicate for directive definitions to trigger the new error reporting.
DaoMethodVariableInspectionTestDao.java Updated method signatures and inline error markers to reflect duplicate parameter scenarios.
DomaUseVariableTest.kt Updated test to include the new duplicate for directive definition SQL.
DomaToolsBundle_ja.properties & DomaToolsBundle.properties Added and modified error message keys for specific SQL inspection error cases.
SqlElIdExprReference.kt, SqlVisitorBase.kt, SqlInspectionVisitor.kt Adjusted references and integrated new processor classes for error validations.
Inspection Visitor Processors (several files) Introduced dedicated processor classes for static field access, primary expressions, for directive, and field access validations.
DaoMethodVariableInspector.kt Updated logic to differentiate between duplicate for directive definitions and unused SQL parameters.
DocumentDaoParameterGenerator.kt, SqlParameterCompletionProvider.kt Minor adjustments to ensure proper type handling in for directive processing.
ForDirectiveUtil.kt & Validation Results Modified utility functions to incorporate DAO method context for determining class types and error highlight results.
Comments suppressed due to low confidence (1)

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

  • The function 'getTopForDirectiveDeclarationClassType' is expected to return a PsiParentClass or null, but this branch returns a ValidationNotFoundTopTypeResult, which may violate the method's type contract. Consider returning null or refactoring to ensure consistent return types that match PsiParentClass?
val classType = parentType as? PsiClassType ?: return ValidationNotFoundTopTypeResult(blocks.first(), shortName)

@xterao xterao force-pushed the feature/more-detailed-error-messages branch from 58a7bc0 to a6993ba Compare May 14, 2025 09:22
@xterao xterao merged commit d801f11 into main May 14, 2025
3 checks passed
@xterao xterao deleted the feature/more-detailed-error-messages branch May 14, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More detailed error messages

2 participants