Module: RipperRubyParser::SexpHandlers::Blocks Private
- Defined in:
- lib/ripper_ruby_parser/sexp_handlers/blocks.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 blocks and related constructs
Instance Method Summary collapse
- #process_begin(exp) ⇒ Object private
- #process_block_var(exp) ⇒ Object private
- #process_bodystmt(exp) ⇒ Object private
- #process_brace_block(exp) ⇒ Object private
- #process_break(exp) ⇒ Object private
- #process_do_block(exp) ⇒ Object private
- #process_ensure(exp) ⇒ Object private
- #process_kwrest_param(exp) ⇒ Object private
- #process_lambda(exp) ⇒ Object private
- #process_method_add_block(exp) ⇒ Object private
- #process_next(exp) ⇒ Object private
- #process_params(exp) ⇒ Object private
- #process_rescue(exp) ⇒ Object private
- #process_rescue_mod(exp) ⇒ Object private
Instance Method Details
#process_begin(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.
50 51 52 53 54 55 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 50 def process_begin(exp) _, body = exp.shift 2 body = process(body) convert_empty_to_nil_symbol(body) end |
#process_block_var(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.
42 43 44 45 46 47 48 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 42 def process_block_var(exp) _, args, = exp.shift 3 names = process(args) convert_special_args names end |
#process_bodystmt(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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 78 def process_bodystmt(exp) _, main, rescue_block, else_block, ensure_block = exp.shift 5 body = s() main = wrap_in_block map_process_sexp_body_compact(main) body << main if main if rescue_block body.push(*process(rescue_block)) body << process(else_block) if else_block body = s(s(:rescue, *body)) elsif else_block body << process(else_block) end if ensure_block body << process(ensure_block) body = s(s(:ensure, *body)) end wrap_in_block(body) || s() end |
#process_brace_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.
14 15 16 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 14 def process_brace_block(exp) handle_generic_block exp end |
#process_break(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.
122 123 124 125 126 127 128 129 130 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 122 def process_break(exp) _, args = exp.shift 2 args = handle_return_argument_list(args) if args.empty? s(:break) else s(:break, args) end end |
#process_do_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.
18 19 20 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 18 def process_do_block(exp) handle_generic_block exp end |
#process_ensure(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.
107 108 109 110 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 107 def process_ensure(exp) _, block = exp.shift 2 convert_empty_to_nil_symbol safe_unwrap_void_stmt process(block) end |
#process_kwrest_param(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.
37 38 39 40 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 37 def process_kwrest_param(exp) _, sym, = exp.shift 3 process(sym) end |
#process_lambda(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.
132 133 134 135 136 137 138 139 140 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 132 def process_lambda(exp) _, args, statements = exp.shift 3 old_type = args.sexp_type args = convert_special_args(process(args)) args = 0 if args == s(:args) && old_type == :params make_iter(s(:call, nil, :lambda), args, safe_unwrap_void_stmt(process(statements))) end |
#process_method_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.
5 6 7 8 9 10 11 12 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 5 def process_method_add_block(exp) _, call, block = exp.shift 3 block = process(block) _, args, stmt = block call = process(call) stmts = stmt.first || s() make_iter call, args, stmts end |
#process_next(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.
112 113 114 115 116 117 118 119 120 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 112 def process_next(exp) _, args = exp.shift 2 args = handle_return_argument_list(args) if args.empty? s(:next) else s(:next, args) end end |
#process_params(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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 22 def process_params(exp) _, normal, defaults, splat, rest, kwargs, doublesplat, block = exp.shift 8 args = [] args += handle_normal_arguments normal args += handle_default_arguments defaults args += handle_splat splat args += handle_normal_arguments rest args += handle_kwargs kwargs args += handle_double_splat doublesplat args += handle_block_argument block s(:args, *args) end |
#process_rescue(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 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 57 def process_rescue(exp) _, eclass, evar, block, after = exp.shift 5 rescue_block = map_process_sexp_body_compact(block) rescue_block << nil if rescue_block.empty? arr = [] if eclass if eclass.first.is_a? Symbol arr += process(eclass).sexp_body else arr << process(eclass[0]) end end arr << create_assignment_sub_type(process(evar), s(:gvar, :$!)) if evar s( s(:resbody, s(:array, *arr), *rescue_block), *process(after)) end |
#process_rescue_mod(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.
102 103 104 105 |
# File 'lib/ripper_ruby_parser/sexp_handlers/blocks.rb', line 102 def process_rescue_mod(exp) _, scary, safe = exp.shift 3 s(:rescue, process(scary), s(:resbody, s(:array), process(safe))) end |