Class: SyntaxTree::Visitor::FieldVisitor

Inherits:
BasicVisitor 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 Method Summary collapse

Methods inherited from BasicVisitor

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

Instance Method Details

#visit___end__(node) ⇒ Object



1107
1108
1109
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1107

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

#visit_alias(node) ⇒ Object



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

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

#visit_aref(node) ⇒ Object



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

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



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

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



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

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



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

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

#visit_arg_star(node) ⇒ Object



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

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

#visit_args(node) ⇒ Object



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

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

#visit_args_forward(node) ⇒ Object



105
106
107
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 105

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

#visit_array(node) ⇒ Object



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

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

#visit_aryptn(node) ⇒ Object



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

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



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

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

#visit_assoc(node) ⇒ Object



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

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



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

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

#visit_backref(node) ⇒ Object



149
150
151
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 149

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

#visit_backtick(node) ⇒ Object



153
154
155
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 153

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

#visit_bare_assoc_hash(node) ⇒ Object



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

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

#visit_BEGIN(node) ⇒ Object



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

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

#visit_begin(node) ⇒ Object



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

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

#visit_binary(node) ⇒ Object



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

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



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

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



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

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

#visit_bodystmt(node) ⇒ Object



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

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



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

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



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

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

#visit_call(node) ⇒ Object



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

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



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

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



246
247
248
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 246

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

#visit_class(node) ⇒ Object



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

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



259
260
261
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 259

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

#visit_command(node) ⇒ Object



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

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



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

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



281
282
283
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 281

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

#visit_const(node) ⇒ Object



285
286
287
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 285

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

#visit_const_path_field(node) ⇒ Object



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

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



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

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



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

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

#visit_cvar(node) ⇒ Object



312
313
314
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 312

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

#visit_def(node) ⇒ Object



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

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



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

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



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

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

#visit_defs(node) ⇒ Object



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

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



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

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



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

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



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

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



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

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

#visit_else(node) ⇒ Object



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

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

#visit_elsif(node) ⇒ Object



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

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



411
412
413
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 411

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

#visit_embexpr_beg(node) ⇒ Object



415
416
417
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 415

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

#visit_embexpr_end(node) ⇒ Object



419
420
421
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 419

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

#visit_embvar(node) ⇒ Object



423
424
425
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 423

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

#visit_END(node) ⇒ Object



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

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

#visit_ensure(node) ⇒ Object



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

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

#visit_excessed_comma(node) ⇒ Object



434
435
436
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 434

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

#visit_fcall(node) ⇒ Object



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

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



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

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



455
456
457
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 455

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

#visit_fndptn(node) ⇒ Object



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

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



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

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



478
479
480
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 478

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

#visit_hash(node) ⇒ Object



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

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

#visit_heredoc(node) ⇒ Object



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

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

#visit_heredoc_beg(node) ⇒ Object



496
497
498
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 496

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

#visit_hshptn(node) ⇒ Object



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

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



509
510
511
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 509

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

#visit_if(node) ⇒ Object



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

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



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

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



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

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



539
540
541
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 539

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

#visit_in(node) ⇒ Object



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

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



552
553
554
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 552

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

#visit_ivar(node) ⇒ Object



556
557
558
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 556

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

#visit_kw(node) ⇒ Object



560
561
562
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 560

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

#visit_kwrest_param(node) ⇒ Object



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

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

#visit_label(node) ⇒ Object



571
572
573
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 571

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

#visit_label_end(node) ⇒ Object



575
576
577
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 575

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

#visit_lambda(node) ⇒ Object



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

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

#visit_lambda_var(node) ⇒ Object



587
588
589
590
591
592
593
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 587

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

#visit_lbrace(node) ⇒ Object



595
596
597
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 595

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

#visit_lbracket(node) ⇒ Object



599
600
601
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 599

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

#visit_lparen(node) ⇒ Object



603
604
605
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 603

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

#visit_massign(node) ⇒ Object



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

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



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

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



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

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

#visit_mlhs_paren(node) ⇒ Object



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

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

#visit_module(node) ⇒ Object



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

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

#visit_mrhs(node) ⇒ Object



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

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

#visit_next(node) ⇒ Object



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

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

#visit_not(node) ⇒ Object



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

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

#visit_op(node) ⇒ Object



666
667
668
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 666

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

#visit_opassign(node) ⇒ Object



670
671
672
673
674
675
676
677
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 670

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



679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 679

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



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

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

#visit_period(node) ⇒ Object



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

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

#visit_pinned_begin(node) ⇒ Object



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

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

#visit_pinned_var_ref(node) ⇒ Object



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

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

#visit_program(node) ⇒ Object



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

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

#visit_qsymbols(node) ⇒ Object



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

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

#visit_qsymbols_beg(node) ⇒ Object



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

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

#visit_qwords(node) ⇒ Object



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

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

#visit_qwords_beg(node) ⇒ Object



742
743
744
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 742

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

#visit_rassign(node) ⇒ Object



746
747
748
749
750
751
752
753
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 746

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



755
756
757
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 755

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

#visit_rbrace(node) ⇒ Object



759
760
761
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 759

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

#visit_rbracket(node) ⇒ Object



763
764
765
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 763

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

#visit_redo(node) ⇒ Object



767
768
769
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 767

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

#visit_regexp_beg(node) ⇒ Object



771
772
773
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 771

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

#visit_regexp_content(node) ⇒ Object



775
776
777
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 775

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

#visit_regexp_end(node) ⇒ Object



779
780
781
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 779

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

#visit_regexp_literal(node) ⇒ Object



783
784
785
786
787
788
789
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 783

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



791
792
793
794
795
796
797
798
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 791

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



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

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



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

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



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

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

#visit_retry(node) ⇒ Object



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

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

#visit_return(node) ⇒ Object



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

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

#visit_return0(node) ⇒ Object



834
835
836
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 834

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

#visit_rparen(node) ⇒ Object



838
839
840
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 838

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

#visit_sclass(node) ⇒ Object



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

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

#visit_statements(node) ⇒ Object



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

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

#visit_string_concat(node) ⇒ Object



857
858
859
860
861
862
863
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 857

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



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

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

#visit_string_dvar(node) ⇒ Object



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

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

#visit_string_embexpr(node) ⇒ Object



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

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

#visit_string_literal(node) ⇒ Object



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

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

#visit_super(node) ⇒ Object



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

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

#visit_symbeg(node) ⇒ Object



897
898
899
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 897

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

#visit_symbol_content(node) ⇒ Object



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

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

#visit_symbol_literal(node) ⇒ Object



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

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

#visit_symbols(node) ⇒ Object



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

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

#visit_symbols_beg(node) ⇒ Object



919
920
921
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 919

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

#visit_tlambda(node) ⇒ Object



923
924
925
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 923

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

#visit_tlambeg(node) ⇒ Object



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

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

#visit_top_const_field(node) ⇒ Object



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

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



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

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



945
946
947
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 945

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

#visit_tstring_content(node) ⇒ Object



949
950
951
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 949

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

#visit_tstring_end(node) ⇒ Object



953
954
955
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 953

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

#visit_unary(node) ⇒ Object



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

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

#visit_undef(node) ⇒ Object



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

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

#visit_unless(node) ⇒ Object



972
973
974
975
976
977
978
979
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 972

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



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

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



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

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



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

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



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

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



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

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

#visit_var_ref(node) ⇒ Object



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

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

#visit_vcall(node) ⇒ Object



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

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

#visit_void_stmt(node) ⇒ Object



1034
1035
1036
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1034

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

#visit_when(node) ⇒ Object



1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1038

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



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

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



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

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



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

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

#visit_words(node) ⇒ Object



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

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

#visit_words_beg(node) ⇒ Object



1077
1078
1079
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1077

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

#visit_xstring(node) ⇒ Object



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

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

#visit_xstring_literal(node) ⇒ Object



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

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

#visit_yield(node) ⇒ Object



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

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

#visit_yield0(node) ⇒ Object



1099
1100
1101
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1099

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

#visit_zsuper(node) ⇒ Object



1103
1104
1105
# File 'lib/syntax_tree/visitor/field_visitor.rb', line 1103

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