@@ -39,10 +39,8 @@ public class Trivia {
39
39
/// The doc comment describing the trivia.
40
40
public let comment : SwiftSyntax . Trivia
41
41
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 ?
46
44
47
45
/// The traits.
48
46
public let traits : TriviaTraits
@@ -65,13 +63,10 @@ public class Trivia {
65
63
}
66
64
}
67
65
68
- /// The length of the `characters` array.
69
- public var charactersLen : Int { characters. count }
70
-
71
66
/// Indicates if the trivia is a collection of characters.
72
67
///
73
68
/// If `true`, the trivia is made up of multiple characters.
74
- public var isCollection : Bool { charactersLen > 0 }
69
+ public var isCollection : Bool { characters != nil }
75
70
76
71
/// Initializes a new `Trivia` instance.
77
72
///
@@ -83,7 +78,7 @@ public class Trivia {
83
78
init (
84
79
name: TokenSyntax ,
85
80
comment: SwiftSyntax . Trivia ,
86
- characters: [ Character ] = [ ] ,
81
+ characters: String ? = nil ,
87
82
traits: TriviaTraits = [ ]
88
83
) {
89
84
self . name = name
@@ -97,7 +92,7 @@ public let TRIVIAS: [Trivia] = [
97
92
Trivia (
98
93
name: " Backslash " ,
99
94
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: " \\ "
101
96
) ,
102
97
103
98
Trivia (
@@ -109,14 +104,14 @@ public let TRIVIAS: [Trivia] = [
109
104
Trivia (
110
105
name: " CarriageReturn " ,
111
106
comment: #"A newline '\r' character."# ,
112
- characters: [ " \r " ] ,
107
+ characters: " \r " ,
113
108
traits: [ . whitespace, . newline]
114
109
) ,
115
110
116
111
Trivia (
117
112
name: " CarriageReturnLineFeed " ,
118
113
comment: #"A newline consists of contiguous '\r' and '\n' characters."# ,
119
- characters: [ " \r " , " \n " ] ,
114
+ characters: " \r \n " ,
120
115
traits: [ . whitespace, . newline]
121
116
) ,
122
117
@@ -136,7 +131,7 @@ public let TRIVIAS: [Trivia] = [
136
131
Trivia (
137
132
name: " Formfeed " ,
138
133
comment: #"A form-feed 'f' character."# ,
139
- characters: [ " \u{000C} " ] ,
134
+ characters: " \u{000C} " ,
140
135
traits: [ . whitespace]
141
136
) ,
142
137
@@ -149,27 +144,27 @@ public let TRIVIAS: [Trivia] = [
149
144
Trivia (
150
145
name: " Newline " ,
151
146
comment: #"A newline '\n' character."# ,
152
- characters: [ " \n " ] ,
147
+ characters: " \n " ,
153
148
traits: [ . whitespace, . newline]
154
149
) ,
155
150
156
151
Trivia (
157
152
name: " Pound " ,
158
153
comment: #"A '#' that is at the end of a line in a multi-line string literal to escape the newline."# ,
159
- characters: [ " # " ]
154
+ characters: " # "
160
155
) ,
161
156
162
157
Trivia (
163
158
name: " Space " ,
164
159
comment: #"A space ' ' character."# ,
165
- characters: [ " " ] ,
160
+ characters: " " ,
166
161
traits: [ . whitespace, . spaceOrTab]
167
162
) ,
168
163
169
164
Trivia (
170
165
name: " Tab " ,
171
166
comment: #"A tab '\t' character."# ,
172
- characters: [ " \t " ] ,
167
+ characters: " \t " ,
173
168
traits: [ . whitespace, . spaceOrTab]
174
169
) ,
175
170
@@ -182,7 +177,7 @@ public let TRIVIAS: [Trivia] = [
182
177
Trivia (
183
178
name: " VerticalTab " ,
184
179
comment: #"A vertical tab '\v' character."# ,
185
- characters: [ " \u{000B} " ] ,
180
+ characters: " \u{000B} " ,
186
181
traits: [ . whitespace]
187
182
) ,
188
183
]
0 commit comments