feat: add whenNeeded and whenFormattedMultiLine brace modes#7
Open
steffen-heil-secforge wants to merge 1 commit intomainfrom
Open
feat: add whenNeeded and whenFormattedMultiLine brace modes#7steffen-heil-secforge wants to merge 1 commit intomainfrom
steffen-heil-secforge wants to merge 1 commit intomainfrom
Conversation
7ebd588 to
bd26b84
Compare
b00c587 to
f8791bc
Compare
This commit introduces two new brace usage modes for control flow statements: whenNeeded and whenFormattedMultiLine, providing more granular control over brace insertion. Added enum variants: UseBraces::WhenNeeded: Only uses braces when syntactically required (empty blocks, declarations, multiple statements, or to avoid dangling else ambiguity) UseBraces::WhenFormattedMultiLine: Uses braces when the formatted body spans multiple lines, removing them for single-line statements Implementation changes: Replaced force_use_braces_for_stmt with more flexible helper functions (get_use_braces_for_node, get_use_braces_for_stmt) Added contains_dangling_if to detect dangling else problems Added use_braces_for_then and use_braces_for_else to enforce braces when required for correctness (declarations, dangling else) Updated gen_conditional_brace_body to support new brace modes Updated gen_if_stmt to intelligently apply braces based on context Test coverage: Added 13 test files covering whenNeeded and whenFormattedMultiLine modes All 660 spec tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
f8791bc to
c2de1b2
Compare
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
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.
This commit introduces two new brace usage modes for control flow statements: whenNeeded and whenFormattedMultiLine, providing more granular control over brace insertion.
Added enum variants
UseBraces::WhenNeeded: Only uses braces when syntactically required (empty blocks, declarations, multiple statements, or to avoid dangling else ambiguity)
UseBraces::WhenFormattedMultiLine: Uses braces when the formatted body spans multiple lines, removing them for single-line statements
Implementation changes
Test coverage
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com