@@ -463,11 +463,12 @@ public extension SyntaxProtocol {
463
463
// MARK: Trivia
464
464
465
465
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.
469
467
///
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
471
472
/// the leading trivia text including all invalid UTF-8 sequences, use
472
473
/// ```
473
474
/// node.syntaxTextBytes.prefix(self.leadingTriviaLength.utf8Length)
@@ -481,9 +482,10 @@ public extension SyntaxProtocol {
481
482
}
482
483
}
483
484
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.
487
489
///
488
490
/// Note: ``Trivia`` is not able to represent invalid UTF-8 sequences. To get
489
491
/// the leading trivia text including all invalid UTF-8 sequences, use
0 commit comments