Class: Solargraph::Source::Chain::Call
- Inherits:
-
Link
- Object
- Link
- Solargraph::Source::Chain::Call
show all
- Includes:
- ParserGem::NodeMethods
- Defined in:
- lib/solargraph/source/chain/call.rb
Overview
Handles both method calls and local variable references by first looking for a variable with the name ‘word’, then proceeding to method signature resolution if not found.
Constant Summary
Constants included
from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary collapse
Attributes inherited from Link
#last_context
Instance Method Summary
collapse
Methods inherited from Link
#clone_body, #clone_head, #constant?, #desc, #head?, #inspect, #nullable?, #to_s, #undefined?
Methods included from Logging
logger
Methods included from Equality
#==, #eql?, #freeze, #hash
Constructor Details
#initialize(word, location = nil, arguments = [], block = nil) ⇒ Call
Returns a new instance of Call.
30
31
32
33
34
35
36
|
# File 'lib/solargraph/source/chain/call.rb', line 30
def initialize word, location = nil, arguments = [], block = nil
@word = word
@location = location
@arguments = arguments
@block = block
fix_block_pass
end
|
Instance Attribute Details
#arguments ⇒ ::Array<Chain>
21
22
23
|
# File 'lib/solargraph/source/chain/call.rb', line 21
def arguments
@arguments
end
|
24
25
26
|
# File 'lib/solargraph/source/chain/call.rb', line 24
def block
@block
end
|
18
19
20
|
# File 'lib/solargraph/source/chain/call.rb', line 18
def location
@location
end
|
#word ⇒ String
15
16
17
|
# File 'lib/solargraph/source/chain/call.rb', line 15
def word
@word
end
|
Instance Method Details
#resolve(api_map, name_pin, locals) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/solargraph/source/chain/call.rb', line 50
def resolve api_map, name_pin, locals
return super_pins(api_map, name_pin) if word == 'super'
return yield_pins(api_map, name_pin) if word == 'yield'
found = if head?
api_map.visible_pins(locals, word, name_pin, location)
else
[]
end
return inferred_pins(found, api_map, name_pin, locals) unless found.empty?
pins = name_pin.binder.each_unique_type.flat_map do |context|
ns_tag = context.namespace == '' ? '' : context.namespace_type.tag
stack = api_map.get_method_stack(ns_tag, word, scope: context.scope)
[stack.first].compact
end
return [] if pins.empty?
inferred_pins(pins, api_map, name_pin, locals)
end
|
#with_block? ⇒ Boolean
43
44
45
|
# File 'lib/solargraph/source/chain/call.rb', line 43
def with_block?
!!@block
end
|