Class: Solargraph::Parser::ParserGem::NodeProcessors::MasgnNode

Inherits:
NodeProcessor::Base show all
Includes:
Solargraph::Parser::ParserGem::NodeMethods
Defined in:
lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb

Constant Summary

Constants included from Solargraph::Parser::ParserGem::NodeMethods

Solargraph::Parser::ParserGem::NodeMethods::NIL_NODE

Instance Attribute Summary

Attributes inherited from NodeProcessor::Base

#locals, #node, #pins, #region

Instance Method Summary collapse

Methods included from Solargraph::Parser::ParserGem::NodeMethods

any_splatted_call?, call_nodes_from, const_nodes_from, convert_hash, drill_signature, find_recipient_node, get_node_end_position, get_node_start_position, infer_literal_node_type, pack_name, repaired_find_recipient_node, returns_from_method_body, splatted_call?, splatted_hash?, unpack_name, value_position_nodes_only

Methods inherited from NodeProcessor::Base

#initialize

Constructor Details

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

Instance Method Details

#processObject



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/parser/parser_gem/node_processors/masgn_node.rb', line 10

def process
  # Example:
  #
  # s(:masgn,
  #   s(:mlhs,
  #     s(:send,
  #       s(:send, nil, :a), :b=),
  #     s(:lvasgn, :b),
  #     s(:ivasgn, :@c)),
  #   s(:array,
  #     s(:int, 1),
  #     s(:int, 2),
  #     s(:int, 3)))
  masgn = node
  mlhs = masgn.children.fetch(0)
  lhs_arr = mlhs.children
  mass_rhs = node.children.fetch(1)

  # Get pins created for the mlhs node
  process_children

  lhs_arr.each_with_index do |lhs, i|
    location = get_node_location(lhs)
    # @todo in line below, nothing in typechecking alerts
    #   when a non-existant method is called on 'l'
    pin = locals.find { |l| l.location == location }
    if pin.nil?
      Solargraph.logger.debug "Could not find pin in location #{location}"
      next
    end
    pin.mass_assignment = [mass_rhs, i]
  end
end