Class: Solargraph::Parser::Rubyvm::NodeProcessors::ResbodyNode

Inherits:
NodeProcessor::Base show all
Includes:
Solargraph::Parser::Rubyvm::NodeMethods
Defined in:
lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb

Instance Attribute Summary

Attributes inherited from NodeProcessor::Base

#locals, #node, #pins, #region

Instance Method Summary collapse

Methods included from Solargraph::Parser::Rubyvm::NodeMethods

any_splatted_call?, call_nodes_from, const_nodes_from, convert_hash, find_recipient_node, infer_literal_node_type, node?, pack_name, returns_from, splatted_call?, splatted_hash?, splatted_node?, unpack_name

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
# File 'lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb', line 10

def process
  presence = Range.from_node(node)
  loc = get_node_location(node.children[1])
  if node.children[1] && node.children[1].children.first
    types = if !node.children.first || node.children.first.children.empty?
              ['Exception']
            else
              node.children.first.children[0..-2].map do |child|
                unpack_name(child)
              end
            end
    if exception_variable?
      locals.push Solargraph::Pin::LocalVariable.new(
        location: loc,
        closure: region.closure,
        name: node.children[1].children.first.children.first.to_s,
        comments: "@type [#{types.join(',')}]",
        presence: presence
      )
    end
  end
  NodeProcessor.process(node.children[1], region, pins, locals)
end