File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -565,12 +565,19 @@ public extension SyntaxProtocol {
565
565
data. raw. write ( to: & target)
566
566
}
567
567
568
+ /// A copy of this node without the leading trivia of the first token in the
569
+ /// node and the trailing trivia of the last token in the node.
570
+ var trimmed : Self {
571
+ // TODO: Should only need one new node here
572
+ return self . with ( \. leadingTrivia, [ ] ) . with ( \. trailingTrivia, [ ] )
573
+ }
574
+
568
575
/// The description of this node without the leading trivia of the first token
569
- /// in the node and the trailing trivia of the last token in the node
576
+ /// in the node and the trailing trivia of the last token in the node.
570
577
var trimmedDescription : String {
571
- // TODO: We shouldn't need to create two intermediate nodes from the `with`
572
- // functions just to get the description without trivia.
573
- return self . with ( \ . leadingTrivia , [ ] ) . with ( \ . trailingTrivia , [ ] ) . description
578
+ // TODO: We shouldn't need to create to copies just to get the description
579
+ // without trivia.
580
+ return self . trimmed . description
574
581
}
575
582
}
576
583
You can’t perform that action at this time.
0 commit comments