Skip to content

Commit 7b008fe

Browse files
authored
Merge pull request #1080 from jpsim/jp-remove-dead-code
Clean up dead code
2 parents 54e4440 + 64a6063 commit 7b008fe

File tree

16 files changed

+0
-339
lines changed

16 files changed

+0
-339
lines changed

Sources/SwiftBasicFormat/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ add_library(SwiftBasicFormat STATIC
1010
generated/BasicFormat.swift
1111
SyntaxProtocol+Formatted.swift
1212
Trivia+Indented.swift
13-
Utils.swift
1413
)
1514

1615
target_link_libraries(SwiftBasicFormat PUBLIC

Sources/SwiftBasicFormat/Utils.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

Sources/SwiftParser/Lexer.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ extension Lexer {
227227
return self.pointer.distance(to: other.pointer)
228228
}
229229

230-
func absoluteDistance(to other: Self) -> AbsolutePosition {
231-
return AbsolutePosition(utf8Offset: self.distance(to: other))
232-
}
233-
234230
func peek(at offset: Int = 0) -> UInt8 {
235231
assert(!self.isAtEndOfFile)
236232
assert(offset >= 0)

Sources/SwiftParser/Lookahead.swift

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -244,51 +244,6 @@ extension Parser.Lookahead {
244244

245245
// MARK: Lookahead
246246

247-
extension Parser.Lookahead {
248-
private static let declAttributeNames: [SyntaxText] = [
249-
"autoclosure",
250-
"convention",
251-
"noescape",
252-
"escaping",
253-
"differentiable",
254-
"noDerivative",
255-
"async",
256-
"Sendable",
257-
"unchecked",
258-
"_local",
259-
"block_storage",
260-
"box",
261-
"dynamic_self",
262-
"sil_weak",
263-
"sil_unowned",
264-
"sil_unmanaged",
265-
"error",
266-
"out",
267-
"in",
268-
"inout",
269-
"inout_aliasable",
270-
"in_guaranteed",
271-
"in_constant",
272-
"owned",
273-
"unowned_inner_pointer",
274-
"guaranteed",
275-
"autoreleased",
276-
"callee_owned",
277-
"callee_guaranteed",
278-
"objc_metatype",
279-
"opened",
280-
"pseudogeneric",
281-
"yields",
282-
"yield_once",
283-
"yield_many",
284-
"captures_generics",
285-
"thin",
286-
"thick",
287-
"_opaqueReturnTypeOf",
288-
]
289-
290-
}
291-
292247
extension Parser.Lookahead {
293248
func isStartOfGetSetAccessor() -> Bool {
294249
assert(self.at(.leftBrace), "not checking a brace?")

Sources/SwiftParser/Modifiers.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ extension Parser {
107107
)
108108
}
109109

110-
mutating func parseSingleArgumentModifier() -> RawDeclModifierSyntax {
111-
let keyword = self.consumeAnyToken(remapping: .contextualKeyword)
112-
let detail = self.parseModifierDetail()
113-
return RawDeclModifierSyntax(name: keyword, detail: detail, arena: self.arena)
114-
}
115-
116110
mutating func parseUnownedModifier() -> RawDeclModifierSyntax {
117111
let (unexpectedBeforeKeyword, keyword) = self.expectContextualKeyword("unowned")
118112

Sources/SwiftParser/Patterns.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,6 @@ extension Parser.Lookahead {
325325
return self.consume(if: .rightParen) != nil
326326
}
327327

328-
/// typed-pattern ::= pattern (':' type)?
329-
mutating func canParseTypedPattern() -> Bool {
330-
guard self.canParsePattern() else {
331-
return false
332-
}
333-
334-
if self.consume(if: .colon) != nil {
335-
return self.canParseType()
336-
}
337-
return true
338-
}
339-
340328
/// Determine whether we are at the start of a parameter name when
341329
/// parsing a parameter.
342330
/// If `allowMisplacedSpecifierRecovery` is `true`, then this will skip over any type

Sources/SwiftParser/RawTokenKindSubset.swift

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -107,105 +107,6 @@ enum BinaryOperator: RawTokenKindSubset {
107107
}
108108
}
109109

110-
enum CanBeDeclaratinStart: RawTokenKindSubset {
111-
case associatedtypeKeyword
112-
case atSign
113-
case caseKeyword
114-
case classKeyword
115-
case deinitKeyword
116-
case enumKeyword
117-
case extensionKeyword
118-
case fileprivateKeyword
119-
case funcKeyword
120-
case identifier
121-
case importKeyword
122-
case initKeyword
123-
case internalKeyword
124-
case letKeyword
125-
case operatorKeyword
126-
case poundErrorKeyword
127-
case poundIfKeyword
128-
case poundSourceLocationKeyword
129-
case poundWarningKeyword
130-
case precedencegroupKeyword
131-
case privateKeyword
132-
case protocolKeyword
133-
case publicKeyword
134-
case staticKeyword
135-
case structKeyword
136-
case subscriptKeyword
137-
case typealiasKeyword
138-
case varKeyword
139-
140-
init?(lexeme: Lexer.Lexeme) {
141-
switch lexeme.tokenKind {
142-
case .associatedtypeKeyword: self = .associatedtypeKeyword
143-
case .atSign: self = .atSign
144-
case .caseKeyword: self = .caseKeyword
145-
case .classKeyword: self = .classKeyword
146-
case .deinitKeyword: self = .deinitKeyword
147-
case .enumKeyword: self = .enumKeyword
148-
case .extensionKeyword: self = .extensionKeyword
149-
case .fileprivateKeyword: self = .fileprivateKeyword
150-
case .funcKeyword: self = .funcKeyword
151-
case .identifier: self = .identifier
152-
case .importKeyword: self = .importKeyword
153-
case .initKeyword: self = .initKeyword
154-
case .internalKeyword: self = .internalKeyword
155-
case .letKeyword: self = .letKeyword
156-
case .operatorKeyword: self = .operatorKeyword
157-
case .poundErrorKeyword: self = .poundErrorKeyword
158-
case .poundIfKeyword: self = .poundIfKeyword
159-
case .poundSourceLocationKeyword: self = .poundSourceLocationKeyword
160-
case .poundWarningKeyword: self = .poundWarningKeyword
161-
case .precedencegroupKeyword: self = .precedencegroupKeyword
162-
case .privateKeyword: self = .privateKeyword
163-
case .protocolKeyword: self = .protocolKeyword
164-
case .publicKeyword: self = .publicKeyword
165-
case .staticKeyword: self = .staticKeyword
166-
case .structKeyword: self = .structKeyword
167-
case .subscriptKeyword: self = .subscriptKeyword
168-
case .typealiasKeyword: self = .typealiasKeyword
169-
case .varKeyword: self = .varKeyword
170-
default: return nil
171-
}
172-
}
173-
174-
var rawTokenKind: RawTokenKind {
175-
switch self {
176-
case .associatedtypeKeyword: return .associatedtypeKeyword
177-
case .atSign: return .atSign
178-
case .caseKeyword: return .caseKeyword
179-
case .classKeyword: return .classKeyword
180-
case .deinitKeyword: return .deinitKeyword
181-
case .enumKeyword: return .enumKeyword
182-
case .extensionKeyword: return .extensionKeyword
183-
case .fileprivateKeyword: return .fileprivateKeyword
184-
case .funcKeyword: return .funcKeyword
185-
case .identifier: return .identifier
186-
case .importKeyword: return .importKeyword
187-
case .initKeyword: return .initKeyword
188-
case .internalKeyword: return .internalKeyword
189-
case .letKeyword: return .letKeyword
190-
case .operatorKeyword: return .operatorKeyword
191-
case .poundErrorKeyword: return .poundErrorKeyword
192-
case .poundIfKeyword: return .poundIfKeyword
193-
case .poundSourceLocationKeyword: return .poundSourceLocationKeyword
194-
case .poundWarningKeyword: return .poundWarningKeyword
195-
case .precedencegroupKeyword: return .precedencegroupKeyword
196-
case .privateKeyword: return .privateKeyword
197-
case .protocolKeyword: return .protocolKeyword
198-
case .publicKeyword: return .publicKeyword
199-
case .staticKeyword: return .staticKeyword
200-
case .structKeyword: return .structKeyword
201-
case .subscriptKeyword: return .subscriptKeyword
202-
case .typealiasKeyword: return .typealiasKeyword
203-
case .varKeyword: return .varKeyword
204-
}
205-
}
206-
207-
}
208-
209110
enum CanBeStatementStart: RawTokenKindSubset {
210111
case breakKeyword
211112
case continueKeyword

Sources/SwiftParser/Statements.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,6 @@ extension Parser.Lookahead {
12141214
}
12151215
}
12161216

1217-
func isBooleanExpr() -> Bool {
1218-
var lookahead = self.lookahead()
1219-
return !lookahead.canParseTypedPattern() || !lookahead.at(.equal)
1220-
}
1221-
12221217
/// Returns whether the parser's current position is the start of a switch case,
12231218
/// given that we're in the middle of a switch already.
12241219
func isAtStartOfSwitchCase(allowRecovery: Bool = false) -> Bool {

Sources/SwiftParserDiagnostics/SyntaxExtensions.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ extension UnexpectedNodesSyntax {
2121
return self.tokens(satisfying: { $0.tokenKind == kind })
2222
}
2323

24-
/// If this only contains a single item that is a token, return that token, otherwise return `nil`.
25-
var onlyToken: TokenSyntax? {
26-
return onlyToken(where: { _ in true })
27-
}
28-
2924
/// If this only contains a single item, which is a token satisfying `condition`, return that token, otherwise return `nil`.
3025
func onlyToken(where condition: (TokenSyntax) -> Bool) -> TokenSyntax? {
3126
if self.count == 1, let token = self.first?.as(TokenSyntax.self), condition(token) {
@@ -94,11 +89,6 @@ extension SyntaxProtocol {
9489
}
9590
}
9691

97-
/// Returns this node or the first ancestor that satisfies `condition`.
98-
func ancestorOrSelf(where condition: (Syntax) -> Bool) -> Syntax? {
99-
return ancestorOrSelf(mapping: { condition($0) ? $0 : nil })
100-
}
101-
10292
/// Returns this node or the first ancestor that satisfies `condition`.
10393
func ancestorOrSelf<T>(mapping map: (Syntax) -> T?) -> T? {
10494
var walk: Syntax? = Syntax(self)

Sources/SwiftParserDiagnostics/Utils.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
extension String {
14-
/// Remove any leading or trailing spaces.
15-
/// This is necessary to avoid depending SwiftParser on Foundation.
16-
func trimmingWhitespace() -> String {
17-
let charactersToDrop: [Character] = [" ", "\t", "\n", "\r"]
18-
var result: Substring = Substring(self)
19-
result = result.drop(while: { charactersToDrop.contains($0) })
20-
while let lastCharacter = result.last, charactersToDrop.contains(lastCharacter) {
21-
result = result.dropLast(1)
22-
}
23-
return String(result)
24-
}
25-
2614
func withFirstLetterUppercased() -> String {
2715
if let firstLetter = self.first {
2816
return firstLetter.uppercased() + self.dropFirst()

0 commit comments

Comments
 (0)