Skip to content

Commit

Permalink
Use Trivia(joining:) in SyntaxCollections
Browse files Browse the repository at this point in the history
We've introduced `Trivia(joining: [Trivia], separator: [Trivia])` to
generate doc comments from multiple pieces, and already use this
approach in `SyntaxNodesFile` for nodes themselves, and for node
children documentation.

This commit switches from joining pieces manually to using
`Trivia(joining:)` in `SyntaxCollectionsFile` so that we use the same
approach everywhere.
  • Loading branch information
natikgadzhi committed Sep 16, 2023
1 parent b4fbbd9 commit be28272
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@ import Utils

let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
for node in SYNTAX_NODES.compactMap(\.collectionNode) {
let documentationSections = [
let documentation = SwiftSyntax.Trivia(joining: [
node.documentation,
node.grammar,
node.containedIn,
]

let documentation =
documentationSections
.filter { !$0.isEmpty }
.map { [$0] }
.joined(separator: [Trivia.newline, Trivia.docLineComment("///"), Trivia.newline])
.reduce(Trivia(), +)
])

try! StructDeclSyntax(
"""
Expand Down

0 comments on commit be28272

Please sign in to comment.