Skip to content

Commit a41749d

Browse files
committed
[CodeGeneration] Eliminate 'Trivia.swiftCharacters'
Not sure how it was used, but it's not used anymore.
1 parent c3cebd0 commit a41749d

File tree

1 file changed

+9
-71
lines changed

1 file changed

+9
-71
lines changed

CodeGeneration/Sources/SyntaxSupport/Trivia.swift

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ public class Trivia {
4444
/// Useful for multi-character trivias like `\r\n`.
4545
public let characters: [Character]
4646

47-
/// The list of characters as they would appear in Swift code.
48-
///
49-
/// This might differ from `characters` due to Swift's character escape requirements.
50-
public let swiftCharacters: [Character]
51-
5247
/// The traits.
5348
public let traits: TriviaTraits
5449

@@ -84,40 +79,25 @@ public class Trivia {
8479
/// - name: A name of the trivia.
8580
/// - comment: A doc comment describing the trivia.
8681
/// - characters: A list of characters that make up the trivia.
87-
/// - swiftCharacters: A list of characters as they would appear in Swift code.
8882
/// - isComment: Indicates if the trivia represents a comment.
8983
init(
9084
name: TokenSyntax,
9185
comment: SwiftSyntax.Trivia,
9286
characters: [Character] = [],
93-
swiftCharacters: [Character] = [],
9487
traits: TriviaTraits = []
9588
) {
9689
self.name = name
9790
self.comment = comment
9891
self.characters = characters
9992
self.traits = traits
100-
101-
// Swift sometimes doesn't support escaped characters like \f or \v;
102-
// we should allow specifying alternatives explicitly.
103-
if !swiftCharacters.isEmpty {
104-
self.swiftCharacters = swiftCharacters
105-
} else {
106-
self.swiftCharacters = characters
107-
}
10893
}
10994
}
11095

11196
public let TRIVIAS: [Trivia] = [
11297
Trivia(
11398
name: "Backslash",
11499
comment: #"A backslash that is at the end of a line in a multi-line string literal to escape the newline."#,
115-
characters: [
116-
Character("\\")
117-
],
118-
swiftCharacters: [
119-
Character("\\")
120-
]
100+
characters: ["\\"]
121101
),
122102

123103
Trivia(
@@ -129,26 +109,14 @@ public let TRIVIAS: [Trivia] = [
129109
Trivia(
130110
name: "CarriageReturn",
131111
comment: #"A newline '\r' character."#,
132-
characters: [
133-
Character("\r")
134-
],
135-
swiftCharacters: [
136-
Character("\r")
137-
],
112+
characters: ["\r"],
138113
traits: [.whitespace, .newline]
139114
),
140115

141116
Trivia(
142117
name: "CarriageReturnLineFeed",
143118
comment: #"A newline consists of contiguous '\r' and '\n' characters."#,
144-
characters: [
145-
Character("\r"),
146-
Character("\n"),
147-
],
148-
swiftCharacters: [
149-
Character("\r"),
150-
Character("\n"),
151-
],
119+
characters: ["\r", "\n"],
152120
traits: [.whitespace, .newline]
153121
),
154122

@@ -168,12 +136,7 @@ public let TRIVIAS: [Trivia] = [
168136
Trivia(
169137
name: "Formfeed",
170138
comment: #"A form-feed 'f' character."#,
171-
characters: [
172-
Character("\u{c}")
173-
],
174-
swiftCharacters: [
175-
Character("\u{240C}")
176-
],
139+
characters: ["\u{000C}"],
177140
traits: [.whitespace]
178141
),
179142

@@ -186,47 +149,27 @@ public let TRIVIAS: [Trivia] = [
186149
Trivia(
187150
name: "Newline",
188151
comment: #"A newline '\n' character."#,
189-
characters: [
190-
Character("\n")
191-
],
192-
swiftCharacters: [
193-
Character("\n")
194-
],
152+
characters: ["\n"],
195153
traits: [.whitespace, .newline]
196154
),
197155

198156
Trivia(
199157
name: "Pound",
200158
comment: #"A '#' that is at the end of a line in a multi-line string literal to escape the newline."#,
201-
characters: [
202-
Character("#")
203-
],
204-
swiftCharacters: [
205-
Character("#")
206-
]
159+
characters: ["#"]
207160
),
208161

209162
Trivia(
210163
name: "Space",
211164
comment: #"A space ' ' character."#,
212-
characters: [
213-
Character(" ")
214-
],
215-
swiftCharacters: [
216-
Character(" ")
217-
],
165+
characters: [" "],
218166
traits: [.whitespace, .spaceOrTab]
219167
),
220168

221169
Trivia(
222170
name: "Tab",
223171
comment: #"A tab '\t' character."#,
224-
characters: [
225-
Character("\t")
226-
],
227-
swiftCharacters: [
228-
Character("\t")
229-
],
172+
characters: ["\t"],
230173
traits: [.whitespace, .spaceOrTab]
231174
),
232175

@@ -239,12 +182,7 @@ public let TRIVIAS: [Trivia] = [
239182
Trivia(
240183
name: "VerticalTab",
241184
comment: #"A vertical tab '\v' character."#,
242-
characters: [
243-
Character("\u{b}")
244-
],
245-
swiftCharacters: [
246-
Character("\u{2B7F}")
247-
],
185+
characters: ["\u{000B}"],
248186
traits: [.whitespace]
249187
),
250188
]

0 commit comments

Comments
 (0)