Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Aug 19, 2025

Overview

This PR fixes an issue where invoking code completion on an SQL file that does not recognize the corresponding DAO method results in an error. The error occurs when the system attempts to retrieve the first element from an empty list during the suggestion of the top binding variable.

Bug Description

  • When code completion is executed on an SQL file without a recognized DAO method, an error occurs due to attempting to get the first element from an empty suggestion list.
  • This issue may also occur if the DAO class file is not located within the source directory or when working with temporary SQL files.

Changes

  • Removed the precondition check for the DAO method.
  • Added a condition to skip processing when the list of code completion targets is empty.
  • Adjusted the logic in SqlParameterCompletionProvider to prevent error scenarios during code completion.

Expected Behavior

  • Code completion will not continue if no available target elements are found.
  • The error is prevented by checking for empty suggestions before accessing the first element.

@xterao xterao requested a review from Copilot August 19, 2025 01:48
@xterao xterao self-assigned this Aug 19, 2025
@xterao xterao linked an issue Aug 19, 2025 that may be closed by this pull request
@github-actions github-actions bot added the fix Bug fixes label Aug 19, 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.

Pull Request Overview

This PR fixes a code completion error in SQL files that occurs when no corresponding DAO method is recognized. The fix prevents an IndexOutOfBoundsException by adding null-safety checks and removing a precondition that was too restrictive.

  • Removed debug print statement from test file
  • Added null-safety checks in SqlParameterCompletionProvider to handle cases where DAO method is not found
  • Modified early return condition to handle empty element lists regardless of DAO method presence

Reviewed Changes

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

File Description
SqlSpecificParamTypeCompleteTest.kt Removed debug print statement
SqlParameterCompletionProvider.kt Added null-safety checks and modified early return logic to prevent errors when DAO method is not found

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@xterao xterao merged commit 33b0414 into main Aug 19, 2025
5 checks passed
@xterao xterao deleted the fix/dao-method-not-recognized-autocomplete-error branch August 19, 2025 02:10
@xterao xterao added this to the 2.1.1 Release milestone Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix error on code completion for SQL file with unrecognized DAO method

2 participants