Skip to content

Commit af63388

Browse files
jpsimSimplyDanny
authored andcommitted
Migrate VerticalWhitespaceOpeningBracesRule to SwiftSyntax
## Summary Convert VerticalWhitespaceOpeningBracesRule to use SwiftSyntax instead of SourceKit for improved performance and better detection of empty lines after opening braces. ## Key Technical Improvements - **Enhanced trivia analysis** for accurate empty line detection after opening braces - **Proper handling of closure "in" keywords** with context-aware detection - **Improved correction logic** handling all newline types (LF, CR, CRLF) consistently - **SwiftSyntax visitor pattern** replacing regex-based detection for better accuracy - **Comprehensive token analysis** supporting all opening brace types (`{`, `[`, `(`) - **Accurate position tracking** for violation start and end positions ## Migration Details - Replaced `CorrectableRule, OptInRule` with `@SwiftSyntaxRule(correctable: true, optIn: true)` - Implemented `ViolationsSyntaxVisitor` for detecting violations in token trailing trivia - Implemented `ViolationsSyntaxRewriter` for correcting violations across different syntax contexts - Added proper handling of closures, code blocks, arrays, and tuples - Maintained exact position reporting for violation locations - Preserved all existing test cases and rule behavior
1 parent de613ba commit af63388

File tree

2 files changed

+400
-41
lines changed

2 files changed

+400
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* `line_length`
4343
* `trailing_whitespace`
4444
* `vertical_whitespace`
45+
* `vertical_whitespace_opening_braces`
4546
<!-- Keep empty line to have the contributors on a separate line. -->
4647
[JP Simard](https://github.com/jpsim)
4748
[Matt Pennig](https://github.com/pennig)

0 commit comments

Comments
 (0)