@@ -463,11 +463,12 @@ public extension SyntaxProtocol {
463463// MARK: Trivia
464464
465465public 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