Skip to content

Commit b3ead2e

Browse files
authored
Merge pull request swiftlang#83 from akyrtzi/tokensyntax-token-specific-rawsyntax-calls
[TokenSyntax] Use the token-specific RawSyntax functions for the TokenSyntax implementation, NFC
2 parents 898e50e + e8b9e6d commit b3ead2e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Sources/SwiftSyntax/RawSyntax.swift

+4
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,10 @@ extension RawSyntax {
10741074
return totalLength - (leadingTriviaLength + trailingTriviaLength)
10751075
}
10761076

1077+
var tokenContentLength: SourceLength {
1078+
return totalLength - (tokenLeadingTriviaLength + tokenTrailingTriviaLength)
1079+
}
1080+
10771081
/// Convenience function to create a RawSyntax when its byte length is not
10781082
/// known in advance, e.g. it is programmatically constructed instead of
10791083
/// created by the parser.

Sources/SwiftSyntax/Syntax.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,12 @@ public struct TokenSyntax: _SyntaxBase, Hashable {
557557

558558
/// The leading trivia (spaces, newlines, etc.) associated with this token.
559559
public var leadingTrivia: Trivia {
560-
return raw.formLeadingTrivia()!
560+
return raw.formTokenLeadingTrivia()!
561561
}
562562

563563
/// The trailing trivia (spaces, newlines, etc.) associated with this token.
564564
public var trailingTrivia: Trivia {
565-
return raw.formTrailingTrivia()!
565+
return raw.formTokenTrailingTrivia()!
566566
}
567567

568568
/// The kind of token this node represents.
@@ -573,17 +573,17 @@ public struct TokenSyntax: _SyntaxBase, Hashable {
573573
/// The length this node takes up spelled out in the source, excluding its
574574
/// leading or trailing trivia.
575575
public var contentLength: SourceLength {
576-
return raw.contentLength
576+
return raw.tokenContentLength
577577
}
578578

579579
/// The length this node's leading trivia takes up spelled out in source.
580580
public var leadingTriviaLength: SourceLength {
581-
return raw.leadingTriviaLength
581+
return raw.tokenLeadingTriviaLength
582582
}
583583

584584
/// The length this node's trailing trivia takes up spelled out in source.
585585
public var trailingTriviaLength: SourceLength {
586-
return raw.trailingTriviaLength
586+
return raw.tokenTrailingTriviaLength
587587
}
588588

589589
/// The length of this node including all of its trivia.

0 commit comments

Comments
 (0)