Class: Solargraph::Source::Chain::InstanceVariable

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

Constant Summary

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS

Instance Attribute Summary

Attributes inherited from Link

#last_context, #word

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?, #equality_fields, #freeze, #hash

Constructor Details

#initialize(word, node, location) ⇒ InstanceVariable

Returns a new instance of InstanceVariable.

Parameters:

  • word (String)
  • node (Parser::AST::Node, nil)

    The node representing the variable

  • location (Location, nil)

    The location of the variable reference in the source



10
11
12
13
14
# File 'lib/solargraph/source/chain/instance_variable.rb', line 10

def initialize word, node, location
  super(word)
  @node = node
  @location = location
end

Instance Method Details

#resolve(api_map, name_pin, locals) ⇒ Object

@sg-ignore Declared return type

::Array<::Solargraph::Pin::Base> does not match inferred
type ::Array<::Solargraph::Pin::BaseVariable, ::NilClass>
for Solargraph::Source::Chain::InstanceVariable#resolve


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

def resolve api_map, name_pin, locals
  ivars = api_map.get_instance_variable_pins(name_pin.context.namespace, name_pin.context.scope).select do |p|
    p.name == word
  end
  out = api_map.var_at_location(ivars, word, name_pin, location)
  [out].compact
end