File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed
Tests/SwiftSyntaxBuilderTest Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -210,9 +210,16 @@ extension Trivia: CustomStringConvertible {
210
210
}
211
211
}
212
212
213
- /// Concatenates two collections of `Trivia` into one collection.
214
- public func + ( lhs: Trivia , rhs: Trivia ) -> Trivia {
215
- return Trivia ( pieces: lhs. pieces + rhs. pieces)
213
+ extension Trivia {
214
+ /// Concatenates two collections of `Trivia` into one collection.
215
+ public static func + ( lhs: Trivia , rhs: Trivia ) -> Trivia {
216
+ return Trivia ( pieces: lhs. pieces + rhs. pieces)
217
+ }
218
+
219
+ /// Concatenates two collections of `Trivia` into the left-hand side.
220
+ public static func += ( lhs: inout Trivia , rhs: Trivia ) {
221
+ lhs = lhs + rhs
222
+ }
216
223
}
217
224
218
225
extension TriviaPiece : Equatable { }
Original file line number Diff line number Diff line change @@ -336,9 +336,16 @@ extension Trivia: CustomStringConvertible {
336
336
}
337
337
}
338
338
339
- /// Concatenates two collections of `Trivia` into one collection.
340
- public func + ( lhs: Trivia , rhs: Trivia ) -> Trivia {
341
- return Trivia ( pieces: lhs. pieces + rhs. pieces)
339
+ extension Trivia {
340
+ /// Concatenates two collections of `Trivia` into one collection.
341
+ public static func + ( lhs: Trivia , rhs: Trivia ) -> Trivia {
342
+ return Trivia ( pieces: lhs. pieces + rhs. pieces)
343
+ }
344
+
345
+ /// Concatenates two collections of `Trivia` into the left-hand side.
346
+ public static func += ( lhs: inout Trivia , rhs: Trivia ) {
347
+ lhs = lhs + rhs
348
+ }
342
349
}
343
350
344
351
extension TriviaPiece : Equatable { }
Original file line number Diff line number Diff line change @@ -24,4 +24,12 @@ final class TriviaTests: XCTestCase {
24
24
/* An inline comment */ static var test: String
25
25
""" )
26
26
}
27
+
28
+ func testTriviaConcatenation( ) {
29
+ let x = Trivia . newline
30
+ var y = x
31
+ y += . space
32
+ XCTAssertEqual ( y, x + . space)
33
+ XCTAssertEqual ( y, [ . newlines( 1 ) , . spaces( 1 ) ] )
34
+ }
27
35
}
You can’t perform that action at this time.
0 commit comments