Class: Solargraph::SourceMap::NodeProcessor::ResbodyNode

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/source_map/node_processor/resbody_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
# File 'lib/solargraph/source_map/node_processor/resbody_node.rb', line 5

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