File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -471,6 +471,12 @@ public extension SyntaxProtocol {
471471 /// The leading trivia of this syntax node. Leading trivia is attached to
472472 /// the first token syntax contained by this node. Without such token, this
473473 /// property will return nil.
474+ ///
475+ /// Note: `Trivia` is not able to represent invalid UTF-8 sequences. To get
476+ /// the leading trivia text including all invalid UTF-8 sequences, use
477+ /// ```
478+ /// node.syntaxTextBytes.prefix(self.leadingTriviaLength.utf8Length)
479+ /// ```
474480 var leadingTrivia : Trivia {
475481 get {
476482 return raw. formLeadingTrivia ( )
@@ -483,6 +489,12 @@ public extension SyntaxProtocol {
483489 /// The trailing trivia of this syntax node. Trailing trivia is attached to
484490 /// the last token syntax contained by this node. Without such token, this
485491 /// property will return nil.
492+ ///
493+ /// Note: `Trivia` is not able to represent invalid UTF-8 sequences. To get
494+ /// the leading trivia text including all invalid UTF-8 sequences, use
495+ /// ```
496+ /// node.syntaxTextBytes[(node.byteSize - node.trailingTriviaLength.utf8Length)...]
497+ /// ```
486498 var trailingTrivia : Trivia {
487499 get {
488500 return raw. formTrailingTrivia ( )
You can’t perform that action at this time.
0 commit comments