|
13 | 13 | /// A Syntax node represents a tree of nodes with tokens at the leaves.
|
14 | 14 | /// Each node has accessors for its known children, and allows efficient
|
15 | 15 | /// iteration over the children through its `children` property.
|
16 |
| -public protocol Syntax: |
| 16 | +public protocol Syntax: |
17 | 17 | CustomStringConvertible, TextOutputStreamable {}
|
18 | 18 |
|
19 | 19 | internal protocol _SyntaxBase: Syntax {
|
@@ -261,7 +261,7 @@ extension _SyntaxBase {
|
261 | 261 | self.write(to: &s)
|
262 | 262 | return s
|
263 | 263 | }
|
264 |
| - |
| 264 | + |
265 | 265 | /// Prints the raw value of this node to the provided stream.
|
266 | 266 | /// - Parameter stream: The stream to which to print the raw tree.
|
267 | 267 | public func write<Target>(to target: inout Target)
|
@@ -507,7 +507,7 @@ public struct TokenSyntax: _SyntaxBase, Hashable {
|
507 | 507 | public var text: String {
|
508 | 508 | return tokenKind.text
|
509 | 509 | }
|
510 |
| - |
| 510 | + |
511 | 511 | /// Returns a new TokenSyntax with its kind replaced
|
512 | 512 | /// by the provided token kind.
|
513 | 513 | public func withKind(_ tokenKind: TokenKind) -> TokenSyntax {
|
@@ -565,25 +565,40 @@ public struct TokenSyntax: _SyntaxBase, Hashable {
|
565 | 565 |
|
566 | 566 | /// The leading trivia (spaces, newlines, etc.) associated with this token.
|
567 | 567 | public var leadingTrivia: Trivia {
|
568 |
| - return raw.formTokenLeadingTrivia()! |
| 568 | + get { |
| 569 | + return raw.formTokenLeadingTrivia()! |
| 570 | + } |
| 571 | + set { |
| 572 | + self = withLeadingTrivia(newValue) |
| 573 | + } |
569 | 574 | }
|
570 | 575 |
|
571 | 576 | /// The trailing trivia (spaces, newlines, etc.) associated with this token.
|
572 | 577 | public var trailingTrivia: Trivia {
|
573 |
| - return raw.formTokenTrailingTrivia()! |
| 578 | + get { |
| 579 | + return raw.formTokenTrailingTrivia()! |
| 580 | + } |
| 581 | + set { |
| 582 | + self = withTrailingTrivia(newValue) |
| 583 | + } |
574 | 584 | }
|
575 | 585 |
|
576 | 586 | /// The kind of token this node represents.
|
577 | 587 | public var tokenKind: TokenKind {
|
578 |
| - return raw.formTokenKind()! |
| 588 | + get { |
| 589 | + return raw.formTokenKind()! |
| 590 | + } |
| 591 | + set { |
| 592 | + self = withKind(newValue) |
| 593 | + } |
579 | 594 | }
|
580 | 595 |
|
581 | 596 | /// The length this node takes up spelled out in the source, excluding its
|
582 | 597 | /// leading or trailing trivia.
|
583 | 598 | public var contentLength: SourceLength {
|
584 | 599 | return raw.tokenContentLength
|
585 | 600 | }
|
586 |
| - |
| 601 | + |
587 | 602 | /// The length this node's leading trivia takes up spelled out in source.
|
588 | 603 | public var leadingTriviaLength: SourceLength {
|
589 | 604 | return raw.tokenLeadingTriviaLength
|
|
0 commit comments