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()

Sources/SwiftSyntax/Raw/RawSyntax.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ extension RawSyntax {
156156
kind == .token
157157
}
158158

159-
/// Whether or not this node is a collection one.
160-
var isCollection: Bool {
161-
kind.isSyntaxCollection
162-
}
163-
164-
/// Whether or not this node is an unknown one.
165-
var isUnknown: Bool {
166-
kind.isUnknown
167-
}
168-
169159
var recursiveFlags: RecursiveRawSyntaxFlags {
170160
switch view {
171161
case .token(let tokenView):

Sources/SwiftSyntax/Raw/RawSyntaxTokenView.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,6 @@ public struct RawSyntaxTokenView {
142142
return Trivia(pieces: trailingRawTriviaPieces.map({ TriviaPiece(raw: $0) }))
143143
}
144144

145-
/// Calls `body` with the token text. The token text value must not escape the closure.
146-
@_spi(RawSyntax)
147-
public func withUnsafeTokenText<Result>(
148-
_ body: (SyntaxText?) -> Result
149-
) -> Result {
150-
body(rawText)
151-
}
152-
153145
/// Returns a `RawSyntax` node with the same source text but with the token
154146
/// kind changed to `newValue`.
155147
@_spi(RawSyntax)

Sources/SwiftSyntax/SyntaxData.swift

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ struct AbsoluteSyntaxPosition {
2121
return .init(offset: newOffset, indexInParent: newIndexInParent)
2222
}
2323

24-
func reversedBySibling(_ raw: RawSyntax?) -> AbsoluteSyntaxPosition {
25-
let newOffset = self.offset - UInt32(truncatingIfNeeded: raw?.totalLength.utf8Length ?? 0)
26-
let newIndexInParent = self.indexInParent - 1
27-
return .init(offset: newOffset, indexInParent: newIndexInParent)
28-
}
29-
3024
func advancedToFirstChild() -> AbsoluteSyntaxPosition {
3125
return .init(offset: self.offset, indexInParent: 0)
3226
}
@@ -52,12 +46,6 @@ struct AbsoluteSyntaxInfo {
5246
return .init(position: newPosition, nodeId: newNodeId)
5347
}
5448

55-
func reversedBySibling(_ raw: RawSyntax?) -> AbsoluteSyntaxInfo {
56-
let newPosition = position.reversedBySibling(raw)
57-
let newNodeId = nodeId.reversedBySibling(raw)
58-
return .init(position: newPosition, nodeId: newNodeId)
59-
}
60-
6149
func advancedToFirstChild() -> AbsoluteSyntaxInfo {
6250
let newPosition = position.advancedToFirstChild()
6351
let newNodeId = nodeId.advancedToFirstChild()
@@ -124,11 +112,6 @@ public struct SyntaxIdentifier: Hashable {
124112
return .init(rootId: self.rootId, indexInTree: newIndexInTree)
125113
}
126114

127-
func reversedBySibling(_ raw: RawSyntax?) -> SyntaxIdentifier {
128-
let newIndexInTree = self.indexInTree.reversedBy(raw)
129-
return .init(rootId: self.rootId, indexInTree: newIndexInTree)
130-
}
131-
132115
func advancedToFirstChild() -> SyntaxIdentifier {
133116
let newIndexInTree = self.indexInTree.advancedToFirstChild()
134117
return .init(rootId: self.rootId, indexInTree: newIndexInTree)
@@ -144,16 +127,6 @@ struct AbsoluteRawSyntax {
144127
let raw: RawSyntax
145128
let info: AbsoluteSyntaxInfo
146129

147-
/// The position of the start of this node's leading trivia
148-
var position: AbsolutePosition {
149-
return AbsolutePosition(utf8Offset: Int(info.offset))
150-
}
151-
152-
/// The end position of this node, including its trivia.
153-
var endPosition: AbsolutePosition {
154-
return position + raw.totalLength
155-
}
156-
157130
/// Returns first `present` child.
158131
func firstChild(viewMode: SyntaxTreeViewMode) -> AbsoluteRawSyntax? {
159132
guard let layoutView = raw.layoutView else { return nil }
@@ -184,10 +157,6 @@ struct AbsoluteRawSyntax {
184157
let newInfo = AbsoluteSyntaxInfo(position: info.position, nodeId: nodeId)
185158
return .init(raw: newRaw, info: newInfo)
186159
}
187-
188-
static func forRoot(_ raw: RawSyntax) -> AbsoluteRawSyntax {
189-
return .init(raw: raw, info: .forRoot(raw))
190-
}
191160
}
192161

193162
/// SyntaxData is the underlying storage for each Syntax node.
@@ -228,10 +197,6 @@ struct SyntaxData {
228197
}
229198
}
230199

231-
private var rootArena: SyntaxArena {
232-
rootInfo.arena
233-
}
234-
235200
private var root: SyntaxData {
236201
switch info {
237202
case .root(_): return self

0 commit comments

Comments
 (0)