@@ -27,15 +27,15 @@ extension SyntaxProtocol {
2727 public var introducedNames : [ LookupName ] {
2828 introducedNames ( using: . memberBlockUpToLastDecl)
2929 }
30-
30+
3131 public func introducedNames( using nameIntroductionStrategy: FileScopeNameIntroductionStrategy ) -> [ LookupName ] {
3232 switch nameIntroductionStrategy {
3333 case . memberBlockUpToLastDecl:
3434 var encounteredNonDeclaration = false
35-
35+
3636 return statements. flatMap { codeBlockItem in
3737 let item = codeBlockItem. item
38-
38+
3939 if encounteredNonDeclaration {
4040 return LookupName . getNames ( from: item, accessibleAfter: codeBlockItem. endPosition)
4141 } else {
@@ -57,15 +57,19 @@ extension SyntaxProtocol {
5757 }
5858 }
5959 }
60-
61- public func lookup( for name: String ? , at syntax: SyntaxProtocol , with configDict: LookupConfigDictionary ) -> [ LookupResult ] {
60+
61+ public func lookup(
62+ for name: String ? ,
63+ at syntax: SyntaxProtocol ,
64+ with configDict: LookupConfigDictionary
65+ ) -> [ LookupResult ] {
6266 let nameIntroductionStrategy = configDict [ FileScopeNameIntroductionStrategy . self] ?? . memberBlockUpToLastDecl
63-
67+
6468 let names = introducedNames ( using: nameIntroductionStrategy)
6569 . filter { introducedName in
6670 introducedName. isAccessible ( at: syntax) && ( name == nil || introducedName. refersTo ( name!) )
6771 }
68-
72+
6973 return [ . fromFileScope( self , withNames: names, nameIntroductionStrategy: nameIntroductionStrategy) ]
7074 }
7175}
@@ -86,26 +90,28 @@ extension SyntaxProtocol {
8690
8791@_spi ( Experimental) extension ClosureExprSyntax : ScopeSyntax {
8892 public var introducedNames : [ LookupName ] {
89- let captureNames = signature? . capture? . children ( viewMode: . sourceAccurate) . flatMap { child in
90- if let captureList = child. as ( ClosureCaptureListSyntax . self) {
91- captureList. children ( viewMode: . sourceAccurate) . flatMap { capture in
92- LookupName . getNames ( from: capture)
93+ let captureNames =
94+ signature? . capture? . children ( viewMode: . sourceAccurate) . flatMap { child in
95+ if let captureList = child. as ( ClosureCaptureListSyntax . self) {
96+ captureList. children ( viewMode: . sourceAccurate) . flatMap { capture in
97+ LookupName . getNames ( from: capture)
98+ }
99+ } else {
100+ LookupName . getNames ( from: child)
93101 }
94- } else {
95- LookupName . getNames ( from: child)
96- }
97- } ?? [ ]
98-
99- let parameterNames = signature? . parameterClause? . children ( viewMode: . sourceAccurate) . flatMap { parameter in
100- if let parameterList = parameter. as ( ClosureParameterListSyntax . self) {
101- parameterList. children ( viewMode: . sourceAccurate) . flatMap { parameter in
102+ } ?? [ ]
103+
104+ let parameterNames =
105+ signature? . parameterClause? . children ( viewMode: . sourceAccurate) . flatMap { parameter in
106+ if let parameterList = parameter. as ( ClosureParameterListSyntax . self) {
107+ parameterList. children ( viewMode: . sourceAccurate) . flatMap { parameter in
108+ LookupName . getNames ( from: parameter)
109+ }
110+ } else {
102111 LookupName . getNames ( from: parameter)
103112 }
104- } else {
105- LookupName . getNames ( from: parameter)
106- }
107- } ?? [ ]
108-
113+ } ?? [ ]
114+
109115 return captureNames + parameterNames
110116 }
111117}
@@ -144,7 +150,11 @@ extension SyntaxProtocol {
144150 }
145151 }
146152
147- public func lookup( for name: String ? , at syntax: SyntaxProtocol , with configDict: LookupConfigDictionary ) -> [ LookupResult ] {
153+ public func lookup(
154+ for name: String ? ,
155+ at syntax: SyntaxProtocol ,
156+ with configDict: LookupConfigDictionary
157+ ) -> [ LookupResult ] {
148158 if let elseBody, elseBody. position <= syntax. position, elseBody. endPosition >= syntax. position {
149159 lookupInParent ( for: name, at: syntax, with: configDict)
150160 } else {
@@ -165,8 +175,12 @@ extension SyntaxProtocol {
165175 public var introducedNames : [ LookupName ] {
166176 [ ]
167177 }
168-
169- public func lookup( for name: String ? , at syntax: SyntaxProtocol , with configDict: LookupConfigDictionary ) -> [ LookupResult ] {
178+
179+ public func lookup(
180+ for name: String ? ,
181+ at syntax: SyntaxProtocol ,
182+ with configDict: LookupConfigDictionary
183+ ) -> [ LookupResult ] {
170184 if body. position <= syntax. position && body. endPosition >= syntax. position {
171185 lookupInParent ( for: name, at: self , with: configDict)
172186 } else {
0 commit comments