@@ -44,10 +44,10 @@ extension SyntaxProtocol {
4444 /// in this exact order. The constant declaration within the function body is omitted
4545 /// due to the ordering rules that prioritize visibility within the function body.
4646 @_spi ( Experimental) public func lookup(
47- for identifier: Identifier ? ,
47+ _ identifier: Identifier ? ,
4848 with config: LookupConfig = LookupConfig ( )
4949 ) -> [ LookupResult ] {
50- scope? . lookup ( for : identifier, at: self . position, with: config) ?? [ ]
50+ scope? . lookup ( identifier, at: self . position, with: config) ?? [ ]
5151 }
5252}
5353
@@ -58,10 +58,9 @@ extension SyntaxProtocol {
5858 var introducedNames : [ LookupName ] { get }
5959 /// Finds all declarations `identifier` refers to. `syntax` specifies the node lookup was triggered with.
6060 /// If `identifier` set to `nil`, returns all available names at the given node.
61- /// `state` represents lookup state passed between lookup methods.
6261 func lookup(
63- for identifier: Identifier ? ,
64- at origin : AbsolutePosition ,
62+ _ identifier: Identifier ? ,
63+ at lookUpPosition : AbsolutePosition ,
6564 with config: LookupConfig
6665 ) -> [ LookupResult ]
6766}
@@ -74,47 +73,50 @@ extension SyntaxProtocol {
7473 /// Returns `LookupResult` of all names introduced in this scope that `identifier`
7574 /// refers to and is accessible at given syntax node then passes lookup to the parent.
7675 /// If `identifier` set to `nil`, returns all available names at the given node.
77- /// `state` represents lookup state passed between lookup methods.
7876 @_spi ( Experimental) public func lookup(
79- for identifier: Identifier ? ,
80- at origin : AbsolutePosition ,
77+ _ identifier: Identifier ? ,
78+ at lookUpPosition : AbsolutePosition ,
8179 with config: LookupConfig
8280 ) -> [ LookupResult ] {
83- defaultLookupImplementation ( for : identifier, at: origin , with: config)
81+ defaultLookupImplementation ( identifier, at: lookUpPosition , with: config)
8482 }
8583
8684 /// Returns `LookupResult` of all names introduced in this scope that `identifier`
8785 /// refers to and is accessible at given syntax node then passes lookup to the parent.
8886 /// If `identifier` set to `nil`, returns all available names at the given node.
8987 func defaultLookupImplementation(
90- for identifier: Identifier ? ,
91- at origin : AbsolutePosition ,
88+ _ identifier: Identifier ? ,
89+ at lookUpPosition : AbsolutePosition ,
9290 with config: LookupConfig
9391 ) -> [ LookupResult ] {
9492 let filteredNames =
9593 introducedNames
9694 . filter { introducedName in
97- checkName ( identifier, refersTo: introducedName, at: origin )
95+ checkIdentifier ( identifier, refersTo: introducedName, at: lookUpPosition )
9896 }
9997
10098 if filteredNames. isEmpty {
101- return lookupInParent ( for : identifier, at: origin , with: config)
99+ return lookupInParent ( identifier, at: lookUpPosition , with: config)
102100 } else {
103101 return [ . fromScope( self , withNames: filteredNames) ]
104- + lookupInParent( for : identifier, at: origin , with: config)
102+ + lookupInParent( identifier, at: lookUpPosition , with: config)
105103 }
106104 }
107105
108106 /// Looks up in parent scope.
109107 func lookupInParent(
110- for identifier: Identifier ? ,
111- at origin : AbsolutePosition ,
108+ _ identifier: Identifier ? ,
109+ at lookUpPosition : AbsolutePosition ,
112110 with config: LookupConfig
113111 ) -> [ LookupResult ] {
114- parentScope? . lookup ( for : identifier, at: origin , with: config) ?? [ ]
112+ parentScope? . lookup ( identifier, at: lookUpPosition , with: config) ?? [ ]
115113 }
116114
117- func checkName( _ name: Identifier ? , refersTo introducedName: LookupName , at origin: AbsolutePosition ) -> Bool {
118- introducedName. isAccessible ( at: origin) && ( name == nil || introducedName. refersTo ( name!) )
115+ func checkIdentifier(
116+ _ identifier: Identifier ? ,
117+ refersTo introducedName: LookupName ,
118+ at lookUpPosition: AbsolutePosition
119+ ) -> Bool {
120+ introducedName. isAccessible ( at: lookUpPosition) && ( identifier == nil || introducedName. identifier == identifier!)
119121 }
120122}
0 commit comments