Class: Solargraph::Parser::Legacy::NodeProcessors::SclassNode
- Inherits:
-
NodeProcessor::Base
- Object
- NodeProcessor::Base
- Solargraph::Parser::Legacy::NodeProcessors::SclassNode
- Defined in:
- lib/solargraph/parser/legacy/node_processors/sclass_node.rb
Instance Attribute Summary
Attributes inherited from NodeProcessor::Base
#locals, #node, #pins, #region
Instance Method Summary collapse
Methods inherited from NodeProcessor::Base
Constructor Details
This class inherits a constructor from Solargraph::Parser::NodeProcessor::Base
Instance Method Details
#process ⇒ Object
8 9 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 |
# File 'lib/solargraph/parser/legacy/node_processors/sclass_node.rb', line 8 def process sclass = node.children[0] if sclass.is_a?(AST::Node) && sclass.type == :self closure = region.closure elsif sclass.is_a?(AST::Node) && sclass.type == :casgn names = [region.closure.namespace, region.closure.name] if sclass.children[0].nil? && names.last != sclass.children[1].to_s names << sclass.children[1].to_s else names.concat [NodeMethods.unpack_name(sclass.children[0]), sclass.children[1].to_s] end name = names.reject(&:empty?).join('::') closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location) elsif sclass.is_a?(AST::Node) && sclass.type == :const names = [region.closure.namespace, region.closure.name] also = NodeMethods.unpack_name(sclass) if also != region.closure.name names << also end name = names.reject(&:empty?).join('::') closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location) else return end pins.push Solargraph::Pin::Singleton.new( location: get_node_location(node), closure: closure ) process_children region.update(visibility: :public, scope: :class, closure: pins.last) end |