Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Sep 11, 2025

Problem

The intention action ConvertSqlFileToAnnotationAction was being registered multiple times for both Java/Kotlin DAO files and SQL files, causing a registration conflict error.

Relation

#451

Solution

Separated the single action class into two distinct action classes to handle each file type independently:

Changes Made

  1. Created Abstract Base Class

    • AbstractConvertSqlFileToAnnotationAction: Contains common logic for SQL file to annotation conversion
    • Subclasses implement file type checking, DAO method retrieval, and provide their own display text
  2. Split into Two Concrete Actions

    • ConvertSqlFileToAnnotationFromDaoAction: Handles conversion when invoked from DAO files (Java/Kotlin)
    • ConvertSqlFileToAnnotationFromSqlAction: Handles conversion when invoked from SQL files
  3. Updated Plugin Configuration

    • Modified plugin.xml to register each action for its specific language context
    • DAO action registered for JAVA language
    • SQL action registered for DomaSql language
  4. Added Localized Messages

    • Added separate message keys for each action to provide context-appropriate text
    • DAO action messages: convert.sql.file.to.annotation.from.dao.*
    • SQL action messages: convert.sql.file.to.annotation.from.sql.*

Benefits

  • Eliminates multiple registration error
  • Provides clearer separation of concerns
  • Allows for context-specific behavior and messaging
  • Maintains all existing functionality while improving code organization

Testing

  • Verified that the intention action appears correctly when invoked from DAO methods
  • Verified that the intention action appears correctly when invoked from SQL files
  • Confirmed that SQL file content is successfully converted to @SQL annotations in both contexts

@github-actions github-actions bot added the fix Bug fixes label Sep 11, 2025
@xterao xterao added the skip-changelog Fixes not included in the update log label Sep 11, 2025
@xterao xterao self-assigned this Sep 11, 2025
@xterao xterao requested a review from Copilot September 11, 2025 09:07
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 fixes a multiple registration error by separating a single intention action class into two distinct action classes for converting SQL files to annotations, each handling different file types (DAO files vs SQL files).

  • Split ConvertSqlFileToAnnotationAction into an abstract base class and two concrete implementations
  • Updated plugin configuration to register each action for its specific language context
  • Added separate localized messages and documentation for each action type

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
AbstractConvertSqlFileToAnnotationAction.kt New abstract base class containing common conversion logic
ConvertSqlFileToAnnotationFromDaoAction.kt New concrete action for DAO file context
ConvertSqlFileToAnnotationFromSqlAction.kt New concrete action for SQL file context
plugin.xml Updated action registrations for specific language contexts
DomaToolsBundle.properties Added separate message keys for each action
DomaToolsBundle_ja.properties Added Japanese translations for new message keys
Test files Updated to use new concrete action classes
Intention descriptions Added separate documentation for each action

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@xterao xterao force-pushed the fix/duplicate-registration-error-for-intention-actions branch from dc29e7a to 8e820f3 Compare September 11, 2025 09:31
@xterao xterao force-pushed the fix/duplicate-registration-error-for-intention-actions branch from 8e820f3 to 0dcf1b6 Compare September 11, 2025 09:36
@xterao xterao merged commit ff2ad95 into main Sep 11, 2025
5 checks passed
@xterao xterao deleted the fix/duplicate-registration-error-for-intention-actions branch September 11, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes skip-changelog Fixes not included in the update log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants