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
3131 }
3232
3333 /// Introduced name.
34- @_spi ( Experimental) public var name : String {
34+ @_spi ( Experimental) public var identifier : Identifier ? {
3535 switch self {
3636 case . identifier( let syntax, _) :
37- syntax. identifier. text
37+ Identifier ( syntax. identifier)
3838 case . declaration( let syntax, _) :
39- syntax. name. text
39+ Identifier ( syntax. name)
4040 }
4141 }
4242
@@ -57,7 +57,8 @@ import SwiftSyntax
5757
5858 /// Checks if this name refers to the looked up phrase.
5959 func refersTo( _ lookedUpName: String ) -> Bool {
60- name == lookedUpName
60+ guard let name = identifier? . name else { return false }
61+ return name == lookedUpName
6162 }
6263
6364 /// 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 {
140140 source: """
141141 func foo() {
142142 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)
145145 }
146146 let b = 0
147147 }
148148 """ ,
149149 references: [
150- " 5️⃣ " : [ . fromScope( ClosureExprSyntax . self, expectedNames: [ " 2️⃣ " ] ) ] ,
151150 " 6️⃣ " : [
152151 . fromScope( ClosureExprSyntax . self, expectedNames: [ " 3️⃣ " ] ) ,
153152 . fromScope( CodeBlockSyntax . self, expectedNames: [ " 1️⃣ " ] ) ,
You can’t perform that action at this time.
0 commit comments