Skip to content

Commit d457715

Browse files
committed
Remove LookupName.refersTo method. Rename checkName to checkIdentifier.
1 parent a2c6fe8 commit d457715

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

Sources/SwiftLexicalLookup/LookupName.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ import SwiftSyntax
152152
return accessibleAfter <= lookUpPosition
153153
}
154154

155-
/// Checks if this name refers to the looked up phrase.
156-
func refersTo(_ lookedUpIdentifier: Identifier) -> Bool {
157-
return identifier == lookedUpIdentifier
158-
}
159-
160155
/// Extracts names introduced by the given `syntax` structure.
161156
///
162157
/// When e.g. looking up a variable declaration like `let a = a`,

Sources/SwiftLexicalLookup/ScopeImplementations.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ import SwiftSyntax
105105
case .memberBlock:
106106
let names = introducedNames(using: .memberBlock)
107107
.filter { lookupName in
108-
checkName(identifier, refersTo: lookupName, at: lookUpPosition)
108+
checkIdentifier(identifier, refersTo: lookupName, at: lookUpPosition)
109109
}
110110

111111
return names.isEmpty ? [] : [.fromFileScope(self, withNames: names)]
@@ -121,7 +121,9 @@ import SwiftSyntax
121121
sequentialItems.append(codeBlockItem)
122122
} else if item.is(DeclSyntax.self) {
123123
let foundNames = LookupName.getNames(from: item)
124-
members.append(contentsOf: foundNames.filter { checkName(identifier, refersTo: $0, at: lookUpPosition) })
124+
members.append(
125+
contentsOf: foundNames.filter { checkIdentifier(identifier, refersTo: $0, at: lookUpPosition) }
126+
)
125127
} else {
126128
encounteredNonDeclaration = true
127129
sequentialItems.append(codeBlockItem)
@@ -323,7 +325,7 @@ import SwiftSyntax
323325
guard !body.range.contains(lookUpPosition) else { return [] }
324326

325327
let names = namesIntroducedToSequentialParent.filter { introducedName in
326-
checkName(identifier, refersTo: introducedName, at: lookUpPosition)
328+
checkIdentifier(identifier, refersTo: introducedName, at: lookUpPosition)
327329
}
328330

329331
return names.isEmpty ? [] : [.fromScope(self, withNames: names)]

Sources/SwiftLexicalLookup/ScopeSyntax.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extension SyntaxProtocol {
9292
let filteredNames =
9393
introducedNames
9494
.filter { introducedName in
95-
checkName(identifier, refersTo: introducedName, at: lookUpPosition)
95+
checkIdentifier(identifier, refersTo: introducedName, at: lookUpPosition)
9696
}
9797

9898
if filteredNames.isEmpty {
@@ -112,8 +112,11 @@ extension SyntaxProtocol {
112112
parentScope?.lookup(identifier, at: lookUpPosition, with: config) ?? []
113113
}
114114

115-
func checkName(_ name: Identifier?, refersTo introducedName: LookupName, at lookUpPosition: AbsolutePosition) -> Bool
116-
{
117-
introducedName.isAccessible(at: lookUpPosition) && (name == nil || introducedName.refersTo(name!))
115+
func checkIdentifier(
116+
_ identifier: Identifier?,
117+
refersTo introducedName: LookupName,
118+
at lookUpPosition: AbsolutePosition
119+
) -> Bool {
120+
introducedName.isAccessible(at: lookUpPosition) && (identifier == nil || introducedName.identifier == identifier!)
118121
}
119122
}

Sources/SwiftLexicalLookup/SequentialScopeSyntax.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extension SequentialScopeSyntax {
6363
from: codeBlockItem.item,
6464
accessibleAfter: codeBlockItem.endPosition
6565
).filter { introducedName in
66-
checkName(identifier, refersTo: introducedName, at: lookUpPosition)
66+
checkIdentifier(identifier, refersTo: introducedName, at: lookUpPosition)
6767
}
6868
} else {
6969
itemsWithoutNamedDecl.append(codeBlockItem)
@@ -99,7 +99,7 @@ extension SequentialScopeSyntax {
9999
from: codeBlockItem.item,
100100
accessibleAfter: codeBlockItem.endPosition
101101
).filter { introducedName in
102-
checkName(identifier, refersTo: introducedName, at: lookUpPosition)
102+
checkIdentifier(identifier, refersTo: introducedName, at: lookUpPosition)
103103
}
104104
}
105105
}

0 commit comments

Comments
 (0)