Skip to content

Commit 22d6d5e

Browse files
committed
Generate @resultbuilder with SwiftSyntaxBuilder
1 parent 52a5a31 commit 22d6d5e

File tree

7 files changed

+414
-131
lines changed

7 files changed

+414
-131
lines changed

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ let package = Package(
7777
dependencies: ["SwiftSyntax"],
7878
exclude: [
7979
"gyb_helpers",
80-
"BuildableNodes.swift.gyb",
81-
"ResultBuilders.swift.gyb",
80+
"BuildableNodes.swift.gyb"
8281
]
8382
),
8483
.target(

Sources/SwiftSyntax/Syntax.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,23 +355,7 @@ public extension SyntaxProtocol {
355355
/// Returns a new syntax node with its leading trivia replaced
356356
/// by the provided trivia.
357357
func withLeadingTrivia(_ leadingTrivia: Trivia) -> Self {
358-
var leadingTrivia: [TriviaPiece] = leadingTrivia.pieces
359-
360-
// If there is 3 or more, then we see if the first two is a newline and a space
361-
// If so, we need to replace add the correct amount of space after each newline
362-
// comming after to have the right indentation of the code.
363-
if leadingTrivia.count > 2,
364-
case .newlines = leadingTrivia[0],
365-
case .spaces(let spaces) = leadingTrivia[1] {
366-
367-
for i in (2..<leadingTrivia.count).reversed() {
368-
if case .newlines = leadingTrivia[i] {
369-
leadingTrivia.insert(.spaces(spaces), at: i + 1)
370-
}
371-
}
372-
}
373-
374-
return Self(Syntax(data.withLeadingTrivia(Trivia(pieces: leadingTrivia))))!
358+
return Self(Syntax(data.withLeadingTrivia(leadingTrivia)))!
375359
}
376360

377361
/// Returns a new syntax node with its trailing trivia replaced

Sources/SwiftSyntaxBuilder/ResultBuilders.swift.gyb

Lines changed: 0 additions & 111 deletions
This file was deleted.

Sources/SwiftSyntaxBuilder/gyb_generated/ResultBuilders.swift renamed to Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3389,4 +3389,3 @@ public extension AvailabilitySpecList {
33893389
self = itemsBuilder()
33903390
}
33913391
}
3392-

0 commit comments

Comments
 (0)