Class: Solargraph::Source::Chain::Call

Inherits:
Link
  • Object
show all
Includes:
ParserGem::NodeMethods
Defined in:
lib/solargraph/source/chain/call.rb

Direct Known Subclasses

QCall, ZSuper

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?, #undefined?

Constructor Details

#initialize(word, arguments = [], block = nil) ⇒ Call

Returns a new instance of Call.

Parameters:

  • word (String)
  • arguments (::Array<Chain>) (defaults to: [])
  • block (Chain, nil) (defaults to: nil)


21
22
23
24
25
26
# File 'lib/solargraph/source/chain/call.rb', line 21

def initialize word, arguments = [], block = nil
  @word = word
  @arguments = arguments
  @block = block
  fix_block_pass
end

Instance Attribute Details

#arguments::Array<Chain> (readonly)

Returns:



13
14
15
# File 'lib/solargraph/source/chain/call.rb', line 13

def arguments
  @arguments
end

#blockChain? (readonly)

Returns:



16
17
18
# File 'lib/solargraph/source/chain/call.rb', line 16

def block
  @block
end

#wordString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/solargraph/source/chain/call.rb', line 10

def word
  @word
end

Instance Method Details

#resolve(api_map, name_pin, locals) ⇒ Object

Parameters:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/solargraph/source/chain/call.rb', line 35

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?
    locals.select { |p| p.name == word }
  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 = context.namespace == '' ? '' : context.namespace_type.tag
    api_map.get_method_stack(ns, word, scope: context.scope)
  end
  return [] if pins.empty?
  inferred_pins(pins, api_map, name_pin, locals)
end

#with_block?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/solargraph/source/chain/call.rb', line 28

def with_block?
  !!@block
end