Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Aug 19, 2025

Running the SQL formatter on certain SQL statements causes IntelliJ IDEA to freeze.

This issue occurs specifically when a literal value (number, string, boolean, etc.) is passed as a parameter in a method call.

  • Problem case: Literals used as method call parameters.

  • Not affected: Cases where DAO method parameters are used, or when literals are used outside of method parameters.

Example that triggers the freeze:

SELECT *
FROM employee
WHERE id = /* employee.getParam(1) */0

The formatter now handles this case without causing IDEA to hang.

Fix Details

Properly implemented child block parsing within parameter blocks.

Ensured a Primary block is generated so that spacing settings do not return null.

@xterao xterao self-assigned this Aug 19, 2025
@github-actions github-actions bot added the fix Bug fixes label Aug 19, 2025
@xterao xterao linked an issue Aug 19, 2025 that may be closed by this pull request
@xterao xterao requested a review from Copilot August 19, 2025 01:48
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 freeze issue in the SQL formatter when literal values are used as parameters in method calls within SQL comments. The fix involves properly implementing child block parsing and spacing logic to handle parameter blocks correctly.

  • Enhanced parameter block handling to support literal values in method calls
  • Fixed spacing logic to prevent null spacing configurations that caused the freeze
  • Added proper child block generation for expression elements

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
StaticFieldAccess_format.sql Test data updated to include literal parameter (0) in method call
StaticFieldAccess.sql Test data updated to include literal parameter (0) in method call
SqlExprBlock.kt Simplified child block addition and changed spacing from null to nonSpacing
SqlElPrimaryBlock.kt Added comprehensive getBlock method to handle different expression types
SqlElParametersBlock.kt Enhanced parameter handling with proper spacing logic and additional expression type support

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 added this to the 2.1.1 Release milestone Aug 19, 2025
@xterao xterao merged commit 0afbd7b into main Aug 19, 2025
5 checks passed
@xterao xterao deleted the fix/sql-format-freeze-during branch August 19, 2025 03:58
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.

IDE Freeze During SQL Formatting

2 participants