Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
41175 views
1
/*
2
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.source.util;
27
28
import com.sun.source.tree.*;
29
30
/**
31
* A TreeVisitor that visits all the child tree nodes.
32
* To visit nodes of a particular type, just override the
33
* corresponding visitXYZ method.
34
* Inside your method, call super.visitXYZ to visit descendant
35
* nodes.
36
*
37
* <p>The default implementation of the visitXYZ methods will determine
38
* a result as follows:
39
* <ul>
40
* <li>If the node being visited has no children, the result will be {@code null}.
41
* <li>If the node being visited has one child, the result will be the
42
* result of calling {@code scan} with that child. The child may be a simple node
43
* or itself a list of nodes.
44
* <li>If the node being visited has more than one child, the result will
45
* be determined by calling {@code scan} with each child in turn, and then combining the
46
* result of each scan after the first with the cumulative result
47
* so far, as determined by the {@link #reduce} method. Each child may be either
48
* a simple node or a list of nodes. The default behavior of the {@code reduce}
49
* method is such that the result of the visitXYZ method will be the result of
50
* the last child scanned.
51
* </ul>
52
*
53
* <p>Here is an example to count the number of identifier nodes in a tree:
54
* <pre>
55
* class CountIdentifiers extends TreeScanner&lt;Integer,Void&gt; {
56
* {@literal @}Override
57
* public Integer visitIdentifier(IdentifierTree node, Void p) {
58
* return 1;
59
* }
60
* {@literal @}Override
61
* public Integer reduce(Integer r1, Integer r2) {
62
* return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2);
63
* }
64
* }
65
* </pre>
66
*
67
* @param <R> the return type of this visitor's methods. Use {@link
68
* Void} for visitors that do not need to return results.
69
* @param <P> the type of the additional parameter to this visitor's
70
* methods. Use {@code Void} for visitors that do not need an
71
* additional parameter.
72
*
73
* @author Peter von der Ah&eacute;
74
* @author Jonathan Gibbons
75
* @since 1.6
76
*/
77
public class TreeScanner<R,P> implements TreeVisitor<R,P> {
78
/**
79
* Constructs a {@code TreeScanner}.
80
*/
81
public TreeScanner() {}
82
83
/**
84
* Scans a single node.
85
* @param tree the node to be scanned
86
* @param p a parameter value passed to the visit method
87
* @return the result value from the visit method
88
*/
89
public R scan(Tree tree, P p) {
90
return (tree == null) ? null : tree.accept(this, p);
91
}
92
93
private R scanAndReduce(Tree node, P p, R r) {
94
return reduce(scan(node, p), r);
95
}
96
97
/**
98
* Scans a sequence of nodes.
99
* @param nodes the nodes to be scanned
100
* @param p a parameter value to be passed to the visit method for each node
101
* @return the combined return value from the visit methods.
102
* The values are combined using the {@link #reduce reduce} method.
103
*/
104
public R scan(Iterable<? extends Tree> nodes, P p) {
105
R r = null;
106
if (nodes != null) {
107
boolean first = true;
108
for (Tree node : nodes) {
109
r = (first ? scan(node, p) : scanAndReduce(node, p, r));
110
first = false;
111
}
112
}
113
return r;
114
}
115
116
private R scanAndReduce(Iterable<? extends Tree> nodes, P p, R r) {
117
return reduce(scan(nodes, p), r);
118
}
119
120
/**
121
* Reduces two results into a combined result.
122
* The default implementation is to return the first parameter.
123
* The general contract of the method is that it may take any action whatsoever.
124
* @param r1 the first of the values to be combined
125
* @param r2 the second of the values to be combined
126
* @return the result of combining the two parameters
127
*/
128
public R reduce(R r1, R r2) {
129
return r1;
130
}
131
132
133
/* ***************************************************************************
134
* Visitor methods
135
****************************************************************************/
136
137
/**
138
* {@inheritDoc} This implementation scans the children in left to right order.
139
*
140
* @param node {@inheritDoc}
141
* @param p {@inheritDoc}
142
* @return the result of scanning
143
*/
144
@Override
145
public R visitCompilationUnit(CompilationUnitTree node, P p) {
146
R r = scan(node.getPackage(), p);
147
r = scanAndReduce(node.getImports(), p, r);
148
r = scanAndReduce(node.getTypeDecls(), p, r);
149
r = scanAndReduce(node.getModule(), p, r);
150
return r;
151
}
152
153
/**
154
* {@inheritDoc} This implementation scans the children in left to right order.
155
*
156
* @param node {@inheritDoc}
157
* @param p {@inheritDoc}
158
* @return the result of scanning
159
*/
160
@Override
161
public R visitPackage(PackageTree node, P p) {
162
R r = scan(node.getAnnotations(), p);
163
r = scanAndReduce(node.getPackageName(), p, r);
164
return r;
165
}
166
167
/**
168
* {@inheritDoc} This implementation scans the children in left to right order.
169
*
170
* @param node {@inheritDoc}
171
* @param p {@inheritDoc}
172
* @return the result of scanning
173
*/
174
@Override
175
public R visitImport(ImportTree node, P p) {
176
return scan(node.getQualifiedIdentifier(), p);
177
}
178
179
/**
180
* {@inheritDoc} This implementation scans the children in left to right order.
181
*
182
* @param node {@inheritDoc}
183
* @param p {@inheritDoc}
184
* @return the result of scanning
185
*/
186
@SuppressWarnings("preview")
187
@Override
188
public R visitClass(ClassTree node, P p) {
189
R r = scan(node.getModifiers(), p);
190
r = scanAndReduce(node.getTypeParameters(), p, r);
191
r = scanAndReduce(node.getExtendsClause(), p, r);
192
r = scanAndReduce(node.getImplementsClause(), p, r);
193
r = scanAndReduce(node.getPermitsClause(), p, r);
194
r = scanAndReduce(node.getMembers(), p, r);
195
return r;
196
}
197
198
/**
199
* {@inheritDoc} This implementation scans the children in left to right order.
200
*
201
* @param node {@inheritDoc}
202
* @param p {@inheritDoc}
203
* @return the result of scanning
204
*/
205
@Override
206
public R visitMethod(MethodTree node, P p) {
207
R r = scan(node.getModifiers(), p);
208
r = scanAndReduce(node.getReturnType(), p, r);
209
r = scanAndReduce(node.getTypeParameters(), p, r);
210
r = scanAndReduce(node.getParameters(), p, r);
211
r = scanAndReduce(node.getReceiverParameter(), p, r);
212
r = scanAndReduce(node.getThrows(), p, r);
213
r = scanAndReduce(node.getBody(), p, r);
214
r = scanAndReduce(node.getDefaultValue(), p, r);
215
return r;
216
}
217
218
/**
219
* {@inheritDoc} This implementation scans the children in left to right order.
220
*
221
* @param node {@inheritDoc}
222
* @param p {@inheritDoc}
223
* @return the result of scanning
224
*/
225
@Override
226
public R visitVariable(VariableTree node, P p) {
227
R r = scan(node.getModifiers(), p);
228
r = scanAndReduce(node.getType(), p, r);
229
r = scanAndReduce(node.getNameExpression(), p, r);
230
r = scanAndReduce(node.getInitializer(), p, r);
231
return r;
232
}
233
234
/**
235
* {@inheritDoc} This implementation returns {@code null}.
236
*
237
* @param node {@inheritDoc}
238
* @param p {@inheritDoc}
239
* @return the result of scanning
240
*/
241
@Override
242
public R visitEmptyStatement(EmptyStatementTree node, P p) {
243
return null;
244
}
245
246
/**
247
* {@inheritDoc} This implementation scans the children in left to right order.
248
*
249
* @param node {@inheritDoc}
250
* @param p {@inheritDoc}
251
* @return the result of scanning
252
*/
253
@Override
254
public R visitBlock(BlockTree node, P p) {
255
return scan(node.getStatements(), p);
256
}
257
258
/**
259
* {@inheritDoc} This implementation scans the children in left to right order.
260
*
261
* @param node {@inheritDoc}
262
* @param p {@inheritDoc}
263
* @return the result of scanning
264
*/
265
@Override
266
public R visitDoWhileLoop(DoWhileLoopTree node, P p) {
267
R r = scan(node.getStatement(), p);
268
r = scanAndReduce(node.getCondition(), p, r);
269
return r;
270
}
271
272
/**
273
* {@inheritDoc} This implementation scans the children in left to right order.
274
*
275
* @param node {@inheritDoc}
276
* @param p {@inheritDoc}
277
* @return the result of scanning
278
*/
279
@Override
280
public R visitWhileLoop(WhileLoopTree node, P p) {
281
R r = scan(node.getCondition(), p);
282
r = scanAndReduce(node.getStatement(), p, r);
283
return r;
284
}
285
286
/**
287
* {@inheritDoc} This implementation scans the children in left to right order.
288
*
289
* @param node {@inheritDoc}
290
* @param p {@inheritDoc}
291
* @return the result of scanning
292
*/
293
@Override
294
public R visitForLoop(ForLoopTree node, P p) {
295
R r = scan(node.getInitializer(), p);
296
r = scanAndReduce(node.getCondition(), p, r);
297
r = scanAndReduce(node.getUpdate(), p, r);
298
r = scanAndReduce(node.getStatement(), p, r);
299
return r;
300
}
301
302
/**
303
* {@inheritDoc} This implementation scans the children in left to right order.
304
*
305
* @param node {@inheritDoc}
306
* @param p {@inheritDoc}
307
* @return the result of scanning
308
*/
309
@Override
310
public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
311
R r = scan(node.getVariable(), p);
312
r = scanAndReduce(node.getExpression(), p, r);
313
r = scanAndReduce(node.getStatement(), p, r);
314
return r;
315
}
316
317
/**
318
* {@inheritDoc} This implementation scans the children in left to right order.
319
*
320
* @param node {@inheritDoc}
321
* @param p {@inheritDoc}
322
* @return the result of scanning
323
*/
324
@Override
325
public R visitLabeledStatement(LabeledStatementTree node, P p) {
326
return scan(node.getStatement(), p);
327
}
328
329
/**
330
* {@inheritDoc} This implementation scans the children in left to right order.
331
*
332
* @param node {@inheritDoc}
333
* @param p {@inheritDoc}
334
* @return the result of scanning
335
*/
336
@Override
337
public R visitSwitch(SwitchTree node, P p) {
338
R r = scan(node.getExpression(), p);
339
r = scanAndReduce(node.getCases(), p, r);
340
return r;
341
}
342
343
/**
344
* {@inheritDoc} This implementation scans the children in left to right order.
345
*
346
* @param node {@inheritDoc}
347
* @param p {@inheritDoc}
348
* @return the result of scanning
349
*/
350
@Override
351
public R visitSwitchExpression(SwitchExpressionTree node, P p) {
352
R r = scan(node.getExpression(), p);
353
r = scanAndReduce(node.getCases(), p, r);
354
return r;
355
}
356
357
/**
358
* {@inheritDoc} This implementation scans the children in left to right order.
359
*
360
* @param node {@inheritDoc}
361
* @param p {@inheritDoc}
362
* @return the result of scanning
363
*/
364
@Override
365
public R visitCase(CaseTree node, P p) {
366
R r = scan(node.getExpressions(), p);
367
if (node.getCaseKind() == CaseTree.CaseKind.RULE)
368
r = scanAndReduce(node.getBody(), p, r);
369
else
370
r = scanAndReduce(node.getStatements(), p, r);
371
return r;
372
}
373
374
/**
375
* {@inheritDoc} This implementation scans the children in left to right order.
376
*
377
* @param node {@inheritDoc}
378
* @param p {@inheritDoc}
379
* @return the result of scanning
380
*/
381
@Override
382
public R visitSynchronized(SynchronizedTree node, P p) {
383
R r = scan(node.getExpression(), p);
384
r = scanAndReduce(node.getBlock(), p, r);
385
return r;
386
}
387
388
/**
389
* {@inheritDoc} This implementation scans the children in left to right order.
390
*
391
* @param node {@inheritDoc}
392
* @param p {@inheritDoc}
393
* @return the result of scanning
394
*/
395
@Override
396
public R visitTry(TryTree node, P p) {
397
R r = scan(node.getResources(), p);
398
r = scanAndReduce(node.getBlock(), p, r);
399
r = scanAndReduce(node.getCatches(), p, r);
400
r = scanAndReduce(node.getFinallyBlock(), p, r);
401
return r;
402
}
403
404
/**
405
* {@inheritDoc} This implementation scans the children in left to right order.
406
*
407
* @param node {@inheritDoc}
408
* @param p {@inheritDoc}
409
* @return the result of scanning
410
*/
411
@Override
412
public R visitCatch(CatchTree node, P p) {
413
R r = scan(node.getParameter(), p);
414
r = scanAndReduce(node.getBlock(), p, r);
415
return r;
416
}
417
418
/**
419
* {@inheritDoc} This implementation scans the children in left to right order.
420
*
421
* @param node {@inheritDoc}
422
* @param p {@inheritDoc}
423
* @return the result of scanning
424
*/
425
@Override
426
public R visitConditionalExpression(ConditionalExpressionTree node, P p) {
427
R r = scan(node.getCondition(), p);
428
r = scanAndReduce(node.getTrueExpression(), p, r);
429
r = scanAndReduce(node.getFalseExpression(), p, r);
430
return r;
431
}
432
433
/**
434
* {@inheritDoc} This implementation scans the children in left to right order.
435
*
436
* @param node {@inheritDoc}
437
* @param p {@inheritDoc}
438
* @return the result of scanning
439
*/
440
@Override
441
public R visitIf(IfTree node, P p) {
442
R r = scan(node.getCondition(), p);
443
r = scanAndReduce(node.getThenStatement(), p, r);
444
r = scanAndReduce(node.getElseStatement(), p, r);
445
return r;
446
}
447
448
/**
449
* {@inheritDoc} This implementation scans the children in left to right order.
450
*
451
* @param node {@inheritDoc}
452
* @param p {@inheritDoc}
453
* @return the result of scanning
454
*/
455
@Override
456
public R visitExpressionStatement(ExpressionStatementTree node, P p) {
457
return scan(node.getExpression(), p);
458
}
459
460
/**
461
* {@inheritDoc} This implementation returns {@code null}.
462
*
463
* @param node {@inheritDoc}
464
* @param p {@inheritDoc}
465
* @return the result of scanning
466
*/
467
@Override
468
public R visitBreak(BreakTree node, P p) {
469
return null;
470
}
471
472
/**
473
* {@inheritDoc} This implementation returns {@code null}.
474
*
475
* @param node {@inheritDoc}
476
* @param p {@inheritDoc}
477
* @return the result of scanning
478
*/
479
@Override
480
public R visitContinue(ContinueTree node, P p) {
481
return null;
482
}
483
484
/**
485
* {@inheritDoc} This implementation scans the children in left to right order.
486
*
487
* @param node {@inheritDoc}
488
* @param p {@inheritDoc}
489
* @return the result of scanning
490
*/
491
@Override
492
public R visitReturn(ReturnTree node, P p) {
493
return scan(node.getExpression(), p);
494
}
495
496
/**
497
* {@inheritDoc} This implementation scans the children in left to right order.
498
*
499
* @param node {@inheritDoc}
500
* @param p {@inheritDoc}
501
* @return the result of scanning
502
*/
503
@Override
504
public R visitThrow(ThrowTree node, P p) {
505
return scan(node.getExpression(), p);
506
}
507
508
/**
509
* {@inheritDoc} This implementation scans the children in left to right order.
510
*
511
* @param node {@inheritDoc}
512
* @param p {@inheritDoc}
513
* @return the result of scanning
514
*/
515
@Override
516
public R visitAssert(AssertTree node, P p) {
517
R r = scan(node.getCondition(), p);
518
r = scanAndReduce(node.getDetail(), p, r);
519
return r;
520
}
521
522
/**
523
* {@inheritDoc} This implementation scans the children in left to right order.
524
*
525
* @param node {@inheritDoc}
526
* @param p {@inheritDoc}
527
* @return the result of scanning
528
*/
529
@Override
530
public R visitMethodInvocation(MethodInvocationTree node, P p) {
531
R r = scan(node.getTypeArguments(), p);
532
r = scanAndReduce(node.getMethodSelect(), p, r);
533
r = scanAndReduce(node.getArguments(), p, r);
534
return r;
535
}
536
537
/**
538
* {@inheritDoc} This implementation scans the children in left to right order.
539
*
540
* @param node {@inheritDoc}
541
* @param p {@inheritDoc}
542
* @return the result of scanning
543
*/
544
@Override
545
public R visitNewClass(NewClassTree node, P p) {
546
R r = scan(node.getEnclosingExpression(), p);
547
r = scanAndReduce(node.getIdentifier(), p, r);
548
r = scanAndReduce(node.getTypeArguments(), p, r);
549
r = scanAndReduce(node.getArguments(), p, r);
550
r = scanAndReduce(node.getClassBody(), p, r);
551
return r;
552
}
553
554
/**
555
* {@inheritDoc} This implementation scans the children in left to right order.
556
*
557
* @param node {@inheritDoc}
558
* @param p {@inheritDoc}
559
* @return the result of scanning
560
*/
561
@Override
562
public R visitNewArray(NewArrayTree node, P p) {
563
R r = scan(node.getType(), p);
564
r = scanAndReduce(node.getDimensions(), p, r);
565
r = scanAndReduce(node.getInitializers(), p, r);
566
r = scanAndReduce(node.getAnnotations(), p, r);
567
for (Iterable< ? extends Tree> dimAnno : node.getDimAnnotations()) {
568
r = scanAndReduce(dimAnno, p, r);
569
}
570
return r;
571
}
572
573
/**
574
* {@inheritDoc} This implementation scans the children in left to right order.
575
*
576
* @param node {@inheritDoc}
577
* @param p {@inheritDoc}
578
* @return the result of scanning
579
*/
580
@Override
581
public R visitLambdaExpression(LambdaExpressionTree node, P p) {
582
R r = scan(node.getParameters(), p);
583
r = scanAndReduce(node.getBody(), p, r);
584
return r;
585
}
586
587
/**
588
* {@inheritDoc} This implementation scans the children in left to right order.
589
*
590
* @param node {@inheritDoc}
591
* @param p {@inheritDoc}
592
* @return the result of scanning
593
*/
594
@Override
595
public R visitParenthesized(ParenthesizedTree node, P p) {
596
return scan(node.getExpression(), p);
597
}
598
599
/**
600
* {@inheritDoc} This implementation scans the children in left to right order.
601
*
602
* @param node {@inheritDoc}
603
* @param p {@inheritDoc}
604
* @return the result of scanning
605
*/
606
@Override
607
public R visitAssignment(AssignmentTree node, P p) {
608
R r = scan(node.getVariable(), p);
609
r = scanAndReduce(node.getExpression(), p, r);
610
return r;
611
}
612
613
/**
614
* {@inheritDoc} This implementation scans the children in left to right order.
615
*
616
* @param node {@inheritDoc}
617
* @param p {@inheritDoc}
618
* @return the result of scanning
619
*/
620
@Override
621
public R visitCompoundAssignment(CompoundAssignmentTree node, P p) {
622
R r = scan(node.getVariable(), p);
623
r = scanAndReduce(node.getExpression(), p, r);
624
return r;
625
}
626
627
/**
628
* {@inheritDoc} This implementation scans the children in left to right order.
629
*
630
* @param node {@inheritDoc}
631
* @param p {@inheritDoc}
632
* @return the result of scanning
633
*/
634
@Override
635
public R visitUnary(UnaryTree node, P p) {
636
return scan(node.getExpression(), p);
637
}
638
639
/**
640
* {@inheritDoc} This implementation scans the children in left to right order.
641
*
642
* @param node {@inheritDoc}
643
* @param p {@inheritDoc}
644
* @return the result of scanning
645
*/
646
@Override
647
public R visitBinary(BinaryTree node, P p) {
648
R r = scan(node.getLeftOperand(), p);
649
r = scanAndReduce(node.getRightOperand(), p, r);
650
return r;
651
}
652
653
/**
654
* {@inheritDoc} This implementation scans the children in left to right order.
655
*
656
* @param node {@inheritDoc}
657
* @param p {@inheritDoc}
658
* @return the result of scanning
659
*/
660
@Override
661
public R visitTypeCast(TypeCastTree node, P p) {
662
R r = scan(node.getType(), p);
663
r = scanAndReduce(node.getExpression(), p, r);
664
return r;
665
}
666
667
/**
668
* {@inheritDoc} This implementation scans the children in left to right order.
669
*
670
* @param node {@inheritDoc}
671
* @param p {@inheritDoc}
672
* @return the result of scanning
673
*/
674
@Override
675
public R visitInstanceOf(InstanceOfTree node, P p) {
676
R r = scan(node.getExpression(), p);
677
if (node.getPattern() != null) {
678
r = scanAndReduce(node.getPattern(), p, r);
679
} else {
680
r = scanAndReduce(node.getType(), p, r);
681
}
682
return r;
683
}
684
685
/**
686
* {@inheritDoc} This implementation scans the children in left to right order.
687
*
688
* @param node {@inheritDoc}
689
* @param p {@inheritDoc}
690
* @return the result of scanning
691
* @since 14
692
*/
693
@Override
694
public R visitBindingPattern(BindingPatternTree node, P p) {
695
return scan(node.getVariable(), p);
696
}
697
698
/**
699
* {@inheritDoc} This implementation scans the children in left to right order.
700
*
701
* @param node {@inheritDoc}
702
* @param p {@inheritDoc}
703
* @return the result of scanning
704
*/
705
@Override
706
public R visitArrayAccess(ArrayAccessTree node, P p) {
707
R r = scan(node.getExpression(), p);
708
r = scanAndReduce(node.getIndex(), p, r);
709
return r;
710
}
711
712
/**
713
* {@inheritDoc} This implementation scans the children in left to right order.
714
*
715
* @param node {@inheritDoc}
716
* @param p {@inheritDoc}
717
* @return the result of scanning
718
*/
719
@Override
720
public R visitMemberSelect(MemberSelectTree node, P p) {
721
return scan(node.getExpression(), p);
722
}
723
724
/**
725
* {@inheritDoc} This implementation scans the children in left to right order.
726
*
727
* @param node {@inheritDoc}
728
* @param p {@inheritDoc}
729
* @return the result of scanning
730
*/
731
@Override
732
public R visitMemberReference(MemberReferenceTree node, P p) {
733
R r = scan(node.getQualifierExpression(), p);
734
r = scanAndReduce(node.getTypeArguments(), p, r);
735
return r;
736
}
737
738
/**
739
* {@inheritDoc} This implementation returns {@code null}.
740
*
741
* @param node {@inheritDoc}
742
* @param p {@inheritDoc}
743
* @return the result of scanning
744
*/
745
@Override
746
public R visitIdentifier(IdentifierTree node, P p) {
747
return null;
748
}
749
750
/**
751
* {@inheritDoc} This implementation returns {@code null}.
752
*
753
* @param node {@inheritDoc}
754
* @param p {@inheritDoc}
755
* @return the result of scanning
756
*/
757
@Override
758
public R visitLiteral(LiteralTree node, P p) {
759
return null;
760
}
761
762
/**
763
* {@inheritDoc} This implementation returns {@code null}.
764
*
765
* @param node {@inheritDoc}
766
* @param p {@inheritDoc}
767
* @return the result of scanning
768
*/
769
@Override
770
public R visitPrimitiveType(PrimitiveTypeTree node, P p) {
771
return null;
772
}
773
774
/**
775
* {@inheritDoc} This implementation scans the children in left to right order.
776
*
777
* @param node {@inheritDoc}
778
* @param p {@inheritDoc}
779
* @return the result of scanning
780
*/
781
@Override
782
public R visitArrayType(ArrayTypeTree node, P p) {
783
return scan(node.getType(), p);
784
}
785
786
/**
787
* {@inheritDoc} This implementation scans the children in left to right order.
788
*
789
* @param node {@inheritDoc}
790
* @param p {@inheritDoc}
791
* @return the result of scanning
792
*/
793
@Override
794
public R visitParameterizedType(ParameterizedTypeTree node, P p) {
795
R r = scan(node.getType(), p);
796
r = scanAndReduce(node.getTypeArguments(), p, r);
797
return r;
798
}
799
800
/**
801
* {@inheritDoc} This implementation scans the children in left to right order.
802
*
803
* @param node {@inheritDoc}
804
* @param p {@inheritDoc}
805
* @return the result of scanning
806
*/
807
@Override
808
public R visitUnionType(UnionTypeTree node, P p) {
809
return scan(node.getTypeAlternatives(), p);
810
}
811
812
/**
813
* {@inheritDoc} This implementation scans the children in left to right order.
814
*
815
* @param node {@inheritDoc}
816
* @param p {@inheritDoc}
817
* @return the result of scanning
818
*/
819
@Override
820
public R visitIntersectionType(IntersectionTypeTree node, P p) {
821
return scan(node.getBounds(), p);
822
}
823
824
/**
825
* {@inheritDoc} This implementation scans the children in left to right order.
826
*
827
* @param node {@inheritDoc}
828
* @param p {@inheritDoc}
829
* @return the result of scanning
830
*/
831
@Override
832
public R visitTypeParameter(TypeParameterTree node, P p) {
833
R r = scan(node.getAnnotations(), p);
834
r = scanAndReduce(node.getBounds(), p, r);
835
return r;
836
}
837
838
/**
839
* {@inheritDoc} This implementation scans the children in left to right order.
840
*
841
* @param node {@inheritDoc}
842
* @param p {@inheritDoc}
843
* @return the result of scanning
844
*/
845
@Override
846
public R visitWildcard(WildcardTree node, P p) {
847
return scan(node.getBound(), p);
848
}
849
850
/**
851
* {@inheritDoc} This implementation scans the children in left to right order.
852
*
853
* @param node {@inheritDoc}
854
* @param p {@inheritDoc}
855
* @return the result of scanning
856
*/
857
@Override
858
public R visitModifiers(ModifiersTree node, P p) {
859
return scan(node.getAnnotations(), p);
860
}
861
862
/**
863
* {@inheritDoc} This implementation scans the children in left to right order.
864
*
865
* @param node {@inheritDoc}
866
* @param p {@inheritDoc}
867
* @return the result of scanning
868
*/
869
@Override
870
public R visitAnnotation(AnnotationTree node, P p) {
871
R r = scan(node.getAnnotationType(), p);
872
r = scanAndReduce(node.getArguments(), p, r);
873
return r;
874
}
875
876
/**
877
* {@inheritDoc} This implementation scans the children in left to right order.
878
*
879
* @param node {@inheritDoc}
880
* @param p {@inheritDoc}
881
* @return the result of scanning
882
*/
883
@Override
884
public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
885
R r = scan(node.getAnnotations(), p);
886
r = scanAndReduce(node.getUnderlyingType(), p, r);
887
return r;
888
}
889
890
@Override
891
public R visitModule(ModuleTree node, P p) {
892
R r = scan(node.getAnnotations(), p);
893
r = scanAndReduce(node.getName(), p, r);
894
r = scanAndReduce(node.getDirectives(), p, r);
895
return r;
896
}
897
898
@Override
899
public R visitExports(ExportsTree node, P p) {
900
R r = scan(node.getPackageName(), p);
901
r = scanAndReduce(node.getModuleNames(), p, r);
902
return r;
903
}
904
905
@Override
906
public R visitOpens(OpensTree node, P p) {
907
R r = scan(node.getPackageName(), p);
908
r = scanAndReduce(node.getModuleNames(), p, r);
909
return r;
910
}
911
912
@Override
913
public R visitProvides(ProvidesTree node, P p) {
914
R r = scan(node.getServiceName(), p);
915
r = scanAndReduce(node.getImplementationNames(), p, r);
916
return r;
917
}
918
919
@Override
920
public R visitRequires(RequiresTree node, P p) {
921
return scan(node.getModuleName(), p);
922
}
923
924
@Override
925
public R visitUses(UsesTree node, P p) {
926
return scan(node.getServiceName(), p);
927
}
928
929
/**
930
* {@inheritDoc} This implementation returns {@code null}.
931
*
932
* @param node {@inheritDoc}
933
* @param p {@inheritDoc}
934
* @return the result of scanning
935
*/
936
@Override
937
public R visitOther(Tree node, P p) {
938
return null;
939
}
940
941
/**
942
* {@inheritDoc} This implementation returns {@code null}.
943
*
944
* @param node {@inheritDoc}
945
* @param p {@inheritDoc}
946
* @return the result of scanning
947
*/
948
@Override
949
public R visitErroneous(ErroneousTree node, P p) {
950
return null;
951
}
952
953
/**
954
* {@inheritDoc} This implementation scans the children in left to right order.
955
*
956
* @param node {@inheritDoc}
957
* @param p {@inheritDoc}
958
* @return the result of scanning
959
*/
960
@Override
961
public R visitYield(YieldTree node, P p) {
962
return scan(node.getValue(), p);
963
}
964
}
965
966