Class: Solargraph::Pin::InstanceVariable

Inherits:
BaseVariable show all
Defined in:
lib/solargraph/pin/instance_variable.rb

Instance Attribute Summary

Attributes inherited from BaseVariable

#assignment

Attributes inherited from Base

#code_object, #location, #name, #path, #return_type

Attributes included from Common

#closure, #location

Instance Method Summary collapse

Methods inherited from BaseVariable

#==, #completion_item_kind, #initialize, #nil_assignment?, #probe, #return_type, #signature, #symbol_kind, #variable?

Methods included from Source::NodeMethods

const_from, drill_signature, get_node_end_position, get_node_start_position, infer_literal_node_type, pack_name, resolve_node_signature, returns_from, unpack_name

Methods inherited from Base

#==, #comments, #completion_item_kind, #deprecated?, #directives, #docstring, #filename, #infer, #initialize, #inspect, #macros, #maybe_directives?, #probe, #probed?, #proxied?, #proxy, #realize, #symbol_kind, #to_s, #typify, #variable?

Methods included from Documenting

#documentation

Methods included from Conversions

#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help

Methods included from Common

#comments, #name, #namespace, #path, #return_type

Constructor Details

This class inherits a constructor from Solargraph::Pin::BaseVariable

Instance Method Details

#binderObject


8
9
10
# File 'lib/solargraph/pin/instance_variable.rb', line 8

def binder
  closure.binder
end

#contextObject


16
17
18
19
20
21
22
23
24
25
# File 'lib/solargraph/pin/instance_variable.rb', line 16

def context
  @context ||= begin
    result = super
    if scope == :class
      ComplexType.parse("Class<#{result.namespace}>")
    else
      ComplexType.parse("#{result.namespace}")
    end
  end
end

#kindObject


4
5
6
# File 'lib/solargraph/pin/instance_variable.rb', line 4

def kind
  Pin::INSTANCE_VARIABLE
end

#nearly?(other) ⇒ Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/solargraph/pin/instance_variable.rb', line 27

def nearly? other
  super && binder == other.binder
end

#scopeObject


12
13
14
# File 'lib/solargraph/pin/instance_variable.rb', line 12

def scope
  closure.binder.scope
end

#try_merge!(pin) ⇒ Object


31
32
33
34
35
36
# File 'lib/solargraph/pin/instance_variable.rb', line 31

def try_merge! pin
  return false unless super
  @assignment = pin.assignment
  @return_type = pin.return_type
  true
end