Skip to content

Commit 83e12ff

Browse files
authored
Merge pull request #2304 from ahoppen/ahoppen/trivia-comment
Improve comment of leading and trailing trivia on `SyntaxProtocol`
2 parents f6868a7 + d5400cb commit 83e12ff

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Sources/SwiftSyntax/SyntaxProtocol.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,12 @@ public extension SyntaxProtocol {
463463
// MARK: Trivia
464464

465465
public extension SyntaxProtocol {
466-
/// The leading trivia of this syntax node. Leading trivia is attached to
467-
/// the first token syntax contained by this node. Without such token, this
468-
/// property will return nil.
466+
/// The leading trivia of this syntax node.
469467
///
470-
/// Note: ``Trivia`` is not able to represent invalid UTF-8 sequences. To get
468+
/// Trivia is always attached to tokens, not to layout nodes. This will return the leading trivia of the first token
469+
/// within the subtree. If no such token exists, this returns empty trivia.
470+
///
471+
/// - Note: ``Trivia`` is not able to represent invalid UTF-8 sequences. To get
471472
/// the leading trivia text including all invalid UTF-8 sequences, use
472473
/// ```
473474
/// node.syntaxTextBytes.prefix(self.leadingTriviaLength.utf8Length)
@@ -481,9 +482,10 @@ public extension SyntaxProtocol {
481482
}
482483
}
483484

484-
/// The trailing trivia of this syntax node. Trailing trivia is attached to
485-
/// the last token syntax contained by this node. Without such token, this
486-
/// property will return nil.
485+
/// The trailing trivia of this syntax node.
486+
///
487+
/// Trivia is always attached to tokens, not to layout nodes. This will return the trailing trivia of the last token
488+
/// within the subtree. If no such token exists, this returns empty trivia.
487489
///
488490
/// Note: ``Trivia`` is not able to represent invalid UTF-8 sequences. To get
489491
/// the leading trivia text including all invalid UTF-8 sequences, use

0 commit comments

Comments
 (0)