@@ -39,10 +39,8 @@ public class Trivia {
3939 /// The doc comment describing the trivia.
4040 public let comment : SwiftSyntax . Trivia
4141
42- /// The list of characters that make up the trivia.
43- ///
44- /// Useful for multi-character trivias like `\r\n`.
45- public let characters : [ Character ]
42+ /// The characters that make up the trivia.
43+ public let characters : String ?
4644
4745 /// The traits.
4846 public let traits : TriviaTraits
@@ -65,13 +63,10 @@ public class Trivia {
6563 }
6664 }
6765
68- /// The length of the `characters` array.
69- public var charactersLen : Int { characters. count }
70-
7166 /// Indicates if the trivia is a collection of characters.
7267 ///
7368 /// If `true`, the trivia is made up of multiple characters.
74- public var isCollection : Bool { charactersLen > 0 }
69+ public var isCollection : Bool { characters != nil }
7570
7671 /// Initializes a new `Trivia` instance.
7772 ///
@@ -83,7 +78,7 @@ public class Trivia {
8378 init (
8479 name: TokenSyntax ,
8580 comment: SwiftSyntax . Trivia ,
86- characters: [ Character ] = [ ] ,
81+ characters: String ? = nil ,
8782 traits: TriviaTraits = [ ]
8883 ) {
8984 self . name = name
@@ -97,7 +92,7 @@ public let TRIVIAS: [Trivia] = [
9792 Trivia (
9893 name: " Backslash " ,
9994 comment: #"A backslash that is at the end of a line in a multi-line string literal to escape the newline."# ,
100- characters: [ " \\ " ]
95+ characters: " \\ "
10196 ) ,
10297
10398 Trivia (
@@ -109,14 +104,14 @@ public let TRIVIAS: [Trivia] = [
109104 Trivia (
110105 name: " CarriageReturn " ,
111106 comment: #"A newline '\r' character."# ,
112- characters: [ " \r " ] ,
107+ characters: " \r " ,
113108 traits: [ . whitespace, . newline]
114109 ) ,
115110
116111 Trivia (
117112 name: " CarriageReturnLineFeed " ,
118113 comment: #"A newline consists of contiguous '\r' and '\n' characters."# ,
119- characters: [ " \r " , " \n " ] ,
114+ characters: " \r \n " ,
120115 traits: [ . whitespace, . newline]
121116 ) ,
122117
@@ -136,7 +131,7 @@ public let TRIVIAS: [Trivia] = [
136131 Trivia (
137132 name: " Formfeed " ,
138133 comment: #"A form-feed 'f' character."# ,
139- characters: [ " \u{000C} " ] ,
134+ characters: " \u{000C} " ,
140135 traits: [ . whitespace]
141136 ) ,
142137
@@ -149,27 +144,27 @@ public let TRIVIAS: [Trivia] = [
149144 Trivia (
150145 name: " Newline " ,
151146 comment: #"A newline '\n' character."# ,
152- characters: [ " \n " ] ,
147+ characters: " \n " ,
153148 traits: [ . whitespace, . newline]
154149 ) ,
155150
156151 Trivia (
157152 name: " Pound " ,
158153 comment: #"A '#' that is at the end of a line in a multi-line string literal to escape the newline."# ,
159- characters: [ " # " ]
154+ characters: " # "
160155 ) ,
161156
162157 Trivia (
163158 name: " Space " ,
164159 comment: #"A space ' ' character."# ,
165- characters: [ " " ] ,
160+ characters: " " ,
166161 traits: [ . whitespace, . spaceOrTab]
167162 ) ,
168163
169164 Trivia (
170165 name: " Tab " ,
171166 comment: #"A tab '\t' character."# ,
172- characters: [ " \t " ] ,
167+ characters: " \t " ,
173168 traits: [ . whitespace, . spaceOrTab]
174169 ) ,
175170
@@ -182,7 +177,7 @@ public let TRIVIAS: [Trivia] = [
182177 Trivia (
183178 name: " VerticalTab " ,
184179 comment: #"A vertical tab '\v' character."# ,
185- characters: [ " \u{000B} " ] ,
180+ characters: " \u{000B} " ,
186181 traits: [ . whitespace]
187182 ) ,
188183]
0 commit comments