Class: Solargraph::Pin::BaseVariable

Inherits:
Base
  • Object
show all
Includes:
NodeMethods
Defined in:
lib/solargraph/pin/base_variable.rb

Instance Attribute Summary

Attributes inherited from Base

#namespace, #node, #source

Instance Method Summary collapse

Methods included from NodeMethods

#const_from, #infer_literal_node_type, #pack_name, #resolve_node_signature, #unpack_name

Methods inherited from Base

#docstring, #filename, #initialize, #location, #parameters, #path, #value

Constructor Details

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

Instance Method Details

#kindObject



10
11
12
# File 'lib/solargraph/pin/base_variable.rb', line 10

def kind
  Solargraph::Suggestion::VARIABLE
end

#nameObject



6
7
8
# File 'lib/solargraph/pin/base_variable.rb', line 6

def name
  node.children[0].to_s
end

#return_typeObject



14
15
16
17
18
19
20
# File 'lib/solargraph/pin/base_variable.rb', line 14

def return_type
  if @return_type.nil? and !docstring.nil?
    tag = docstring.tag(:type)
    @return_type = tag.types[0] unless tag.nil?
  end
  @return_type ||= literal_from_assignment
end

#signatureObject



22
23
24
# File 'lib/solargraph/pin/base_variable.rb', line 22

def signature
  @signature ||= resolve_node_signature(node.children[(node.type == :casgn ? 2 : 1)])
end