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.



78
79
80
81
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 78

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.



101
102
103
104
105
106
107
108
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 101

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(:arglist) 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.



37
38
39
40
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 37

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.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 48

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.



61
62
63
64
65
66
67
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 61

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.



69
70
71
72
73
74
75
76
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 69

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.



94
95
96
97
98
99
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 94

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
31
32
33
34
# 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)
  if parens.sexp_type == :forward_args
    call.push(parens)
  else
    call.push(*parens.sexp_body)
  end
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.



110
111
112
113
114
115
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 110

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.



83
84
85
86
87
88
89
90
91
92
# File 'lib/ripper_ruby_parser/sexp_handlers/method_calls.rb', line 83

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