Module: RipperRubyParser::SexpHandlers::MethodCalls Private

Defined in:
lib/ripper_ruby_parser/sexp_handlers/method_calls.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Sexp handlers for method calls

Constant Summary collapse

CALL_OP_MAP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  '.': :call,
  '::': :call,
  '&.': :safe_call
}.freeze

Instance Method Summary collapse

Instance Method Details

#map_call_op(call_op) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



74
75
76
77
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 74

def map_call_op(call_op)
  call_op = call_op.sexp_body.first.to_sym if call_op.is_a? Sexp
  CALL_OP_MAP.fetch(call_op)
end

#process_aref(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



97
98
99
100
101
102
103
104
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 97

def process_aref(exp)
  _, coll, idx = exp.shift 3

  coll = process(coll)
  idx = process(idx) || []
  idx.shift
  s(:call, coll, :[], *idx)
end

#process_arg_paren(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 18

def process_arg_paren(exp)
  _, args = exp.shift 2
  return s() if args.nil?

  process(args)
end

#process_args_add_block(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
14
15
16
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 11

def process_args_add_block(exp)
  _, regular, block = exp.shift 3
  args = process(regular)
  args << s(:block_pass, process(block)) if block
  args
end

#process_args_add_star(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 7

def process_args_add_star(exp)
  generic_add_star exp
end

#process_bare_assoc_hash(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Handle implied hashes, such as at the end of argument lists.



33
34
35
36
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 33

def process_bare_assoc_hash(exp)
  _, elems = exp.shift 2
  s(:hash, *make_hash_items(elems))
end

#process_call(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 44

def process_call(exp)
  _, receiver, op, ident = exp.shift 4
  type = map_call_op op
  case ident
  when :call
    s(type, process(receiver), :call)
  else
    with_position_from_node_symbol(ident) do |method|
      s(type, unwrap_begin(process(receiver)), method)
    end
  end
end

#process_command(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



57
58
59
60
61
62
63
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 57

def process_command(exp)
  _, ident, arglist = exp.shift 3
  with_position_from_node_symbol(ident) do |method|
    args = process(arglist).sexp_body
    s(:call, nil, method, *args)
  end
end

#process_command_call(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



65
66
67
68
69
70
71
72
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 65

def process_command_call(exp)
  _, receiver, op, ident, arguments = exp.shift 5
  type = map_call_op op
  with_position_from_node_symbol(ident) do |method|
    args = process(arguments).sexp_body
    s(type, process(receiver), method, *args)
  end
end

#process_fcall(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



90
91
92
93
94
95
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 90

def process_fcall(exp)
  _, ident = exp.shift 2
  with_position_from_node_symbol(ident) do |method|
    s(:call, nil, method)
  end
end

#process_method_add_arg(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
30
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 25

def process_method_add_arg(exp)
  _, call, parens = exp.shift 3
  call = process(call)
  parens = process(parens)
  call.push(*parens.sexp_body)
end

#process_super(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



106
107
108
109
110
111
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 106

def process_super(exp)
  _, args = exp.shift 2
  args = process(args)
  args.shift
  s(:super, *args)
end

#process_vcall(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



79
80
81
82
83
84
85
86
87
88
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 79

def process_vcall(exp)
  _, ident = exp.shift 2
  with_position_from_node_symbol(ident) do |method|
    if replace_kwrest_arg_call? method
      s(:lvar, method)
    else
      s(:call, nil, method)
    end
  end
end