Class: Solargraph::Parser::ParserGem::NodeProcessors::ArgsNode

Inherits:
NodeProcessor::Base show all
Defined in:
lib/solargraph/parser/parser_gem/node_processors/args_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
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/solargraph/parser/parser_gem/node_processors/args_node.rb', line 8

def process
  callable = region.closure
  if callable.is_a? Pin::Callable
    if node.type == :forward_args
      forward(callable)
    else
      node.children.each do |u|
        loc = get_node_location(u)
        locals.push Solargraph::Pin::Parameter.new(
                      location: loc,
                      closure: callable,
                      comments: comments_for(node),
                      name: u.children[0].to_s,
                      assignment: u.children[1],
                      asgn_code: u.children[1] ? region.code_for(u.children[1]) : nil,
                      presence: callable.location.range,
                      decl: get_decl(u),
                      source: :parser
                    )
        callable.parameters.push locals.last
      end
    end
  end
  process_children
end