Class: Solargraph::SourceMap::NodeProcessor::DefsNode

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

def process
  s_visi = region.visibility
  s_visi = :public if s_visi == :module_function || region.scope != :class
  loc = get_node_location(node)
  if node.children[0].is_a?(AST::Node) && node.children[0].type == :self
    closure = region.closure
  else
    closure = Solargraph::Pin::Namespace.new(
      name: unpack_name(node.children[0])
    )
  end
  pins.push Solargraph::Pin::Method.new(
    location: loc,
    closure: closure,
    name: node.children[1].to_s,
    comments: comments_for(node),
    scope: :class,
    visibility: s_visi,
    args: method_args,
    node: node
  )
  process_children region.update(closure: pins.last, scope: :class)
end