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

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

Direct Known Subclasses

ZSuper

Instance Attribute Summary collapse

Attributes inherited from Link

#last_context

Instance Method Summary collapse

Methods inherited from Link

#==, #clone_body, #clone_head, #constant?, #head?, #undefined?

Constructor Details

#initialize(word, arguments = [], with_block = false) ⇒ Call

Returns a new instance of Call.

Parameters:

  • word (String)
  • arguments (Array<Chain>) (defaults to: [])
  • with_block (Boolean) (defaults to: false)

    True if the chain is inside a block

  • head (Boolean)

    True if the call is the start of its chain



17
18
19
20
21
# File 'lib/solargraph/source/chain/call.rb', line 17

def initialize word, arguments = [], with_block = false
  @word = word
  @arguments = arguments
  @with_block = with_block
end

Instance Attribute Details

#argumentsArray<Chain> (readonly)

Returns:



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

def arguments
  @arguments
end

#wordString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/solargraph/source/chain/call.rb', line 8

def word
  @word
end

Instance Method Details

#resolve(api_map, name_pin, locals) ⇒ Object

Parameters:



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/solargraph/source/chain/call.rb', line 30

def resolve api_map, name_pin, locals
  return super_pins(api_map, name_pin) if word == 'super'
  found = if head?
    locals.select { |p| p.name == word }
  else
    []
  end
  return inferred_pins(found, api_map, name_pin.context, locals) unless found.empty?
  pins = api_map.get_method_stack(name_pin.binder.namespace, word, scope: name_pin.binder.scope)
  return [] if pins.empty?
  inferred_pins(pins, api_map, name_pin.context, locals)
end

#with_block?Boolean

Returns:

  • (Boolean)


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

def with_block?
  @with_block
end