@@ -44,10 +44,10 @@ extension SyntaxProtocol {
44
44
/// in this exact order. The constant declaration within the function body is omitted
45
45
/// due to the ordering rules that prioritize visibility within the function body.
46
46
@_spi ( Experimental) public func lookup(
47
- for identifier: Identifier ? ,
47
+ _ identifier: Identifier ? ,
48
48
with config: LookupConfig = LookupConfig ( )
49
49
) -> [ LookupResult ] {
50
- scope? . lookup ( for : identifier, at: self . position, with: config) ?? [ ]
50
+ scope? . lookup ( identifier, at: self . position, with: config) ?? [ ]
51
51
}
52
52
}
53
53
@@ -58,10 +58,9 @@ extension SyntaxProtocol {
58
58
var introducedNames : [ LookupName ] { get }
59
59
/// Finds all declarations `identifier` refers to. `syntax` specifies the node lookup was triggered with.
60
60
/// If `identifier` set to `nil`, returns all available names at the given node.
61
- /// `state` represents lookup state passed between lookup methods.
62
61
func lookup(
63
- for identifier: Identifier ? ,
64
- at origin : AbsolutePosition ,
62
+ _ identifier: Identifier ? ,
63
+ at lookUpPosition : AbsolutePosition ,
65
64
with config: LookupConfig
66
65
) -> [ LookupResult ]
67
66
}
@@ -74,47 +73,50 @@ extension SyntaxProtocol {
74
73
/// Returns `LookupResult` of all names introduced in this scope that `identifier`
75
74
/// refers to and is accessible at given syntax node then passes lookup to the parent.
76
75
/// If `identifier` set to `nil`, returns all available names at the given node.
77
- /// `state` represents lookup state passed between lookup methods.
78
76
@_spi ( Experimental) public func lookup(
79
- for identifier: Identifier ? ,
80
- at origin : AbsolutePosition ,
77
+ _ identifier: Identifier ? ,
78
+ at lookUpPosition : AbsolutePosition ,
81
79
with config: LookupConfig
82
80
) -> [ LookupResult ] {
83
- defaultLookupImplementation ( for : identifier, at: origin , with: config)
81
+ defaultLookupImplementation ( identifier, at: lookUpPosition , with: config)
84
82
}
85
83
86
84
/// Returns `LookupResult` of all names introduced in this scope that `identifier`
87
85
/// refers to and is accessible at given syntax node then passes lookup to the parent.
88
86
/// If `identifier` set to `nil`, returns all available names at the given node.
89
87
func defaultLookupImplementation(
90
- for identifier: Identifier ? ,
91
- at origin : AbsolutePosition ,
88
+ _ identifier: Identifier ? ,
89
+ at lookUpPosition : AbsolutePosition ,
92
90
with config: LookupConfig
93
91
) -> [ LookupResult ] {
94
92
let filteredNames =
95
93
introducedNames
96
94
. filter { introducedName in
97
- checkName ( identifier, refersTo: introducedName, at: origin )
95
+ checkIdentifier ( identifier, refersTo: introducedName, at: lookUpPosition )
98
96
}
99
97
100
98
if filteredNames. isEmpty {
101
- return lookupInParent ( for : identifier, at: origin , with: config)
99
+ return lookupInParent ( identifier, at: lookUpPosition , with: config)
102
100
} else {
103
101
return [ . fromScope( self , withNames: filteredNames) ]
104
- + lookupInParent( for : identifier, at: origin , with: config)
102
+ + lookupInParent( identifier, at: lookUpPosition , with: config)
105
103
}
106
104
}
107
105
108
106
/// Looks up in parent scope.
109
107
func lookupInParent(
110
- for identifier: Identifier ? ,
111
- at origin : AbsolutePosition ,
108
+ _ identifier: Identifier ? ,
109
+ at lookUpPosition : AbsolutePosition ,
112
110
with config: LookupConfig
113
111
) -> [ LookupResult ] {
114
- parentScope? . lookup ( for : identifier, at: origin , with: config) ?? [ ]
112
+ parentScope? . lookup ( identifier, at: lookUpPosition , with: config) ?? [ ]
115
113
}
116
114
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!)
119
121
}
120
122
}
0 commit comments