Class: Solargraph::Parser::Rubyvm::NodeProcessors::NamespaceNode

Inherits:
NodeProcessor::Base show all
Includes:
Solargraph::Parser::Rubyvm::NodeMethods
Defined in:
lib/solargraph/parser/rubyvm/node_processors/namespace_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

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

def process
  sc = nil
  if node.type == :CLASS && !node.children[1].nil?
    sc = unpack_name(node.children[1])
  end
  loc = get_node_location(node)
  nspin = Solargraph::Pin::Namespace.new(
    type: node.type.to_s.downcase.to_sym,
    location: loc,
    closure: region.closure,
    name: unpack_name(node.children[0]),
    comments: comments_for(node),
    visibility: :public,
    gates: region.closure.gates.freeze
  )
  pins.push nspin
  unless sc.nil?
    pins.push Pin::Reference::Superclass.new(
      location: loc,
      closure: pins.last,
      name: sc
    )
  end
  process_children region.update(closure: nspin, visibility: :public)
end