Class: Solargraph::Parser::Rubyvm::NodeProcessors::OptArgNode

Inherits:
NodeProcessor::Base show all
Defined in:
lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb

Instance Attribute Summary

Attributes inherited from NodeProcessor::Base

#locals, #node, #pins, #region

Instance Method Summary collapse

Methods inherited from NodeProcessor::Base

#initialize

Constructor Details

This class inherits a constructor from Solargraph::Parser::NodeProcessor::Base

Instance Method Details

#processObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb', line 8

def process
  locals.push Solargraph::Pin::Parameter.new(
    location: region.closure.location,
    closure: region.closure,
    comments: comments_for(node),
    name: node.children[0].children[0].to_s,
    assignment: node.children[0].children[1],
    asgn_code: node.children[0].children[1] ? region.code_for(node.children[0].children[1]) : nil,
    presence: region.closure.location.range,
    decl: :optarg
  )
  region.closure.parameters.push locals.last
  node.children[1] && NodeProcessor.process(node.children[1], region, pins, locals)
end