1212
1313import SwiftSyntax
1414
15- extension SyntaxProtocol {
15+ @ _spi ( Experimental ) extension SyntaxProtocol {
1616 /// Parent scope of this syntax node, or scope introduced by this syntax node.
17- var scope : ScopeSyntax ? {
17+ @ _spi ( Experimental ) public var scope : ScopeSyntax ? {
1818 if let scopeSyntax = Syntax ( self ) . asProtocol ( SyntaxProtocol . self) as? ScopeSyntax {
1919 scopeSyntax
2020 } else {
@@ -26,7 +26,7 @@ extension SyntaxProtocol {
2626@_spi ( Experimental) extension SourceFileSyntax : SequentialScopeSyntax {
2727 /// All names introduced in the file scope
2828 /// according to the default strategy: `memberBlockUpToLastDecl`.
29- public var introducedNames : [ LookupName ] {
29+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
3030 introducedNames ( using: . memberBlockUpToLastDecl)
3131 }
3232
@@ -47,10 +47,10 @@ extension SyntaxProtocol {
4747 /// ```
4848 /// During lookup, according to different configurations,
4949 /// names available at the marked place are:
50- /// - for `fileScopeNameIntroductionStrategy ` - a, b, c, d
50+ /// - for `memberBlockUpToLastDecl ` - a, b, c, d
5151 /// - for `memberBlock` - a, b, c, d, e, f
5252 /// - for `codeBlock` - a
53- public func introducedNames( using fileScopeHandling: FileScopeHandlingConfig ) -> [ LookupName ] {
53+ @ _spi ( Experimental ) public func introducedNames( using fileScopeHandling: FileScopeHandlingConfig ) -> [ LookupName ] {
5454 switch fileScopeHandling {
5555 case . memberBlockUpToLastDecl:
5656 var encounteredNonDeclaration = false
@@ -61,7 +61,7 @@ extension SyntaxProtocol {
6161 if encounteredNonDeclaration {
6262 return LookupName . getNames ( from: item, accessibleAfter: codeBlockItem. endPosition)
6363 } else {
64- if item. is ( DeclSyntax . self) || item . is ( VariableDeclSyntax . self ) {
64+ if item. is ( DeclSyntax . self) {
6565 return LookupName . getNames ( from: item)
6666 } else {
6767 encounteredNonDeclaration = true
@@ -97,10 +97,10 @@ extension SyntaxProtocol {
9797 /// ```
9898 /// According to different configurations,
9999 /// names available at the marked place are:
100- /// - for `fileScopeNameIntroductionStrategy ` - a, b, c, d
100+ /// - for `memberBlockUpToLastDecl ` - a, b, c, d
101101 /// - for `memberBlock` - a, b, c, d, e, f
102102 /// - for `codeBlock` - a
103- public func lookup(
103+ @ _spi ( Experimental ) public func lookup(
104104 for name: String ? ,
105105 at syntax: SyntaxProtocol ,
106106 with config: LookupConfig ,
@@ -162,13 +162,13 @@ extension SyntaxProtocol {
162162@_spi ( Experimental) extension CodeBlockSyntax : SequentialScopeSyntax {
163163 /// Names introduced in the code block scope
164164 /// accessible after their declaration.
165- public var introducedNames : [ LookupName ] {
165+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
166166 statements. flatMap { codeBlockItem in
167167 LookupName . getNames ( from: codeBlockItem. item, accessibleAfter: codeBlockItem. endPosition)
168168 }
169169 }
170170
171- public func lookup(
171+ @ _spi ( Experimental ) public func lookup(
172172 for name: String ? ,
173173 at syntax: SyntaxProtocol ,
174174 with config: LookupConfig ,
@@ -187,7 +187,7 @@ extension SyntaxProtocol {
187187
188188@_spi ( Experimental) extension ForStmtSyntax : ScopeSyntax {
189189 /// Names introduced in the `for` body.
190- public var introducedNames : [ LookupName ] {
190+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
191191 LookupName . getNames ( from: pattern)
192192 }
193193}
@@ -204,26 +204,20 @@ extension SyntaxProtocol {
204204 /// ```
205205 /// During lookup, names available at the marked place are:
206206 /// `self`, a, b.
207- public var introducedNames : [ LookupName ] {
207+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
208208 let captureNames =
209- signature? . capture? . children ( viewMode: . sourceAccurate) . flatMap { child in
210- if let captureList = child. as ( ClosureCaptureListSyntax . self) {
211- captureList. children ( viewMode: . sourceAccurate) . flatMap { capture in
212- LookupName . getNames ( from: capture)
213- }
214- } else {
215- LookupName . getNames ( from: child)
216- }
209+ signature? . capture? . items. flatMap { element in
210+ LookupName . getNames ( from: element)
217211 } ?? [ ]
218212
219213 let parameterNames =
220214 signature? . parameterClause? . children ( viewMode: . sourceAccurate) . flatMap { parameter in
221215 if let parameterList = parameter. as ( ClosureParameterListSyntax . self) {
222- parameterList. children ( viewMode: . sourceAccurate) . flatMap { parameter in
216+ return parameterList. children ( viewMode: . sourceAccurate) . flatMap { parameter in
223217 LookupName . getNames ( from: parameter)
224218 }
225219 } else {
226- LookupName . getNames ( from: parameter)
220+ return LookupName . getNames ( from: parameter)
227221 }
228222 } ?? [ ]
229223
@@ -233,7 +227,7 @@ extension SyntaxProtocol {
233227
234228@_spi ( Experimental) extension WhileStmtSyntax : ScopeSyntax {
235229 /// Names introduced by the `while` loop by its conditions.
236- public var introducedNames : [ LookupName ] {
230+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
237231 conditions. flatMap { element in
238232 LookupName . getNames ( from: element. condition)
239233 }
@@ -242,7 +236,7 @@ extension SyntaxProtocol {
242236
243237@_spi ( Experimental) extension IfExprSyntax : ScopeSyntax {
244238 /// Parent scope, omitting ancestor `if` statements if part of their `else if` clause.
245- public var parentScope : ScopeSyntax ? {
239+ @ _spi ( Experimental ) public var parentScope : ScopeSyntax ? {
246240 getParent ( for: self . parent, previousIfElse: self . elseKeyword == nil )
247241 }
248242
@@ -278,7 +272,7 @@ extension SyntaxProtocol {
278272 }
279273
280274 /// Names introduced by the `if` optional binding conditions.
281- public var introducedNames : [ LookupName ] {
275+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
282276 conditions. flatMap { element in
283277 LookupName . getNames ( from: element. condition, accessibleAfter: element. endPosition)
284278 }
@@ -296,7 +290,7 @@ extension SyntaxProtocol {
296290 /// // <-- a is not visible here
297291 /// }
298292 /// ```
299- public func lookup(
293+ @ _spi ( Experimental ) public func lookup(
300294 for name: String ? ,
301295 at syntax: SyntaxProtocol ,
302296 with config: LookupConfig ,
@@ -312,15 +306,15 @@ extension SyntaxProtocol {
312306
313307@_spi ( Experimental) extension MemberBlockSyntax : ScopeSyntax {
314308 /// All names introduced by members of this member scope.
315- public var introducedNames : [ LookupName ] {
309+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
316310 members. flatMap { member in
317311 LookupName . getNames ( from: member. decl)
318312 }
319313 }
320314}
321315
322316@_spi ( Experimental) extension GuardStmtSyntax : IntroducingToSequentialParentScopeSyntax {
323- public func introducesToSequentialParent(
317+ @ _spi ( Experimental ) public func introducesToSequentialParent(
324318 for name: String ? ,
325319 at syntax: SwiftSyntax . SyntaxProtocol ,
326320 with config: LookupConfig ,
@@ -335,7 +329,7 @@ extension SyntaxProtocol {
335329 return names. isEmpty ? [ ] : [ . fromScope( self , withNames: names) ]
336330 }
337331
338- public var introducedNames : [ LookupName ] {
332+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
339333 [ ]
340334 }
341335
@@ -350,7 +344,7 @@ extension SyntaxProtocol {
350344 /// }
351345 /// // a is visible here
352346 /// ```
353- public func lookup(
347+ @ _spi ( Experimental ) public func lookup(
354348 for name: String ? ,
355349 at syntax: SyntaxProtocol ,
356350 with config: LookupConfig ,
@@ -373,7 +367,7 @@ extension SyntaxProtocol {
373367@_spi ( Experimental) extension ExtensionDeclSyntax : TypeScopeSyntax { }
374368
375369@_spi ( Experimental) extension AccessorDeclSyntax : ScopeSyntax {
376- public var introducedNames : [ LookupName ] {
370+ @ _spi ( Experimental ) public var introducedNames : [ LookupName ] {
377371 if let parameters {
378372 LookupName . getNames ( from: parameters)
379373 } else {
0 commit comments