Commit 27e3c77
committed
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 behavior1 parent 81474e3 commit 27e3c77
File tree
2 files changed
+367
-42
lines changed- Source/SwiftLintBuiltInRules/Rules/Style
2 files changed
+367
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
32 | 74 | | |
33 | 75 | | |
34 | 76 | | |
| |||
0 commit comments