Class: SyntaxTree::Visitor::PrettyPrintVisitor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SyntaxTree::Visitor

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

Constructor Details

#initialize(q) ⇒ PrettyPrintVisitor

Returns a new instance of PrettyPrintVisitor.



8
9
10
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 8

def initialize(q)
  @q = q
end

Instance Attribute Details

#qObject (readonly)

Returns the value of attribute q.



6
7
8
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 6

def q
  @q
end

Instance Method Details

#visit___end__(node) ⇒ Object



1161
1162
1163
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1161

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

#visit_alias(node) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 28

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

#visit_aref(node) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 12

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

#visit_aref_field(node) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 20

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

#visit_arg_block(node) ⇒ Object



36
37
38
39
40
41
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 36

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

#visit_arg_paren(node) ⇒ Object



43
44
45
46
47
48
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 43

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

#visit_arg_star(node) ⇒ Object



50
51
52
53
54
55
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 50

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

#visit_args(node) ⇒ Object



57
58
59
60
61
62
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 57

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

#visit_args_forward(node) ⇒ Object



64
65
66
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 64

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

#visit_array(node) ⇒ Object



68
69
70
71
72
73
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 68

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

#visit_aryptn(node) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 75

def visit_aryptn(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



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

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

#visit_assoc(node) ⇒ Object



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

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

#visit_assoc_splat(node) ⇒ Object



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

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

#visit_backref(node) ⇒ Object



108
109
110
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 108

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

#visit_backtick(node) ⇒ Object



112
113
114
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 112

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

#visit_bare_assoc_hash(node) ⇒ Object



116
117
118
119
120
121
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 116

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

#visit_begin(node) ⇒ Object



130
131
132
133
134
135
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 130

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

#visit_BEGIN(node) ⇒ Object



123
124
125
126
127
128
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 123

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

#visit_binary(node) ⇒ Object



137
138
139
140
141
142
143
144
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 137

def visit_binary(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



153
154
155
156
157
158
159
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 153

def visit_block_var(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



146
147
148
149
150
151
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 146

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

#visit_bodystmt(node) ⇒ Object



161
162
163
164
165
166
167
168
169
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 161

def visit_bodystmt(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



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

def visit_brace_block(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



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

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

#visit_call(node) ⇒ Object



186
187
188
189
190
191
192
193
194
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 186

def visit_call(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



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

def visit_case(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



205
206
207
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 205

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

#visit_class(node) ⇒ Object



209
210
211
212
213
214
215
216
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 209

def visit_class(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



218
219
220
221
222
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 218

def visit_comma(node)
  node("comma") do
    field("value", node)
  end
end

#visit_command(node) ⇒ Object



224
225
226
227
228
229
230
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 224

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

#visit_command_call(node) ⇒ Object



232
233
234
235
236
237
238
239
240
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 232

def visit_command_call(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



242
243
244
245
246
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 242

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

#visit_const(node) ⇒ Object



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

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

#visit_const_path_field(node) ⇒ Object



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

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

#visit_const_path_ref(node) ⇒ Object



260
261
262
263
264
265
266
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 260

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

#visit_const_ref(node) ⇒ Object



268
269
270
271
272
273
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 268

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

#visit_cvar(node) ⇒ Object



275
276
277
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 275

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

#visit_def(node) ⇒ Object



279
280
281
282
283
284
285
286
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 279

def visit_def(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



288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 288

def visit_def_endless(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



302
303
304
305
306
307
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 302

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

#visit_defs(node) ⇒ Object



309
310
311
312
313
314
315
316
317
318
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 309

def visit_defs(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



320
321
322
323
324
325
326
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 320

def visit_do_block(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



328
329
330
331
332
333
334
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 328

def visit_dot2(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



336
337
338
339
340
341
342
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 336

def visit_dot3(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



344
345
346
347
348
349
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 344

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

#visit_else(node) ⇒ Object



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

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

#visit_elsif(node) ⇒ Object



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

def visit_elsif(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



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

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

#visit_embexpr_beg(node) ⇒ Object



380
381
382
383
384
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 380

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

#visit_embexpr_end(node) ⇒ Object



386
387
388
389
390
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 386

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

#visit_embvar(node) ⇒ Object



392
393
394
395
396
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 392

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

#visit_END(node) ⇒ Object



351
352
353
354
355
356
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 351

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

#visit_ensure(node) ⇒ Object



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

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

#visit_excessed_comma(node) ⇒ Object



405
406
407
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 405

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

#visit_fcall(node) ⇒ Object



409
410
411
412
413
414
415
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 409

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

#visit_field(node) ⇒ Object



417
418
419
420
421
422
423
424
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 417

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

#visit_float(node) ⇒ Object



426
427
428
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 426

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

#visit_fndptn(node) ⇒ Object



430
431
432
433
434
435
436
437
438
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 430

def visit_fndptn(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



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

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

#visit_gvar(node) ⇒ Object



449
450
451
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 449

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

#visit_hash(node) ⇒ Object



453
454
455
456
457
458
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 453

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

#visit_heredoc(node) ⇒ Object



460
461
462
463
464
465
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 460

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

#visit_heredoc_beg(node) ⇒ Object



467
468
469
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 467

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

#visit_hshptn(node) ⇒ Object



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 471

def visit_hshptn(node)
  node("hshptn") do
    field("constant", node.constant) if node.constant

    if node.keywords.any?
      q.breakable
      q.group(2, "(", ")") do
        q.seplist(node.keywords) do |(key, value)|
          q.group(2, "(", ")") do
            key.pretty_print(q)

            if value
              q.breakable
              value.pretty_print(q)
            end
          end
        end
      end
    end

    field("keyword_rest", node.keyword_rest) if node.keyword_rest
    comments(node)
  end
end

#visit_ident(node) ⇒ Object



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

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

#visit_if(node) ⇒ Object



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

def visit_if(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



509
510
511
512
513
514
515
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 509

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

#visit_if_op(node) ⇒ Object



517
518
519
520
521
522
523
524
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 517

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

#visit_imaginary(node) ⇒ Object



526
527
528
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 526

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

#visit_in(node) ⇒ Object



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

def visit_in(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



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

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

#visit_ivar(node) ⇒ Object



543
544
545
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 543

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

#visit_kw(node) ⇒ Object



547
548
549
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 547

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

#visit_kwrest_param(node) ⇒ Object



551
552
553
554
555
556
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 551

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

#visit_label(node) ⇒ Object



558
559
560
561
562
563
564
565
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 558

def visit_label(node)
  node("label") do
    q.breakable
    q.text(":")
    q.text(node.value[0...-1])
    comments(node)
  end
end

#visit_label_end(node) ⇒ Object



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

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

#visit_lambda(node) ⇒ Object



573
574
575
576
577
578
579
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 573

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

#visit_lbrace(node) ⇒ Object



581
582
583
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 581

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

#visit_lbracket(node) ⇒ Object



585
586
587
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 585

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

#visit_lparen(node) ⇒ Object



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

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

#visit_massign(node) ⇒ Object



593
594
595
596
597
598
599
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 593

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

#visit_method_add_block(node) ⇒ Object



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

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

#visit_mlhs(node) ⇒ Object



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

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

#visit_mlhs_paren(node) ⇒ Object



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

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

#visit_module(node) ⇒ Object



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

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

#visit_mrhs(node) ⇒ Object



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

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

#visit_next(node) ⇒ Object



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

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

#visit_not(node) ⇒ Object



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

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

#visit_op(node) ⇒ Object



652
653
654
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 652

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

#visit_opassign(node) ⇒ Object



656
657
658
659
660
661
662
663
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 656

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

#visit_params(node) ⇒ Object



665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 665

def visit_params(node)
  node("params") do
    list("requireds", node.requireds) if node.requireds.any?

    if node.optionals.any?
      q.breakable
      q.group(2, "(", ")") do
        q.seplist(node.optionals) do |(name, default)|
          name.pretty_print(q)
          q.text("=")
          q.group(2) do
            q.breakable("")
            default.pretty_print(q)
          end
        end
      end
    end

    field("rest", node.rest) if node.rest
    list("posts", node.posts) if node.posts.any?
    
    if node.keywords.any?
      q.breakable
      q.group(2, "(", ")") do
        q.seplist(node.keywords) do |(name, default)|
          name.pretty_print(q)

          if default
            q.text("=")
            q.group(2) do
              q.breakable("")
              default.pretty_print(q)
            end
          end
        end
      end
    end

    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



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

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

#visit_period(node) ⇒ Object



716
717
718
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 716

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

#visit_pinned_begin(node) ⇒ Object



720
721
722
723
724
725
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 720

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

#visit_pinned_var_ref(node) ⇒ Object



727
728
729
730
731
732
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 727

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

#visit_program(node) ⇒ Object



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

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

#visit_qsymbols(node) ⇒ Object



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

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

#visit_qsymbols_beg(node) ⇒ Object



748
749
750
751
752
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 748

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

#visit_qwords(node) ⇒ Object



754
755
756
757
758
759
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 754

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

#visit_qwords_beg(node) ⇒ Object



761
762
763
764
765
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 761

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

#visit_rassign(node) ⇒ Object



767
768
769
770
771
772
773
774
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 767

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

#visit_rational(node) ⇒ Object



776
777
778
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 776

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

#visit_rbrace(node) ⇒ Object



780
781
782
783
784
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 780

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

#visit_rbracket(node) ⇒ Object



786
787
788
789
790
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 786

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

#visit_redo(node) ⇒ Object



792
793
794
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 792

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

#visit_regexp_beg(node) ⇒ Object



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

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

#visit_regexp_content(node) ⇒ Object



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

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

#visit_regexp_end(node) ⇒ Object



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

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

#visit_regexp_literal(node) ⇒ Object



814
815
816
817
818
819
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 814

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

#visit_rescue(node) ⇒ Object



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

def visit_rescue(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



830
831
832
833
834
835
836
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 830

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

#visit_rescue_mod(node) ⇒ Object



838
839
840
841
842
843
844
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 838

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

#visit_rest_param(node) ⇒ Object



846
847
848
849
850
851
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 846

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

#visit_retry(node) ⇒ Object



853
854
855
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 853

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

#visit_return(node) ⇒ Object



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

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

#visit_return0(node) ⇒ Object



864
865
866
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 864

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

#visit_rparen(node) ⇒ Object



868
869
870
871
872
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 868

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

#visit_sclass(node) ⇒ Object



874
875
876
877
878
879
880
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 874

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

#visit_statements(node) ⇒ Object



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

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

#visit_string_concat(node) ⇒ Object



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

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

#visit_string_content(node) ⇒ Object



897
898
899
900
901
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 897

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

#visit_string_dvar(node) ⇒ Object



903
904
905
906
907
908
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 903

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

#visit_string_embexpr(node) ⇒ Object



910
911
912
913
914
915
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 910

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

#visit_string_literal(node) ⇒ Object



917
918
919
920
921
922
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 917

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

#visit_super(node) ⇒ Object



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

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

#visit_symbeg(node) ⇒ Object



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

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

#visit_symbol_content(node) ⇒ Object



937
938
939
940
941
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 937

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

#visit_symbol_literal(node) ⇒ Object



943
944
945
946
947
948
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 943

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

#visit_symbols(node) ⇒ Object



950
951
952
953
954
955
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 950

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

#visit_symbols_beg(node) ⇒ Object



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

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

#visit_tlambda(node) ⇒ Object



963
964
965
966
967
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 963

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

#visit_tlambeg(node) ⇒ Object



969
970
971
972
973
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 969

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

#visit_top_const_field(node) ⇒ Object



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

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

#visit_top_const_ref(node) ⇒ Object



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

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

#visit_tstring_beg(node) ⇒ Object



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

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

#visit_tstring_content(node) ⇒ Object



995
996
997
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 995

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

#visit_tstring_end(node) ⇒ Object



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

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

#visit_unary(node) ⇒ Object



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

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

#visit_undef(node) ⇒ Object



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

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

#visit_unless(node) ⇒ Object



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

def visit_unless(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



1029
1030
1031
1032
1033
1034
1035
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1029

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

#visit_until(node) ⇒ Object



1037
1038
1039
1040
1041
1042
1043
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1037

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

#visit_until_mod(node) ⇒ Object



1045
1046
1047
1048
1049
1050
1051
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1045

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

#visit_var_alias(node) ⇒ Object



1053
1054
1055
1056
1057
1058
1059
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1053

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

#visit_var_field(node) ⇒ Object



1061
1062
1063
1064
1065
1066
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1061

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

#visit_var_ref(node) ⇒ Object



1068
1069
1070
1071
1072
1073
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1068

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

#visit_vcall(node) ⇒ Object



1075
1076
1077
1078
1079
1080
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1075

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

#visit_void_stmt(node) ⇒ Object



1082
1083
1084
1085
1086
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1082

def visit_void_stmt(node)
  node("void_stmt") do
    comments(node)
  end
end

#visit_when(node) ⇒ Object



1088
1089
1090
1091
1092
1093
1094
1095
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1088

def visit_when(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



1097
1098
1099
1100
1101
1102
1103
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1097

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

#visit_while_mod(node) ⇒ Object



1105
1106
1107
1108
1109
1110
1111
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1105

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

#visit_word(node) ⇒ Object



1113
1114
1115
1116
1117
1118
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1113

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

#visit_words(node) ⇒ Object



1120
1121
1122
1123
1124
1125
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1120

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

#visit_words_beg(node) ⇒ Object



1127
1128
1129
1130
1131
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1127

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

#visit_xstring(node) ⇒ Object



1133
1134
1135
1136
1137
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1133

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

#visit_xstring_literal(node) ⇒ Object



1139
1140
1141
1142
1143
1144
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1139

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

#visit_yield(node) ⇒ Object



1146
1147
1148
1149
1150
1151
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1146

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

#visit_yield0(node) ⇒ Object



1153
1154
1155
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1153

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

#visit_zsuper(node) ⇒ Object



1157
1158
1159
# File 'lib/syntax_tree/visitor/pretty_print_visitor.rb', line 1157

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