Class: Solargraph::Parser::ParserGem::NodeProcessors::NamespaceNode

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

#ivars, #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, find_recipient_node_by_text, get_node_end_position, get_node_start_position, infer_literal_node_type, pack_name, repaired_find_recipient_node, returns_from_method_body, simple_convert, simple_convert_array, simple_convert_hash, 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
# File 'lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb', line 10

def process
  name = unpack_name(node.children[0])
  comments = comments_for(node)

  superclass_name = if node.type == :class && node.children[1]&.type == :const
    "#{type_from_node}#{parameters_from_inline_rbs}"
  end

  loc = get_node_location(node)
  nspin = Solargraph::Pin::Namespace.new(
    type: node.type,
    location: loc,
    closure: region.closure,
    name: name,
    comments: comments,
    visibility: :public,
    gates: region.closure.gates.freeze,
    source: :parser
  )
  pins.push nspin
  Solargraph.logger.warn "Superclass: #{superclass_name}" if superclass_name&.start_with?('Array')
  if superclass_name
    pins.push Pin::Reference::Superclass.new(
      location: loc,
      closure: pins.last,
      name: superclass_name,
      source: :parser
    )
  end
  process_children region.update(closure: nspin, visibility: :public)
end