-
Notifications
You must be signed in to change notification settings - Fork 0
Formatting of SQL Function Parameters with Keyword Elements #409
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
Formatting of SQL Function Parameters with Keyword Elements #409
Conversation
…nnecessary spaces in function parameters
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 fixes SQL formatting issues when combining function names (treated as keyword elements) with other keyword elements within SQL function parameters. The changes ensure proper line breaks and indentation are maintained in such scenarios.
- Improved function name detection by checking if a FUNCTION_NAME element is followed by a LEFT_PAREN
- Fixed indentation calculation for function parameters, especially when conditional loop directives are present
- Enhanced the preprocessing logic to handle line breaks after function names more precisely
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| SqlKeywordUtil.kt | Added "year" to the SET_LINE_KEYWORDS mapping for "from" keyword |
| SqlBlockGenerator.kt | Added logic to handle "from" keyword within subgroup blocks |
| SqlFormatPreProcessor.kt | Separated LEFT_PAREN handling logic to prevent unwanted line breaks after function names |
| SqlFileBlock.kt | Enhanced FUNCTION_NAME detection to check for following LEFT_PAREN |
| SqlFunctionGroupBlock.kt | Refactored indentation calculation methods |
| SqlFunctionParamBlock.kt | Improved group indentation calculation with better spacing logic |
| SqlCommaBlock.kt | Moved to comma package and enhanced indentation handling |
| SqlArrayCommaBlock.kt | Updated import after SqlCommaBlock package move |
| Test files | Added comprehensive test cases for the new formatting behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Overview
This PR fixes formatting issues that occurred when combining function names (treated as keyword elements) and other keyword elements within SQL function parameters. Previously, line breaks and indentation were not handled correctly in such cases.
Changes
In the PreProcessor, the condition to prevent line breaks after a function name is now applied only to LEFT_PAREN, not to other elements.
These changes improve the formatting of SQL code involving function parameters and keyword elements, ensuring correct line breaks and indentation.