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
log_level, 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
37
|
# File 'lib/solargraph/source/chain/call.rb', line 30
def initialize word, location = nil, arguments = [], block = nil
super(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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/solargraph/source/chain/call.rb', line 46
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 = api_map.var_at_location(locals, word, name_pin, location) if head?
return inferred_pins([found], api_map, name_pin, locals) unless found.nil?
binder = name_pin.binder
binder = binder.without_nil if nullable?
pin_groups = binder.each_unique_type.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
pin_groups = [] if !api_map.loose_unions && pin_groups.any?(&:empty?)
pins = pin_groups.flatten.uniq(&:path)
return [] if pins.empty?
inferred_pins(pins, api_map, name_pin, locals)
end
|
#with_block? ⇒ Boolean
39
40
41
|
# File 'lib/solargraph/source/chain/call.rb', line 39
def with_block?
!!@block
end
|