Class: Rubycop::Analyzer::NodeBuilder
- Inherits:
-
Ripper::SexpBuilder
- Object
- Ripper::SexpBuilder
- Rubycop::Analyzer::NodeBuilder
- Defined in:
- lib/rubycop/analyzer/node_builder.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(src, filename = nil, lineno = nil) ⇒ NodeBuilder
constructor
A new instance of NodeBuilder.
- #on_alias(new_name, old_name) ⇒ Object
- #on_aref(target, args) ⇒ Object
- #on_aref_field(target, args) ⇒ Object
- #on_arg_paren(args) ⇒ Object
- #on_args_add(args, arg) ⇒ Object
- #on_args_add_block(args, block) ⇒ Object
- #on_args_new ⇒ Object
- #on_array(args) ⇒ Object
- #on_assign(lvalue, rvalue) ⇒ Object
- #on_assoc_new(key, value) ⇒ Object
- #on_assoclist_from_args(args) ⇒ Object
- #on_bare_assoc_hash(assocs) ⇒ Object
- #on_BEGIN(statements) ⇒ Object
- #on_begin(body) ⇒ Object
- #on_binary(lvalue, operator, rvalue) ⇒ Object
- #on_block_var(params, something) ⇒ Object
- #on_blockarg(arg) ⇒ Object
- #on_bodystmt(body, rescue_block, else_block, ensure_block) ⇒ Object
- #on_brace_block(params, statements) ⇒ Object
- #on_break(args) ⇒ Object
- #on_call(target, separator, identifier) ⇒ Object
- #on_case(args, when_block) ⇒ Object
- #on_CHAR(token) ⇒ Object
- #on_class(const, superclass, body) ⇒ Object
- #on_class_name_error(ident) ⇒ Object
- #on_command(identifier, args) ⇒ Object
- #on_command_call(target, separator, identifier, args) ⇒ Object
- #on_const(token) ⇒ Object
- #on_const_path_field(namespace, const) ⇒ Object
- #on_const_path_ref(namespace, const) ⇒ Object
- #on_const_ref(const) ⇒ Object
- #on_cvar(token) ⇒ Object
- #on_def(identifier, params, body) ⇒ Object
- #on_defined(ref) ⇒ Object
- #on_defs(target, separator, identifier, params, body) ⇒ Object
- #on_do_block(params, statements) ⇒ Object
- #on_dot2(min, max) ⇒ Object
- #on_dot3(min, max) ⇒ Object
- #on_dyna_symbol(symbol) ⇒ Object
- #on_else(statements) ⇒ Object
- #on_END(statements) ⇒ Object
- #on_ensure(statements) ⇒ Object
- #on_fcall(identifier) ⇒ Object
- #on_field(target, separator, identifier) ⇒ Object
- #on_float(token) ⇒ Object
- #on_for(variable, range, statements) ⇒ Object
- #on_gvar(token) ⇒ Object
- #on_hash(assocs) ⇒ Object
- #on_ident(token) ⇒ Object
- #on_if(expression, statements, else_block) ⇒ Object (also: #on_elsif)
- #on_if_mod(expression, statement) ⇒ Object
- #on_ifop(condition, then_part, else_part) ⇒ Object
- #on_int(token) ⇒ Object
- #on_ivar(token) ⇒ Object
- #on_kw(token) ⇒ Object
- #on_label(token) ⇒ Object
- #on_lambda(params, statements) ⇒ Object
- #on_massign(lvalue, rvalue) ⇒ Object
- #on_method_add_arg(call, args) ⇒ Object
- #on_method_add_block(call, block) ⇒ Object
- #on_mlhs_add(assignment, ref) ⇒ Object
- #on_mlhs_add_star(assignment, ref) ⇒ Object
- #on_mlhs_new ⇒ Object
- #on_module(const, body) ⇒ Object
- #on_mrhs_add(assignment, ref) ⇒ Object
- #on_mrhs_new_from_args(args) ⇒ Object
- #on_next(args) ⇒ Object
- #on_op(operator) ⇒ Object
- #on_opassign(lvalue, operator, rvalue) ⇒ Object
- #on_params(params, optionals, rest, something, block) ⇒ Object
- #on_paren(node) ⇒ Object
- #on_parse_error(message) ⇒ Object
- #on_program(statements) ⇒ Object
- #on_qwords_add(array, word) ⇒ Object
- #on_qwords_new ⇒ Object
- #on_redo ⇒ Object
- #on_regexp_add(regexp, content) ⇒ Object
- #on_regexp_literal(regexp, rdelim) ⇒ Object
- #on_regexp_new ⇒ Object
- #on_rescue(types, var, statements, block) ⇒ Object
- #on_rescue_mod(expression, statements) ⇒ Object
- #on_rest_param(param) ⇒ Object
- #on_retry ⇒ Object
- #on_return(args) ⇒ Object
- #on_sclass(superclass, body) ⇒ Object
- #on_stmts_add(target, statement) ⇒ Object
- #on_stmts_new ⇒ Object
- #on_string_add(string, content) ⇒ Object
- #on_string_concat(*strings) ⇒ Object
- #on_string_content ⇒ Object
-
#on_string_dvar(variable) ⇒ Object
weird string syntax that I didn’t know existed until writing this lib.
- #on_string_embexpr(expression) ⇒ Object
- #on_string_literal(string) ⇒ Object
- #on_super(args) ⇒ Object
- #on_symbol(token) ⇒ Object
- #on_symbol_literal(symbol) ⇒ Object
- #on_top_const_field(field) ⇒ Object
- #on_top_const_ref(const) ⇒ Object
- #on_tstring_content(token) ⇒ Object
- #on_unary(operator, operand) ⇒ Object
- #on_undef(args) ⇒ Object
- #on_unless(expression, statements, else_block) ⇒ Object
- #on_unless_mod(expression, statement) ⇒ Object
- #on_until(expression, statements) ⇒ Object
- #on_until_mod(expression, statement) ⇒ Object
- #on_var_alias(new_name, old_name) ⇒ Object
- #on_var_field(field) ⇒ Object
- #on_var_ref(ref) ⇒ Object
- #on_void_stmt ⇒ Object
- #on_when(expression, statements, next_block) ⇒ Object
- #on_while(expression, statements) ⇒ Object
- #on_while_mod(expression, statement) ⇒ Object
- #on_word_add(string, word) ⇒ Object
- #on_word_new ⇒ Object
- #on_words_add(array, word) ⇒ Object
- #on_words_new ⇒ Object
- #on_xstring_add(string, content) ⇒ Object
- #on_xstring_literal(string) ⇒ Object
- #on_xstring_new ⇒ Object
- #on_yield(args) ⇒ Object
- #on_yield0 ⇒ Object
- #on_zsuper ⇒ Object
Constructor Details
#initialize(src, filename = nil, lineno = nil) ⇒ NodeBuilder
Returns a new instance of NodeBuilder.
4 5 6 7 8 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 4 def initialize(src, filename=nil, lineno=nil) @src = src ||= filename && File.read(filename) || '' @filename = filename super end |
Class Method Details
.build(src, filename = nil) ⇒ Object
11 12 13 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 11 def build(src, filename=nil) new(src, filename).parse end |
Instance Method Details
#on_alias(new_name, old_name) ⇒ Object
16 17 18 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 16 def on_alias(new_name, old_name) Ruby::Alias.new(to_ident(new_name), to_ident(old_name)) end |
#on_aref(target, args) ⇒ Object
20 21 22 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 20 def on_aref(target, args) Ruby::Call.new(target, ident(:[]), args) end |
#on_aref_field(target, args) ⇒ Object
24 25 26 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 24 def on_aref_field(target, args) Ruby::Call.new(target, ident(:[]), args) end |
#on_arg_paren(args) ⇒ Object
28 29 30 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 28 def on_arg_paren(args) args end |
#on_args_add(args, arg) ⇒ Object
32 33 34 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 32 def on_args_add(args, arg) args.add(arg); args end |
#on_args_add_block(args, block) ⇒ Object
36 37 38 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 36 def on_args_add_block(args, block) args.add_block(block) if block; args end |
#on_args_new ⇒ Object
40 41 42 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 40 def on_args_new Ruby::Args.new end |
#on_array(args) ⇒ Object
44 45 46 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 44 def on_array(args) args ? args.to_array : Ruby::Array.new end |
#on_assign(lvalue, rvalue) ⇒ Object
48 49 50 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 48 def on_assign(lvalue, rvalue) lvalue.assignment(rvalue, ident(:'=')) end |
#on_assoc_new(key, value) ⇒ Object
52 53 54 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 52 def on_assoc_new(key, value) Ruby::Assoc.new(key, value) end |
#on_assoclist_from_args(args) ⇒ Object
56 57 58 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 56 def on_assoclist_from_args(args) args end |
#on_bare_assoc_hash(assocs) ⇒ Object
60 61 62 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 60 def (assocs) Ruby::Hash.new(assocs) end |
#on_BEGIN(statements) ⇒ Object
64 65 66 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 64 def on_BEGIN(statements) Ruby::Call.new(nil, ident(:BEGIN), nil, statements) end |
#on_begin(body) ⇒ Object
68 69 70 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 68 def on_begin(body) body.is_a?(Ruby::ChainedBlock) ? body : body.to_chained_block end |
#on_binary(lvalue, operator, rvalue) ⇒ Object
72 73 74 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 72 def on_binary(lvalue, operator, rvalue) Ruby::Binary.new(lvalue, rvalue, operator) end |
#on_block_var(params, something) ⇒ Object
80 81 82 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 80 def on_block_var(params, something) params end |
#on_blockarg(arg) ⇒ Object
76 77 78 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 76 def on_blockarg(arg) arg end |
#on_bodystmt(body, rescue_block, else_block, ensure_block) ⇒ Object
84 85 86 87 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 84 def on_bodystmt(body, rescue_block, else_block, ensure_block) statements = [rescue_block, else_block, ensure_block].compact statements.empty? ? body : body.to_chained_block(statements) end |
#on_brace_block(params, statements) ⇒ Object
89 90 91 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 89 def on_brace_block(params, statements) statements.to_block(params) end |
#on_break(args) ⇒ Object
93 94 95 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 93 def on_break(args) Ruby::Call.new(nil, ident(:break), args) end |
#on_call(target, separator, identifier) ⇒ Object
97 98 99 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 97 def on_call(target, separator, identifier) Ruby::Call.new(target, identifier) end |
#on_case(args, when_block) ⇒ Object
101 102 103 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 101 def on_case(args, when_block) Ruby::Case.new(args, when_block) end |
#on_CHAR(token) ⇒ Object
105 106 107 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 105 def on_CHAR(token) Ruby::Char.new(token, position) end |
#on_class(const, superclass, body) ⇒ Object
109 110 111 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 109 def on_class(const, superclass, body) Ruby::Class.new(const, superclass, body) end |
#on_class_name_error(ident) ⇒ Object
113 114 115 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 113 def on_class_name_error(ident) raise SyntaxError, 'class/module name must be CONSTANT' end |
#on_command(identifier, args) ⇒ Object
117 118 119 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 117 def on_command(identifier, args) Ruby::Call.new(nil, identifier, args) end |
#on_command_call(target, separator, identifier, args) ⇒ Object
121 122 123 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 121 def on_command_call(target, separator, identifier, args) Ruby::Call.new(target, identifier, args) end |
#on_const(token) ⇒ Object
125 126 127 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 125 def on_const(token) Ruby::Constant.new(token, position) end |
#on_const_path_field(namespace, const) ⇒ Object
129 130 131 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 129 def on_const_path_field(namespace, const) const.namespace = namespace; const end |
#on_const_path_ref(namespace, const) ⇒ Object
133 134 135 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 133 def on_const_path_ref(namespace, const) const.namespace = namespace; const end |
#on_const_ref(const) ⇒ Object
137 138 139 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 137 def on_const_ref(const) const end |
#on_cvar(token) ⇒ Object
141 142 143 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 141 def on_cvar(token) Ruby::ClassVariable.new(token, position) end |
#on_def(identifier, params, body) ⇒ Object
145 146 147 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 145 def on_def(identifier, params, body) Ruby::Method.new(nil, identifier, params, body) end |
#on_defined(ref) ⇒ Object
153 154 155 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 153 def on_defined(ref) Ruby::Defined.new(ref) end |
#on_defs(target, separator, identifier, params, body) ⇒ Object
149 150 151 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 149 def on_defs(target, separator, identifier, params, body) Ruby::Method.new(target, identifier, params, body) end |
#on_do_block(params, statements) ⇒ Object
157 158 159 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 157 def on_do_block(params, statements) statements.to_block(params) end |
#on_dot2(min, max) ⇒ Object
161 162 163 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 161 def on_dot2(min, max) Ruby::Range.new(min, max, false) end |
#on_dot3(min, max) ⇒ Object
165 166 167 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 165 def on_dot3(min, max) Ruby::Range.new(min, max, true) end |
#on_dyna_symbol(symbol) ⇒ Object
169 170 171 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 169 def on_dyna_symbol(symbol) symbol.to_dyna_symbol end |
#on_else(statements) ⇒ Object
173 174 175 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 173 def on_else(statements) Ruby::Else.new(statements) end |
#on_END(statements) ⇒ Object
177 178 179 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 177 def on_END(statements) Ruby::Call.new(nil, ident(:END), nil, statements) end |
#on_ensure(statements) ⇒ Object
181 182 183 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 181 def on_ensure(statements) statements end |
#on_fcall(identifier) ⇒ Object
198 199 200 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 198 def on_fcall(identifier) Ruby::Call.new(nil, identifier) end |
#on_field(target, separator, identifier) ⇒ Object
202 203 204 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 202 def on_field(target, separator, identifier) Ruby::Call.new(target, identifier) end |
#on_float(token) ⇒ Object
206 207 208 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 206 def on_float(token) Ruby::Float.new(token, position) end |
#on_for(variable, range, statements) ⇒ Object
210 211 212 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 210 def on_for(variable, range, statements) Ruby::For.new(variable, range, statements) end |
#on_gvar(token) ⇒ Object
214 215 216 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 214 def on_gvar(token) Ruby::GlobalVariable.new(token, position) end |
#on_hash(assocs) ⇒ Object
218 219 220 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 218 def on_hash(assocs) Ruby::Hash.new(assocs) end |
#on_ident(token) ⇒ Object
222 223 224 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 222 def on_ident(token) ident(token) end |
#on_if(expression, statements, else_block) ⇒ Object Also known as: on_elsif
185 186 187 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 185 def on_if(expression, statements, else_block) Ruby::If.new(expression, statements, else_block) end |
#on_if_mod(expression, statement) ⇒ Object
194 195 196 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 194 def on_if_mod(expression, statement) Ruby::IfMod.new(expression, statement) end |
#on_ifop(condition, then_part, else_part) ⇒ Object
190 191 192 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 190 def on_ifop(condition, then_part, else_part) Ruby::IfOp.new(condition, then_part, else_part) end |
#on_int(token) ⇒ Object
226 227 228 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 226 def on_int(token) Ruby::Integer.new(token, position) end |
#on_ivar(token) ⇒ Object
230 231 232 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 230 def on_ivar(token) Ruby::InstanceVariable.new(token, position) end |
#on_kw(token) ⇒ Object
234 235 236 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 234 def on_kw(token) Ruby::Keyword.new(token, position) end |
#on_label(token) ⇒ Object
238 239 240 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 238 def on_label(token) Ruby::Label.new(token, position) end |
#on_lambda(params, statements) ⇒ Object
242 243 244 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 242 def on_lambda(params, statements) Ruby::Block.new(statements, params) end |
#on_massign(lvalue, rvalue) ⇒ Object
246 247 248 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 246 def on_massign(lvalue, rvalue) lvalue.assignment(rvalue, ident(:'=')) end |
#on_method_add_arg(call, args) ⇒ Object
250 251 252 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 250 def on_method_add_arg(call, args) call.arguments = args; call end |
#on_method_add_block(call, block) ⇒ Object
254 255 256 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 254 def on_method_add_block(call, block) call.block = block; call end |
#on_mlhs_add(assignment, ref) ⇒ Object
258 259 260 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 258 def on_mlhs_add(assignment, ref) assignment.add(ref); assignment end |
#on_mlhs_add_star(assignment, ref) ⇒ Object
262 263 264 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 262 def on_mlhs_add_star(assignment, ref) assignment.add(Ruby::SplatArg.new(ref)); assignment end |
#on_mlhs_new ⇒ Object
266 267 268 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 266 def on_mlhs_new Ruby::MultiAssignmentList.new end |
#on_module(const, body) ⇒ Object
270 271 272 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 270 def on_module(const, body) Ruby::Module.new(const, body) end |
#on_mrhs_add(assignment, ref) ⇒ Object
274 275 276 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 274 def on_mrhs_add(assignment, ref) assignment.add(ref); assignment end |
#on_mrhs_new_from_args(args) ⇒ Object
278 279 280 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 278 def on_mrhs_new_from_args(args) Ruby::MultiAssignmentList.new(args.elements) end |
#on_next(args) ⇒ Object
282 283 284 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 282 def on_next(args) Ruby::Call.new(nil, ident(:next), args) end |
#on_op(operator) ⇒ Object
286 287 288 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 286 def on_op(operator) operator.intern end |
#on_opassign(lvalue, operator, rvalue) ⇒ Object
290 291 292 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 290 def on_opassign(lvalue, operator, rvalue) lvalue.assignment(rvalue, operator) end |
#on_params(params, optionals, rest, something, block) ⇒ Object
294 295 296 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 294 def on_params(params, optionals, rest, something, block) Ruby::Params.new(params, optionals, rest, block) end |
#on_paren(node) ⇒ Object
298 299 300 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 298 def on_paren(node) node end |
#on_parse_error(message) ⇒ Object
302 303 304 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 302 def on_parse_error() raise SyntaxError, end |
#on_program(statements) ⇒ Object
306 307 308 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 306 def on_program(statements) statements.to_program(@src, @filename) end |
#on_qwords_add(array, word) ⇒ Object
310 311 312 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 310 def on_qwords_add(array, word) array.add(Ruby::String.new(word)); array end |
#on_qwords_new ⇒ Object
314 315 316 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 314 def on_qwords_new Ruby::Array.new end |
#on_redo ⇒ Object
318 319 320 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 318 def on_redo Ruby::Call.new(nil, ident(:redo)) end |
#on_regexp_add(regexp, content) ⇒ Object
322 323 324 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 322 def on_regexp_add(regexp, content) regexp.add(content); regexp end |
#on_regexp_literal(regexp, rdelim) ⇒ Object
326 327 328 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 326 def on_regexp_literal(regexp, rdelim) regexp end |
#on_regexp_new ⇒ Object
330 331 332 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 330 def on_regexp_new Ruby::Regexp.new end |
#on_rescue(types, var, statements, block) ⇒ Object
334 335 336 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 334 def on_rescue(types, var, statements, block) statements.to_chained_block(block, Ruby::RescueParams.new(types, var)) end |
#on_rescue_mod(expression, statements) ⇒ Object
338 339 340 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 338 def on_rescue_mod(expression, statements) Ruby::RescueMod.new(expression, statements) end |
#on_rest_param(param) ⇒ Object
342 343 344 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 342 def on_rest_param(param) param end |
#on_retry ⇒ Object
346 347 348 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 346 def on_retry Ruby::Call.new(nil, ident(:retry)) end |
#on_return(args) ⇒ Object
350 351 352 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 350 def on_return(args) Ruby::Call.new(nil, ident(:return), args) end |
#on_sclass(superclass, body) ⇒ Object
354 355 356 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 354 def on_sclass(superclass, body) Ruby::SingletonClass.new(superclass, body) end |
#on_stmts_add(target, statement) ⇒ Object
358 359 360 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 358 def on_stmts_add(target, statement) target.add(statement) if statement; target end |
#on_stmts_new ⇒ Object
362 363 364 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 362 def on_stmts_new Ruby::Statements.new end |
#on_string_add(string, content) ⇒ Object
366 367 368 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 366 def on_string_add(string, content) string.add(content); string end |
#on_string_concat(*strings) ⇒ Object
370 371 372 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 370 def on_string_concat(*strings) Ruby::StringConcat.new(strings) end |
#on_string_content ⇒ Object
374 375 376 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 374 def on_string_content Ruby::String.new end |
#on_string_dvar(variable) ⇒ Object
weird string syntax that I didn’t know existed until writing this lib. ex. “safe level is #$SAFE” => “safe level is 0”
380 381 382 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 380 def on_string_dvar(variable) variable end |
#on_string_embexpr(expression) ⇒ Object
384 385 386 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 384 def on_string_embexpr(expression) expression end |
#on_string_literal(string) ⇒ Object
388 389 390 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 388 def on_string_literal(string) string end |
#on_super(args) ⇒ Object
392 393 394 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 392 def on_super(args) Ruby::Call.new(nil, ident(:super), args) end |
#on_symbol(token) ⇒ Object
396 397 398 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 396 def on_symbol(token) Ruby::Symbol.new(token, position) end |
#on_symbol_literal(symbol) ⇒ Object
400 401 402 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 400 def on_symbol_literal(symbol) symbol end |
#on_top_const_field(field) ⇒ Object
404 405 406 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 404 def on_top_const_field(field) field end |
#on_top_const_ref(const) ⇒ Object
408 409 410 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 408 def on_top_const_ref(const) const end |
#on_tstring_content(token) ⇒ Object
412 413 414 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 412 def on_tstring_content(token) token end |
#on_unary(operator, operand) ⇒ Object
416 417 418 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 416 def on_unary(operator, operand) Ruby::Unary.new(operator, operand) end |
#on_undef(args) ⇒ Object
420 421 422 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 420 def on_undef(args) Ruby::Call.new(nil, ident(:undef), Ruby::Args.new(args.collect { |e| to_ident(e) })) end |
#on_unless(expression, statements, else_block) ⇒ Object
424 425 426 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 424 def on_unless(expression, statements, else_block) Ruby::Unless.new(expression, statements, else_block) end |
#on_unless_mod(expression, statement) ⇒ Object
428 429 430 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 428 def on_unless_mod(expression, statement) Ruby::UnlessMod.new(expression, statement) end |
#on_until(expression, statements) ⇒ Object
432 433 434 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 432 def on_until(expression, statements) Ruby::Until.new(expression, statements) end |
#on_until_mod(expression, statement) ⇒ Object
436 437 438 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 436 def on_until_mod(expression, statement) Ruby::UntilMod.new(expression, statement) end |
#on_var_alias(new_name, old_name) ⇒ Object
440 441 442 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 440 def on_var_alias(new_name, old_name) Ruby::Alias.new(to_ident(new_name), to_ident(old_name)) end |
#on_var_field(field) ⇒ Object
444 445 446 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 444 def on_var_field(field) field end |
#on_var_ref(ref) ⇒ Object
448 449 450 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 448 def on_var_ref(ref) ref end |
#on_void_stmt ⇒ Object
452 453 454 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 452 def on_void_stmt nil end |
#on_when(expression, statements, next_block) ⇒ Object
456 457 458 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 456 def on_when(expression, statements, next_block) Ruby::When.new(expression, statements, next_block) end |
#on_while(expression, statements) ⇒ Object
460 461 462 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 460 def on_while(expression, statements) Ruby::While.new(expression, statements) end |
#on_while_mod(expression, statement) ⇒ Object
464 465 466 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 464 def on_while_mod(expression, statement) Ruby::WhileMod.new(expression, statement) end |
#on_word_add(string, word) ⇒ Object
468 469 470 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 468 def on_word_add(string, word) string.add(word); string end |
#on_word_new ⇒ Object
476 477 478 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 476 def on_word_new Ruby::String.new end |
#on_words_add(array, word) ⇒ Object
472 473 474 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 472 def on_words_add(array, word) array.add(word); array end |
#on_words_new ⇒ Object
480 481 482 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 480 def on_words_new Ruby::Array.new end |
#on_xstring_add(string, content) ⇒ Object
484 485 486 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 484 def on_xstring_add(string, content) on_string_add(string, content) end |
#on_xstring_literal(string) ⇒ Object
492 493 494 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 492 def on_xstring_literal(string) string end |
#on_xstring_new ⇒ Object
488 489 490 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 488 def on_xstring_new Ruby::ExecutableString.new end |
#on_yield(args) ⇒ Object
496 497 498 |
# File 'lib/rubycop/analyzer/node_builder.rb', line 496 def on_yield(args) Ruby::Call.new(nil, ident(:yield), args) end |