Class: SyntaxTree::Visitor::FieldVisitor

Inherits:
SyntaxTree::Visitor show all
Defined in:
lib/syntax_tree/visitor/field_visitor.rb

Overview

This is the parent class of a lot of built-in visitors for Syntax Tree. It reflects visiting each of the fields on every node in turn. It itself does not do anything with these fields, it leaves that behavior up to the subclass to implement.

In order to properly use this class, you will need to subclass it and implement #comments, #field, #list, #node, #pairs, and #text. Those are documented here.

comments(node)

This accepts the node that is being visited and does something depending on the comments attached to the node.

field(name, value)

This accepts the name of the field being visited as a string (like “value”) and the actual value of that field. The value can be a subclass of Node or any other type that can be held within the tree.

list(name, values)

This accepts the name of the field being visited as well as a list of values. This is used, for example, when visiting something like the body of a Statements node.

node(name, node)

This is the parent serialization method for each node. It is called with the node itself, as well as the type of the node as a string. The type is an internally used value that usually resembles the name of the ripper event that generated the node. The method should yield to the given block which then calls through to visit each of the fields on the node.

text(name, value)

This accepts the name of the field being visited as well as a string value representing the value of the field.

pairs(name, values)

This accepts the name of the field being visited as well as a list of pairs that represent the value of the field. It is used only in a couple of circumstances, like when visiting the list of optional parameters defined on a method.

Direct Known Subclasses

JSONVisitor, MatchVisitor, PrettyPrintVisitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SyntaxTree::Visitor

#visit, #visit_all, #visit_child_nodes, visit_method, visit_methods

Instance Attribute Details

#qObject (readonly)

Returns the value of attribute q.



53
54
55
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 53

def q
  @q
end

Instance Method Details

#visit___end__(node) ⇒ Object



1101
1102
1103
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1101

def visit___end__(node)
  visit_token(node, "__end__")
end

#visit_alias(node) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 71

def visit_alias(node)
  node(node, "alias") do
    field("left", node.left)
    field("right", node.right)
    comments(node)
  end
end

#visit_aref(node) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 55

def visit_aref(node)
  node(node, "aref") do
    field("collection", node.collection)
    field("index", node.index)
    comments(node)
  end
end

#visit_aref_field(node) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 63

def visit_aref_field(node)
  node(node, "aref_field") do
    field("collection", node.collection)
    field("index", node.index)
    comments(node)
  end
end

#visit_arg_block(node) ⇒ Object



79
80
81
82
83
84
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 79

def visit_arg_block(node)
  node(node, "arg_block") do
    field("value", node.value) if node.value
    comments(node)
  end
end

#visit_arg_paren(node) ⇒ Object



86
87
88
89
90
91
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 86

def visit_arg_paren(node)
  node(node, "arg_paren") do
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_arg_star(node) ⇒ Object



93
94
95
96
97
98
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 93

def visit_arg_star(node)
  node(node, "arg_star") do
    field("value", node.value)
    comments(node)
  end
end

#visit_args(node) ⇒ Object



100
101
102
103
104
105
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 100

def visit_args(node)
  node(node, "args") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_args_forward(node) ⇒ Object



107
108
109
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 107

def visit_args_forward(node)
  visit_token(node, "args_forward")
end

#visit_array(node) ⇒ Object



111
112
113
114
115
116
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 111

def visit_array(node)
  node(node, "array") do
    field("contents", node.contents)
    comments(node)
  end
end

#visit_aryptn(node) ⇒ Object



118
119
120
121
122
123
124
125
126
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 118

def visit_aryptn(node)
  node(node, "aryptn") do
    field("constant", node.constant) if node.constant
    list("requireds", node.requireds) if node.requireds.any?
    field("rest", node.rest) if node.rest
    list("posts", node.posts) if node.posts.any?
    comments(node)
  end
end

#visit_assign(node) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 128

def visit_assign(node)
  node(node, "assign") do
    field("target", node.target)
    field("value", node.value)
    comments(node)
  end
end

#visit_assoc(node) ⇒ Object



136
137
138
139
140
141
142
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 136

def visit_assoc(node)
  node(node, "assoc") do
    field("key", node.key)
    field("value", node.value) if node.value
    comments(node)
  end
end

#visit_assoc_splat(node) ⇒ Object



144
145
146
147
148
149
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 144

def visit_assoc_splat(node)
  node(node, "assoc_splat") do
    field("value", node.value)
    comments(node)
  end
end

#visit_backref(node) ⇒ Object



151
152
153
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 151

def visit_backref(node)
  visit_token(node, "backref")
end

#visit_backtick(node) ⇒ Object



155
156
157
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 155

def visit_backtick(node)
  visit_token(node, "backtick")
end

#visit_bare_assoc_hash(node) ⇒ Object



159
160
161
162
163
164
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 159

def visit_bare_assoc_hash(node)
  node(node, "bare_assoc_hash") do
    list("assocs", node.assocs)
    comments(node)
  end
end

#visit_BEGIN(node) ⇒ Object



166
167
168
169
170
171
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 166

def visit_BEGIN(node)
  node(node, "BEGIN") do
    field("statements", node.statements)
    comments(node)
  end
end

#visit_begin(node) ⇒ Object



173
174
175
176
177
178
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 173

def visit_begin(node)
  node(node, "begin") do
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_binary(node) ⇒ Object



180
181
182
183
184
185
186
187
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 180

def visit_binary(node)
  node(node, "binary") do
    field("left", node.left)
    text("operator", node.operator)
    field("right", node.right)
    comments(node)
  end
end

#visit_block_var(node) ⇒ Object



196
197
198
199
200
201
202
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 196

def visit_block_var(node)
  node(node, "block_var") do
    field("params", node.params)
    list("locals", node.locals) if node.locals.any?
    comments(node)
  end
end

#visit_blockarg(node) ⇒ Object



189
190
191
192
193
194
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 189

def visit_blockarg(node)
  node(node, "blockarg") do
    field("name", node.name) if node.name
    comments(node)
  end
end

#visit_bodystmt(node) ⇒ Object



204
205
206
207
208
209
210
211
212
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 204

def visit_bodystmt(node)
  node(node, "bodystmt") do
    field("statements", node.statements)
    field("rescue_clause", node.rescue_clause) if node.rescue_clause
    field("else_clause", node.else_clause) if node.else_clause
    field("ensure_clause", node.ensure_clause) if node.ensure_clause
    comments(node)
  end
end

#visit_brace_block(node) ⇒ Object



214
215
216
217
218
219
220
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 214

def visit_brace_block(node)
  node(node, "brace_block") do
    field("block_var", node.block_var) if node.block_var
    field("statements", node.statements)
    comments(node)
  end
end

#visit_break(node) ⇒ Object



222
223
224
225
226
227
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 222

def visit_break(node)
  node(node, "break") do
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_call(node) ⇒ Object



229
230
231
232
233
234
235
236
237
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 229

def visit_call(node)
  node(node, "call") do
    field("receiver", node.receiver)
    field("operator", node.operator)
    field("message", node.message)
    field("arguments", node.arguments) if node.arguments
    comments(node)
  end
end

#visit_case(node) ⇒ Object



239
240
241
242
243
244
245
246
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 239

def visit_case(node)
  node(node, "case") do
    field("keyword", node.keyword)
    field("value", node.value) if node.value
    field("consequent", node.consequent)
    comments(node)
  end
end

#visit_CHAR(node) ⇒ Object



248
249
250
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 248

def visit_CHAR(node)
  visit_token(node, "CHAR")
end

#visit_class(node) ⇒ Object



252
253
254
255
256
257
258
259
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 252

def visit_class(node)
  node(node, "class") do
    field("constant", node.constant)
    field("superclass", node.superclass) if node.superclass
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_comma(node) ⇒ Object



261
262
263
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 261

def visit_comma(node)
  node(node, "comma") { field("value", node.value) }
end

#visit_command(node) ⇒ Object



265
266
267
268
269
270
271
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 265

def visit_command(node)
  node(node, "command") do
    field("message", node.message)
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_command_call(node) ⇒ Object



273
274
275
276
277
278
279
280
281
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 273

def visit_command_call(node)
  node(node, "command_call") do
    field("receiver", node.receiver)
    field("operator", node.operator)
    field("message", node.message)
    field("arguments", node.arguments) if node.arguments
    comments(node)
  end
end

#visit_comment(node) ⇒ Object



283
284
285
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 283

def visit_comment(node)
  node(node, "comment") { field("value", node.value) }
end

#visit_const(node) ⇒ Object



287
288
289
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 287

def visit_const(node)
  visit_token(node, "const")
end

#visit_const_path_field(node) ⇒ Object



291
292
293
294
295
296
297
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 291

def visit_const_path_field(node)
  node(node, "const_path_field") do
    field("parent", node.parent)
    field("constant", node.constant)
    comments(node)
  end
end

#visit_const_path_ref(node) ⇒ Object



299
300
301
302
303
304
305
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 299

def visit_const_path_ref(node)
  node(node, "const_path_ref") do
    field("parent", node.parent)
    field("constant", node.constant)
    comments(node)
  end
end

#visit_const_ref(node) ⇒ Object



307
308
309
310
311
312
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 307

def visit_const_ref(node)
  node(node, "const_ref") do
    field("constant", node.constant)
    comments(node)
  end
end

#visit_cvar(node) ⇒ Object



314
315
316
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 314

def visit_cvar(node)
  visit_token(node, "cvar")
end

#visit_def(node) ⇒ Object



318
319
320
321
322
323
324
325
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 318

def visit_def(node)
  node(node, "def") do
    field("name", node.name)
    field("params", node.params)
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_def_endless(node) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 327

def visit_def_endless(node)
  node(node, "def_endless") do
    if node.target
      field("target", node.target)
      field("operator", node.operator)
    end

    field("name", node.name)
    field("paren", node.paren) if node.paren
    field("statement", node.statement)
    comments(node)
  end
end

#visit_defined(node) ⇒ Object



341
342
343
344
345
346
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 341

def visit_defined(node)
  node(node, "defined") do
    field("value", node.value)
    comments(node)
  end
end

#visit_defs(node) ⇒ Object



348
349
350
351
352
353
354
355
356
357
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 348

def visit_defs(node)
  node(node, "defs") do
    field("target", node.target)
    field("operator", node.operator)
    field("name", node.name)
    field("params", node.params)
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_do_block(node) ⇒ Object



359
360
361
362
363
364
365
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 359

def visit_do_block(node)
  node(node, "do_block") do
    field("block_var", node.block_var) if node.block_var
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_dot2(node) ⇒ Object



367
368
369
370
371
372
373
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 367

def visit_dot2(node)
  node(node, "dot2") do
    field("left", node.left) if node.left
    field("right", node.right) if node.right
    comments(node)
  end
end

#visit_dot3(node) ⇒ Object



375
376
377
378
379
380
381
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 375

def visit_dot3(node)
  node(node, "dot3") do
    field("left", node.left) if node.left
    field("right", node.right) if node.right
    comments(node)
  end
end

#visit_dyna_symbol(node) ⇒ Object



383
384
385
386
387
388
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 383

def visit_dyna_symbol(node)
  node(node, "dyna_symbol") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_else(node) ⇒ Object



397
398
399
400
401
402
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 397

def visit_else(node)
  node(node, "else") do
    field("statements", node.statements)
    comments(node)
  end
end

#visit_elsif(node) ⇒ Object



404
405
406
407
408
409
410
411
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 404

def visit_elsif(node)
  node(node, "elsif") do
    field("predicate", node.predicate)
    field("statements", node.statements)
    field("consequent", node.consequent) if node.consequent
    comments(node)
  end
end

#visit_embdoc(node) ⇒ Object



413
414
415
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 413

def visit_embdoc(node)
  node(node, "embdoc") { field("value", node.value) }
end

#visit_embexpr_beg(node) ⇒ Object



417
418
419
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 417

def visit_embexpr_beg(node)
  node(node, "embexpr_beg") { field("value", node.value) }
end

#visit_embexpr_end(node) ⇒ Object



421
422
423
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 421

def visit_embexpr_end(node)
  node(node, "embexpr_end") { field("value", node.value) }
end

#visit_embvar(node) ⇒ Object



425
426
427
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 425

def visit_embvar(node)
  node(node, "embvar") { field("value", node.value) }
end

#visit_END(node) ⇒ Object



390
391
392
393
394
395
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 390

def visit_END(node)
  node(node, "END") do
    field("statements", node.statements)
    comments(node)
  end
end

#visit_ensure(node) ⇒ Object



429
430
431
432
433
434
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 429

def visit_ensure(node)
  node(node, "ensure") do
    field("statements", node.statements)
    comments(node)
  end
end

#visit_excessed_comma(node) ⇒ Object



436
437
438
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 436

def visit_excessed_comma(node)
  visit_token(node, "excessed_comma")
end

#visit_fcall(node) ⇒ Object



440
441
442
443
444
445
446
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 440

def visit_fcall(node)
  node(node, "fcall") do
    field("value", node.value)
    field("arguments", node.arguments) if node.arguments
    comments(node)
  end
end

#visit_field(node) ⇒ Object



448
449
450
451
452
453
454
455
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 448

def visit_field(node)
  node(node, "field") do
    field("parent", node.parent)
    field("operator", node.operator)
    field("name", node.name)
    comments(node)
  end
end

#visit_float(node) ⇒ Object



457
458
459
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 457

def visit_float(node)
  visit_token(node, "float")
end

#visit_fndptn(node) ⇒ Object



461
462
463
464
465
466
467
468
469
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 461

def visit_fndptn(node)
  node(node, "fndptn") do
    field("constant", node.constant) if node.constant
    field("left", node.left)
    list("values", node.values)
    field("right", node.right)
    comments(node)
  end
end

#visit_for(node) ⇒ Object



471
472
473
474
475
476
477
478
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 471

def visit_for(node)
  node(node, "for") do
    field("index", node.index)
    field("collection", node.collection)
    field("statements", node.statements)
    comments(node)
  end
end

#visit_gvar(node) ⇒ Object



480
481
482
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 480

def visit_gvar(node)
  visit_token(node, "gvar")
end

#visit_hash(node) ⇒ Object



484
485
486
487
488
489
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 484

def visit_hash(node)
  node(node, "hash") do
    list("assocs", node.assocs) if node.assocs.any?
    comments(node)
  end
end

#visit_heredoc(node) ⇒ Object



491
492
493
494
495
496
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 491

def visit_heredoc(node)
  node(node, "heredoc") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_heredoc_beg(node) ⇒ Object



498
499
500
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 498

def visit_heredoc_beg(node)
  visit_token(node, "heredoc_beg")
end

#visit_hshptn(node) ⇒ Object



502
503
504
505
506
507
508
509
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 502

def visit_hshptn(node)
  node(node, "hshptn") do
    field("constant", node.constant) if node.constant
    pairs("keywords", node.keywords) if node.keywords.any?
    field("keyword_rest", node.keyword_rest) if node.keyword_rest
    comments(node)
  end
end

#visit_ident(node) ⇒ Object



511
512
513
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 511

def visit_ident(node)
  visit_token(node, "ident")
end

#visit_if(node) ⇒ Object



515
516
517
518
519
520
521
522
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 515

def visit_if(node)
  node(node, "if") do
    field("predicate", node.predicate)
    field("statements", node.statements)
    field("consequent", node.consequent) if node.consequent
    comments(node)
  end
end

#visit_if_mod(node) ⇒ Object



524
525
526
527
528
529
530
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 524

def visit_if_mod(node)
  node(node, "if_mod") do
    field("statement", node.statement)
    field("predicate", node.predicate)
    comments(node)
  end
end

#visit_if_op(node) ⇒ Object



532
533
534
535
536
537
538
539
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 532

def visit_if_op(node)
  node(node, "if_op") do
    field("predicate", node.predicate)
    field("truthy", node.truthy)
    field("falsy", node.falsy)
    comments(node)
  end
end

#visit_imaginary(node) ⇒ Object



541
542
543
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 541

def visit_imaginary(node)
  visit_token(node, "imaginary")
end

#visit_in(node) ⇒ Object



545
546
547
548
549
550
551
552
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 545

def visit_in(node)
  node(node, "in") do
    field("pattern", node.pattern)
    field("statements", node.statements)
    field("consequent", node.consequent) if node.consequent
    comments(node)
  end
end

#visit_int(node) ⇒ Object



554
555
556
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 554

def visit_int(node)
  visit_token(node, "int")
end

#visit_ivar(node) ⇒ Object



558
559
560
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 558

def visit_ivar(node)
  visit_token(node, "ivar")
end

#visit_kw(node) ⇒ Object



562
563
564
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 562

def visit_kw(node)
  visit_token(node, "kw")
end

#visit_kwrest_param(node) ⇒ Object



566
567
568
569
570
571
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 566

def visit_kwrest_param(node)
  node(node, "kwrest_param") do
    field("name", node.name)
    comments(node)
  end
end

#visit_label(node) ⇒ Object



573
574
575
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 573

def visit_label(node)
  visit_token(node, "label")
end

#visit_label_end(node) ⇒ Object



577
578
579
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 577

def visit_label_end(node)
  node(node, "label_end") { field("value", node.value) }
end

#visit_lambda(node) ⇒ Object



581
582
583
584
585
586
587
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 581

def visit_lambda(node)
  node(node, "lambda") do
    field("params", node.params)
    field("statements", node.statements)
    comments(node)
  end
end

#visit_lbrace(node) ⇒ Object



589
590
591
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 589

def visit_lbrace(node)
  visit_token(node, "lbrace")
end

#visit_lbracket(node) ⇒ Object



593
594
595
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 593

def visit_lbracket(node)
  visit_token(node, "lbracket")
end

#visit_lparen(node) ⇒ Object



597
598
599
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 597

def visit_lparen(node)
  visit_token(node, "lparen")
end

#visit_massign(node) ⇒ Object



601
602
603
604
605
606
607
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 601

def visit_massign(node)
  node(node, "massign") do
    field("target", node.target)
    field("value", node.value)
    comments(node)
  end
end

#visit_method_add_block(node) ⇒ Object



609
610
611
612
613
614
615
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 609

def visit_method_add_block(node)
  node(node, "method_add_block") do
    field("call", node.call)
    field("block", node.block)
    comments(node)
  end
end

#visit_mlhs(node) ⇒ Object



617
618
619
620
621
622
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 617

def visit_mlhs(node)
  node(node, "mlhs") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_mlhs_paren(node) ⇒ Object



624
625
626
627
628
629
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 624

def visit_mlhs_paren(node)
  node(node, "mlhs_paren") do
    field("contents", node.contents)
    comments(node)
  end
end

#visit_module(node) ⇒ Object



631
632
633
634
635
636
637
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 631

def visit_module(node)
  node(node, "module") do
    field("constant", node.constant)
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_mrhs(node) ⇒ Object



639
640
641
642
643
644
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 639

def visit_mrhs(node)
  node(node, "mrhs") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_next(node) ⇒ Object



646
647
648
649
650
651
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 646

def visit_next(node)
  node(node, "next") do
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_not(node) ⇒ Object



653
654
655
656
657
658
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 653

def visit_not(node)
  node(node, "not") do
    field("statement", node.statement)
    comments(node)
  end
end

#visit_op(node) ⇒ Object



660
661
662
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 660

def visit_op(node)
  visit_token(node, "op")
end

#visit_opassign(node) ⇒ Object



664
665
666
667
668
669
670
671
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 664

def visit_opassign(node)
  node(node, "opassign") do
    field("target", node.target)
    field("operator", node.operator)
    field("value", node.value)
    comments(node)
  end
end

#visit_params(node) ⇒ Object



673
674
675
676
677
678
679
680
681
682
683
684
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 673

def visit_params(node)
  node(node, "params") do
    list("requireds", node.requireds) if node.requireds.any?
    pairs("optionals", node.optionals) if node.optionals.any?
    field("rest", node.rest) if node.rest
    list("posts", node.posts) if node.posts.any?
    pairs("keywords", node.keywords) if node.keywords.any?
    field("keyword_rest", node.keyword_rest) if node.keyword_rest
    field("block", node.block) if node.block
    comments(node)
  end
end

#visit_paren(node) ⇒ Object



686
687
688
689
690
691
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 686

def visit_paren(node)
  node(node, "paren") do
    field("contents", node.contents)
    comments(node)
  end
end

#visit_period(node) ⇒ Object



693
694
695
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 693

def visit_period(node)
  visit_token(node, "period")
end

#visit_pinned_begin(node) ⇒ Object



697
698
699
700
701
702
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 697

def visit_pinned_begin(node)
  node(node, "pinned_begin") do
    field("statement", node.statement)
    comments(node)
  end
end

#visit_pinned_var_ref(node) ⇒ Object



704
705
706
707
708
709
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 704

def visit_pinned_var_ref(node)
  node(node, "pinned_var_ref") do
    field("value", node.value)
    comments(node)
  end
end

#visit_program(node) ⇒ Object



711
712
713
714
715
716
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 711

def visit_program(node)
  node(node, "program") do
    field("statements", node.statements)
    comments(node)
  end
end

#visit_qsymbols(node) ⇒ Object



718
719
720
721
722
723
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 718

def visit_qsymbols(node)
  node(node, "qsymbols") do
    list("elements", node.elements)
    comments(node)
  end
end

#visit_qsymbols_beg(node) ⇒ Object



725
726
727
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 725

def visit_qsymbols_beg(node)
  node(node, "qsymbols_beg") { field("value", node.value) }
end

#visit_qwords(node) ⇒ Object



729
730
731
732
733
734
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 729

def visit_qwords(node)
  node(node, "qwords") do
    list("elements", node.elements)
    comments(node)
  end
end

#visit_qwords_beg(node) ⇒ Object



736
737
738
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 736

def visit_qwords_beg(node)
  node(node, "qwords_beg") { field("value", node.value) }
end

#visit_rassign(node) ⇒ Object



740
741
742
743
744
745
746
747
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 740

def visit_rassign(node)
  node(node, "rassign") do
    field("value", node.value)
    field("operator", node.operator)
    field("pattern", node.pattern)
    comments(node)
  end
end

#visit_rational(node) ⇒ Object



749
750
751
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 749

def visit_rational(node)
  visit_token(node, "rational")
end

#visit_rbrace(node) ⇒ Object



753
754
755
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 753

def visit_rbrace(node)
  node(node, "rbrace") { field("value", node.value) }
end

#visit_rbracket(node) ⇒ Object



757
758
759
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 757

def visit_rbracket(node)
  node(node, "rbracket") { field("value", node.value) }
end

#visit_redo(node) ⇒ Object



761
762
763
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 761

def visit_redo(node)
  visit_token(node, "redo")
end

#visit_regexp_beg(node) ⇒ Object



765
766
767
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 765

def visit_regexp_beg(node)
  node(node, "regexp_beg") { field("value", node.value) }
end

#visit_regexp_content(node) ⇒ Object



769
770
771
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 769

def visit_regexp_content(node)
  node(node, "regexp_content") { list("parts", node.parts) }
end

#visit_regexp_end(node) ⇒ Object



773
774
775
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 773

def visit_regexp_end(node)
  node(node, "regexp_end") { field("value", node.value) }
end

#visit_regexp_literal(node) ⇒ Object



777
778
779
780
781
782
783
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 777

def visit_regexp_literal(node)
  node(node, "regexp_literal") do
    list("parts", node.parts)
    field("options", node.options)
    comments(node)
  end
end

#visit_rescue(node) ⇒ Object



785
786
787
788
789
790
791
792
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 785

def visit_rescue(node)
  node(node, "rescue") do
    field("exception", node.exception) if node.exception
    field("statements", node.statements)
    field("consequent", node.consequent) if node.consequent
    comments(node)
  end
end

#visit_rescue_ex(node) ⇒ Object



794
795
796
797
798
799
800
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 794

def visit_rescue_ex(node)
  node(node, "rescue_ex") do
    field("exceptions", node.exceptions)
    field("variable", node.variable)
    comments(node)
  end
end

#visit_rescue_mod(node) ⇒ Object



802
803
804
805
806
807
808
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 802

def visit_rescue_mod(node)
  node(node, "rescue_mod") do
    field("statement", node.statement)
    field("value", node.value)
    comments(node)
  end
end

#visit_rest_param(node) ⇒ Object



810
811
812
813
814
815
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 810

def visit_rest_param(node)
  node(node, "rest_param") do
    field("name", node.name)
    comments(node)
  end
end

#visit_retry(node) ⇒ Object



817
818
819
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 817

def visit_retry(node)
  visit_token(node, "retry")
end

#visit_return(node) ⇒ Object



821
822
823
824
825
826
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 821

def visit_return(node)
  node(node, "return") do
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_return0(node) ⇒ Object



828
829
830
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 828

def visit_return0(node)
  visit_token(node, "return0")
end

#visit_rparen(node) ⇒ Object



832
833
834
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 832

def visit_rparen(node)
  node(node, "rparen") { field("value", node.value) }
end

#visit_sclass(node) ⇒ Object



836
837
838
839
840
841
842
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 836

def visit_sclass(node)
  node(node, "sclass") do
    field("target", node.target)
    field("bodystmt", node.bodystmt)
    comments(node)
  end
end

#visit_statements(node) ⇒ Object



844
845
846
847
848
849
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 844

def visit_statements(node)
  node(node, "statements") do
    list("body", node.body)
    comments(node)
  end
end

#visit_string_concat(node) ⇒ Object



851
852
853
854
855
856
857
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 851

def visit_string_concat(node)
  node(node, "string_concat") do
    field("left", node.left)
    field("right", node.right)
    comments(node)
  end
end

#visit_string_content(node) ⇒ Object



859
860
861
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 859

def visit_string_content(node)
  node(node, "string_content") { list("parts", node.parts) }
end

#visit_string_dvar(node) ⇒ Object



863
864
865
866
867
868
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 863

def visit_string_dvar(node)
  node(node, "string_dvar") do
    field("variable", node.variable)
    comments(node)
  end
end

#visit_string_embexpr(node) ⇒ Object



870
871
872
873
874
875
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 870

def visit_string_embexpr(node)
  node(node, "string_embexpr") do
    field("statements", node.statements)
    comments(node)
  end
end

#visit_string_literal(node) ⇒ Object



877
878
879
880
881
882
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 877

def visit_string_literal(node)
  node(node, "string_literal") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_super(node) ⇒ Object



884
885
886
887
888
889
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 884

def visit_super(node)
  node(node, "super") do
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_symbeg(node) ⇒ Object



891
892
893
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 891

def visit_symbeg(node)
  node(node, "symbeg") { field("value", node.value) }
end

#visit_symbol_content(node) ⇒ Object



895
896
897
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 895

def visit_symbol_content(node)
  node(node, "symbol_content") { field("value", node.value) }
end

#visit_symbol_literal(node) ⇒ Object



899
900
901
902
903
904
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 899

def visit_symbol_literal(node)
  node(node, "symbol_literal") do
    field("value", node.value)
    comments(node)
  end
end

#visit_symbols(node) ⇒ Object



906
907
908
909
910
911
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 906

def visit_symbols(node)
  node(node, "symbols") do
    list("elements", node.elements)
    comments(node)
  end
end

#visit_symbols_beg(node) ⇒ Object



913
914
915
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 913

def visit_symbols_beg(node)
  node(node, "symbols_beg") { field("value", node.value) }
end

#visit_tlambda(node) ⇒ Object



917
918
919
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 917

def visit_tlambda(node)
  node(node, "tlambda") { field("value", node.value) }
end

#visit_tlambeg(node) ⇒ Object



921
922
923
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 921

def visit_tlambeg(node)
  node(node, "tlambeg") { field("value", node.value) }
end

#visit_top_const_field(node) ⇒ Object



925
926
927
928
929
930
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 925

def visit_top_const_field(node)
  node(node, "top_const_field") do
    field("constant", node.constant)
    comments(node)
  end
end

#visit_top_const_ref(node) ⇒ Object



932
933
934
935
936
937
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 932

def visit_top_const_ref(node)
  node(node, "top_const_ref") do
    field("constant", node.constant)
    comments(node)
  end
end

#visit_tstring_beg(node) ⇒ Object



939
940
941
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 939

def visit_tstring_beg(node)
  node(node, "tstring_beg") { field("value", node.value) }
end

#visit_tstring_content(node) ⇒ Object



943
944
945
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 943

def visit_tstring_content(node)
  visit_token(node, "tstring_content")
end

#visit_tstring_end(node) ⇒ Object



947
948
949
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 947

def visit_tstring_end(node)
  node(node, "tstring_end") { field("value", node.value) }
end

#visit_unary(node) ⇒ Object



951
952
953
954
955
956
957
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 951

def visit_unary(node)
  node(node, "unary") do
    field("operator", node.operator)
    field("statement", node.statement)
    comments(node)
  end
end

#visit_undef(node) ⇒ Object



959
960
961
962
963
964
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 959

def visit_undef(node)
  node(node, "undef") do
    list("symbols", node.symbols)
    comments(node)
  end
end

#visit_unless(node) ⇒ Object



966
967
968
969
970
971
972
973
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 966

def visit_unless(node)
  node(node, "unless") do
    field("predicate", node.predicate)
    field("statements", node.statements)
    field("consequent", node.consequent) if node.consequent
    comments(node)
  end
end

#visit_unless_mod(node) ⇒ Object



975
976
977
978
979
980
981
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 975

def visit_unless_mod(node)
  node(node, "unless_mod") do
    field("statement", node.statement)
    field("predicate", node.predicate)
    comments(node)
  end
end

#visit_until(node) ⇒ Object



983
984
985
986
987
988
989
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 983

def visit_until(node)
  node(node, "until") do
    field("predicate", node.predicate)
    field("statements", node.statements)
    comments(node)
  end
end

#visit_until_mod(node) ⇒ Object



991
992
993
994
995
996
997
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 991

def visit_until_mod(node)
  node(node, "until_mod") do
    field("statement", node.statement)
    field("predicate", node.predicate)
    comments(node)
  end
end

#visit_var_alias(node) ⇒ Object



999
1000
1001
1002
1003
1004
1005
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 999

def visit_var_alias(node)
  node(node, "var_alias") do
    field("left", node.left)
    field("right", node.right)
    comments(node)
  end
end

#visit_var_field(node) ⇒ Object



1007
1008
1009
1010
1011
1012
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1007

def visit_var_field(node)
  node(node, "var_field") do
    field("value", node.value)
    comments(node)
  end
end

#visit_var_ref(node) ⇒ Object



1014
1015
1016
1017
1018
1019
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1014

def visit_var_ref(node)
  node(node, "var_ref") do
    field("value", node.value)
    comments(node)
  end
end

#visit_vcall(node) ⇒ Object



1021
1022
1023
1024
1025
1026
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1021

def visit_vcall(node)
  node(node, "vcall") do
    field("value", node.value)
    comments(node)
  end
end

#visit_void_stmt(node) ⇒ Object



1028
1029
1030
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1028

def visit_void_stmt(node)
  node(node, "void_stmt") { comments(node) }
end

#visit_when(node) ⇒ Object



1032
1033
1034
1035
1036
1037
1038
1039
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1032

def visit_when(node)
  node(node, "when") do
    field("arguments", node.arguments)
    field("statements", node.statements)
    field("consequent", node.consequent) if node.consequent
    comments(node)
  end
end

#visit_while(node) ⇒ Object



1041
1042
1043
1044
1045
1046
1047
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1041

def visit_while(node)
  node(node, "while") do
    field("predicate", node.predicate)
    field("statements", node.statements)
    comments(node)
  end
end

#visit_while_mod(node) ⇒ Object



1049
1050
1051
1052
1053
1054
1055
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1049

def visit_while_mod(node)
  node(node, "while_mod") do
    field("statement", node.statement)
    field("predicate", node.predicate)
    comments(node)
  end
end

#visit_word(node) ⇒ Object



1057
1058
1059
1060
1061
1062
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1057

def visit_word(node)
  node(node, "word") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_words(node) ⇒ Object



1064
1065
1066
1067
1068
1069
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1064

def visit_words(node)
  node(node, "words") do
    list("elements", node.elements)
    comments(node)
  end
end

#visit_words_beg(node) ⇒ Object



1071
1072
1073
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1071

def visit_words_beg(node)
  node(node, "words_beg") { field("value", node.value) }
end

#visit_xstring(node) ⇒ Object



1075
1076
1077
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1075

def visit_xstring(node)
  node(node, "xstring") { list("parts", node.parts) }
end

#visit_xstring_literal(node) ⇒ Object



1079
1080
1081
1082
1083
1084
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1079

def visit_xstring_literal(node)
  node(node, "xstring_literal") do
    list("parts", node.parts)
    comments(node)
  end
end

#visit_yield(node) ⇒ Object



1086
1087
1088
1089
1090
1091
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1086

def visit_yield(node)
  node(node, "yield") do
    field("arguments", node.arguments)
    comments(node)
  end
end

#visit_yield0(node) ⇒ Object



1093
1094
1095
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1093

def visit_yield0(node)
  visit_token(node, "yield0")
end

#visit_zsuper(node) ⇒ Object



1097
1098
1099
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1097

def visit_zsuper(node)
  visit_token(node, "zsuper")
end