-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Formatting Rules for CASE ... END Clause #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
xterao
merged 4 commits into
feature/sql-format-official-version
from
feature/sql-format-support-case-end
Jul 11, 2025
Merged
Fix Formatting Rules for CASE ... END Clause #314
xterao
merged 4 commits into
feature/sql-format-official-version
from
feature/sql-format-support-case-end
Jul 11, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…better organization
0979977 to
3c4aa79
Compare
Contributor
There was a problem hiding this 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 enhances the SQL formatter to correctly break and indent WHEN/ELSE branches and right-align the END in a CASE expression.
- Adds a new test case and expected formatted SQL for
CASE … ENDexpressions. - Introduces
INLINEandINLINE_SECONDindent types and refactors formatter blocks to use them. - Updates related processor logic, imports, and indentation calculations for inline keyword groups.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/testData/sql/formatter/SelectCaseEnd_format.sql | Expected formatted output for CASE…END test |
| src/test/testData/sql/formatter/SelectCaseEnd.sql | Raw SQL input for CASE…END formatting test |
| src/test/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatterTest.kt | Added testSelectCaseEndFormatter |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/util/SqlKeywordUtil.kt | Added INLINE & INLINE_SECOND indent types |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/util/SqlBlockUtil.kt | Aligned multiline parameter formatting |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlSetParentGroupProcessor.kt | Simplified updateInlineSecondGroupBlockParentAndAddGroup signature |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/keyword/inline/SqlInlineSecondGroupBlock.kt | Refined indent logic and isEndCase detection |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/block/group/keyword/inline/SqlInlineGroupBlock.kt | Refactored indent calculations and added inlineConditions list |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlCommaBlock.kt | Extracted expectedTypes and adjusted isSaveSpace logic |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlBlock.kt | Updated imports and inline-second group processor invocation |
...omaframework/doma/intellij/formatter/block/group/keyword/inline/SqlInlineSecondGroupBlock.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/util/SqlKeywordUtil.kt
Show resolved
Hide resolved
...omaframework/doma/intellij/formatter/block/group/keyword/inline/SqlInlineSecondGroupBlock.kt
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updated the formatter to correctly set line-break flags for "WHEN", "ELSE", and "END" within a "CASE" expression.
Formatting Behavior
The first "WHEN" clause remains inline with "CASE".
The second and subsequent branches ("WHEN", "ELSE") are:
The "END" keyword is right-aligned with the initial "CASE" keyword.
Example (Formatted Output)