Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented May 12, 2025

Align line comments with the same indent as the element immediately below

@xterao xterao added this to the 0.7.0 Release milestone May 12, 2025
@xterao xterao requested a review from Copilot May 12, 2025 05:58
@xterao xterao self-assigned this May 12, 2025
@xterao xterao added the bug Something isn't working label May 12, 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 the alignment of line comments in the SQL formatter. The key changes include:

  • Updating SQL test files to align line comments with the subsequent SQL element.
  • Adjusting the calculation of indentation in the Kotlin SQL line comment block.
  • Ensuring consistency between test data and formatted output files.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/test/testData/sql/formatter/Select.sql Introduces new comment lines without additional indent; verify intended alignment.
src/test/testData/sql/formatter/FormattedSelect.sql Updates comment lines with proper indentation to reflect expected output.
src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlLineCommentBlock.kt Updates indentation logic to use the parent element's indent length for consistent alignment.
Comments suppressed due to low confidence (2)

src/test/testData/sql/formatter/Select.sql:18

  • The comment '-- Line1' in the test data file does not include the indentation applied in the formatted version. Verify that the expected indentation in this test file matches the output shown in FormattedSelect.sql for consistency.
+-- Line1

src/main/kotlin/org/domaframework/doma/intellij/formatter/block/SqlLineCommentBlock.kt:58

  • Replacing the fixed return value with 'it.indent.indentLen' can improve alignment consistency; ensure this change covers all edge cases where the element's indent may vary.
return it.indent.indentLen

@xterao xterao merged commit 2be3aca into main May 12, 2025
3 checks passed
@xterao xterao deleted the fix/formatter-line-comment-indent branch May 12, 2025 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【SQL Format】Fix Line Comment Indent

2 participants