Class: Solargraph::SourceMap::NodeProcessor::SendNode

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/source_map/node_processor/send_node.rb

Instance Attribute Summary

Attributes inherited from Base

#locals, #node, #pins, #region

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Solargraph::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

Constructor Details

This class inherits a constructor from Solargraph::SourceMap::NodeProcessor::Base

Instance Method Details

#processObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/solargraph/source_map/node_processor/send_node.rb', line 5

def process
  if node.children[0].nil?
    if [:private, :public, :protected].include?(node.children[1])
      if (node.children.length > 2)
        node.children[2..-1].each do |child|
          next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
          name = child.children[0].to_s
          matches = pins.select{ |pin| [Pin::METHOD, Pin::ATTRIBUTE].include?(pin.kind) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)}
          matches.each do |pin|
            # @todo Smelly instance variable access
            pin.instance_variable_set(:@visibility, node.children[1])
          end
        end
      else
        # @todo Smelly instance variable access
        region.instance_variable_set(:@visibility, node.children[1])
      end
    elsif node.children[1] == :module_function
      process_module_function
    elsif [:attr_reader, :attr_writer, :attr_accessor].include?(node.children[1])
      process_attribute
    elsif node.children[1] == :include
      process_include
    elsif node.children[1] == :extend
      process_extend
    elsif node.children[1] == :require
      process_require
    elsif node.children[1] == :private_constant
      process_private_constant
    elsif node.children[1] == :alias_method && node.children[2] && node.children[2] && node.children[2].type == :sym && node.children[3] && node.children[3].type == :sym
      process_alias_method
    elsif node.children[1] == :private_class_method && node.children[2].kind_of?(AST::Node)
      # Processing a private class can potentially handle children on its own
      return if process_private_class_method
    end
  end
  process_children
end