File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Sources/SwiftLexicalLookup
Tests/SwiftLexicalLookupTest Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,12 @@ import SwiftSyntax
31
31
}
32
32
33
33
/// Introduced name.
34
- @_spi ( Experimental) public var name : String {
34
+ @_spi ( Experimental) public var identifier : Identifier ? {
35
35
switch self {
36
36
case . identifier( let syntax, _) :
37
- syntax. identifier. text
37
+ Identifier ( syntax. identifier)
38
38
case . declaration( let syntax, _) :
39
- syntax. name. text
39
+ Identifier ( syntax. name)
40
40
}
41
41
}
42
42
@@ -57,7 +57,8 @@ import SwiftSyntax
57
57
58
58
/// Checks if this name refers to the looked up phrase.
59
59
func refersTo( _ lookedUpName: String ) -> Bool {
60
- name == lookedUpName
60
+ guard let name = identifier? . name else { return false }
61
+ return name == lookedUpName
61
62
}
62
63
63
64
/// Extracts names introduced by the given `from` structure.
Original file line number Diff line number Diff line change @@ -140,14 +140,13 @@ final class testNameLookup: XCTestCase {
140
140
source: """
141
141
func foo() {
142
142
let 1️⃣a = 1
143
- let x = { [2️⃣weak self, 3️⃣a, 4️⃣unowned b] in
144
- print(5️⃣self, 6️⃣a)
143
+ let x = { [3️⃣a, 4️⃣unowned b] in
144
+ print(6️⃣a)
145
145
}
146
146
let b = 0
147
147
}
148
148
""" ,
149
149
references: [
150
- " 5️⃣ " : [ . fromScope( ClosureExprSyntax . self, expectedNames: [ " 2️⃣ " ] ) ] ,
151
150
" 6️⃣ " : [
152
151
. fromScope( ClosureExprSyntax . self, expectedNames: [ " 3️⃣ " ] ) ,
153
152
. fromScope( CodeBlockSyntax . self, expectedNames: [ " 1️⃣ " ] ) ,
You can’t perform that action at this time.
0 commit comments