Skip to content

Commit a255fc9

Browse files
committed
Fix merge artifacts.
1 parent 166fdb7 commit a255fc9

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

Sources/SwiftLexicalLookup/LookupName.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import SwiftSyntax
5555
"oldValue"
5656
}
5757
}
58-
58+
5959
/// Identifier used for name comparison.
6060
var identifier: Identifier {
6161
Identifier(name)

Sources/SwiftLexicalLookup/ScopeImplementations.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ import SwiftSyntax
106106
case .memberBlock:
107107
let names = introducedNames(using: .memberBlock)
108108
.filter { lookupName in
109-
checkName(name, refersTo: lookupName, at: syntax)
109+
checkName(identifier, refersTo: lookupName, at: syntax)
110110
}
111111

112112
return names.isEmpty ? [] : [.fromFileScope(self, withNames: names)]
@@ -124,7 +124,7 @@ import SwiftSyntax
124124
if item.is(DeclSyntax.self) || item.is(VariableDeclSyntax.self) {
125125
let foundNames = LookupName.getNames(from: item)
126126

127-
members.append(contentsOf: foundNames.filter { checkName(name, refersTo: $0, at: syntax) })
127+
members.append(contentsOf: foundNames.filter { checkName(identifier, refersTo: $0, at: syntax) })
128128
} else {
129129
encounteredNonDeclaration = true
130130
sequentialItems.append(codeBlockItem)
@@ -284,9 +284,9 @@ import SwiftSyntax
284284
state: LookupState
285285
) -> [LookupResult] {
286286
if let elseBody, elseBody.position <= syntax.position, elseBody.endPosition >= syntax.position {
287-
return lookupInParent(for: name, at: syntax, with: config, state: state)
287+
return lookupInParent(for: identifier, at: syntax, with: config, state: state)
288288
} else {
289-
return defaultLookupImplementation(for: name, at: syntax, with: config, state: state)
289+
return defaultLookupImplementation(for: identifier, at: syntax, with: config, state: state)
290290
}
291291
}
292292
}
@@ -310,7 +310,7 @@ import SwiftSyntax
310310
let names = conditions.flatMap { element in
311311
LookupName.getNames(from: element.condition, accessibleAfter: element.endPosition)
312312
}.filter { introducedName in
313-
checkName(name, refersTo: introducedName, at: syntax)
313+
checkName(identifier, refersTo: introducedName, at: syntax)
314314
}
315315

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

Sources/SwiftLexicalLookup/ScopeSyntax.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extension SyntaxProtocol {
9595
let filteredNames =
9696
introducedNames
9797
.filter { introducedName in
98-
checkName(name, refersTo: introducedName, at: syntax)
98+
checkName(identifier, refersTo: introducedName, at: syntax)
9999
}
100100

101101
if filteredNames.isEmpty {
@@ -116,7 +116,7 @@ extension SyntaxProtocol {
116116
parentScope?.lookup(for: identifier, at: syntax, with: config, state: state) ?? []
117117
}
118118

119-
func checkName(_ name: String?, refersTo introducedName: LookupName, at syntax: SyntaxProtocol) -> Bool {
119+
func checkName(_ name: Identifier?, refersTo introducedName: LookupName, at syntax: SyntaxProtocol) -> Bool {
120120
introducedName.isAccessible(at: syntax) && (name == nil || introducedName.refersTo(name!))
121121
}
122122
}

Sources/SwiftLexicalLookup/SequentialScopeSyntax.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension SequentialScopeSyntax {
7575
from: codeBlockItem.item,
7676
accessibleAfter: codeBlockItem.endPosition
7777
).filter { introducedName in
78-
checkName(name, refersTo: introducedName, at: syntax)
78+
checkName(identifier, refersTo: introducedName, at: syntax)
7979
}
8080
)
8181
}
@@ -87,6 +87,7 @@ extension SequentialScopeSyntax {
8787
currentChunk = []
8888
}
8989

90-
return (result.isEmpty ? [] : result.reversed()) + lookupInParent(for: identifier, at: syntax, with: config, state: state)
90+
return (result.isEmpty ? [] : result.reversed())
91+
+ lookupInParent(for: identifier, at: syntax, with: config, state: state)
9192
}
9293
}

Sources/SwiftSyntax/Identifier.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public struct Identifier: Equatable, Hashable, Sendable {
1515
enum IdentifierKind: Hashable {
1616
case token(raw: RawIdentifier, arena: SyntaxArenaRef)
1717
case string(String)
18-
18+
1919
static func sanitize(string: String) -> IdentifierKind {
2020
let backtick = "`"
2121
if string.count > 2 && string.hasPrefix(backtick) && string.hasSuffix(backtick) {
@@ -27,7 +27,7 @@ public struct Identifier: Equatable, Hashable, Sendable {
2727
}
2828
}
2929
}
30-
30+
3131
/// The sanitized name of the identifier.
3232
public var name: String {
3333
switch identifier {
@@ -37,7 +37,7 @@ public struct Identifier: Equatable, Hashable, Sendable {
3737
string
3838
}
3939
}
40-
40+
4141
@_spi(RawSyntax)
4242
public var raw: RawIdentifier? {
4343
switch identifier {
@@ -54,14 +54,14 @@ public struct Identifier: Equatable, Hashable, Sendable {
5454
guard case .identifier = token.tokenKind else {
5555
return nil
5656
}
57-
57+
5858
self.identifier = .token(raw: RawIdentifier(token.tokenView), arena: token.tokenView.raw.arenaReference)
5959
}
60-
60+
6161
public init(_ string: String) {
6262
self.identifier = IdentifierKind.sanitize(string: string)
6363
}
64-
64+
6565
public static func == (lhs: Self, rhs: Self) -> Bool {
6666
lhs.name == rhs.name
6767
}

Tests/SwiftLexicalLookupTest/Assertions.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import SwiftParser
1515
import SwiftSyntax
1616
import XCTest
1717
import _SwiftSyntaxTestSupport
18+
1819
/// `methodUnderTest` is called with the token at every position marker in the keys of `expected`.
1920
/// It then asserts that the positions of the syntax nodes returned by `methodUnderTest` are the values in `expected`.
2021
/// It also checks whether result types match rules specified in `expectedResultTypes`.
@@ -93,7 +94,7 @@ func assertLexicalNameLookup(
9394
source: source,
9495
methodUnderTest: { marker, tokenAtMarker in
9596
let lookupIdentifier = Identifier(tokenAtMarker) ?? Identifier(tokenAtMarker.text)
96-
97+
9798
let result = tokenAtMarker.lookup(for: useNilAsTheParameter ? nil : lookupIdentifier, with: config)
9899

99100
guard let expectedValues = references[marker] else {

Tests/SwiftLexicalLookupTest/NameLookupTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ final class testNameLookup: XCTestCase {
668668
]
669669
)
670670
}
671-
671+
672672
func testBacktickCompatibility() {
673673
assertLexicalNameLookup(
674674
source: """
@@ -679,7 +679,7 @@ final class testNameLookup: XCTestCase {
679679
print(4️⃣`self`)
680680
}
681681
}
682-
682+
683683
5️⃣struct Bar {
684684
func test() {
685685
print(6️⃣self)
@@ -691,18 +691,18 @@ final class testNameLookup: XCTestCase {
691691
references: [
692692
"3️⃣": [
693693
.fromScope(CodeBlockSyntax.self, expectedNames: [NameExpectation.identifier("2️⃣")]),
694-
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("1️⃣"))])
694+
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("1️⃣"))]),
695695
],
696696
"4️⃣": [
697697
.fromScope(CodeBlockSyntax.self, expectedNames: [NameExpectation.identifier("2️⃣")]),
698-
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("1️⃣"))])
698+
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("1️⃣"))]),
699699
],
700700
"6️⃣": [
701701
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("5️⃣"))])
702702
],
703703
"8️⃣": [
704704
.fromScope(CodeBlockSyntax.self, expectedNames: [NameExpectation.identifier("7️⃣")]),
705-
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("5️⃣"))])
705+
.fromScope(StructDeclSyntax.self, expectedNames: [NameExpectation.implicit(.self("5️⃣"))]),
706706
],
707707
]
708708
)

0 commit comments

Comments
 (0)