class Solargraph::Parser::NodeProcessor::Base

Attributes

locals[R]

@return [Array<Pin::Base>]

node[R]

@return [Parser::AST::Node]

pins[R]

@return [Array<Pin::Base>]

region[R]

@return [Region]

Public Class Methods

new(node, region, pins, locals) click to toggle source

@param node [Parser::AST::Node] @param region [Region] @param pins [Array<Pin::Base>]

# File lib/solargraph/parser/node_processor/base.rb, line 25
def initialize node, region, pins, locals
  @node = node
  @region = region
  @pins = pins
  @locals = locals
  @processed_children = false
end

Public Instance Methods

process() click to toggle source

Subclasses should override this method to generate new pins.

@return [void]

# File lib/solargraph/parser/node_processor/base.rb, line 36
def process
  process_children
end

Private Instance Methods

block_pin(position) click to toggle source

@todo Candidate for deprecation

# File lib/solargraph/parser/node_processor/base.rb, line 69
def block_pin position
  pins.select{|pin| pin.is_a?(Pin::Closure) && pin.location.range.contain?(position)}.last
end
closure_pin(position) click to toggle source

@todo Candidate for deprecation

# File lib/solargraph/parser/node_processor/base.rb, line 74
def closure_pin position
  pins.select{|pin| pin.is_a?(Pin::Closure) && pin.location.range.contain?(position)}.last
end
comments_for(node) click to toggle source
# File lib/solargraph/parser/node_processor/base.rb, line 60
def comments_for(node)
  region.source.comments_for(node)
end
get_node_location(node) click to toggle source

@param node [Parser::AST::Node] @return [Solargraph::Location]

# File lib/solargraph/parser/node_processor/base.rb, line 55
def get_node_location(node)
  range = Parser.node_range(node)
  Location.new(region.filename, range)
end
named_path_pin(position) click to toggle source
# File lib/solargraph/parser/node_processor/base.rb, line 64
def named_path_pin position
  pins.select{|pin| pin.is_a?(Pin::Closure) && pin.path && !pin.path.empty? && pin.location.range.contain?(position)}.last
end
process_children(subregion = region) click to toggle source

@param subregion [Region] @return [void]

# File lib/solargraph/parser/node_processor/base.rb, line 44
def process_children subregion = region
  return if @processed_children
  @processed_children = true
  node.children.each do |child|
    next unless Parser.is_ast_node?(child)
    NodeProcessor.process(child, subregion, pins, locals)
  end
end