TreeScanner.java revision 2571:10fc81ac75b4
1/* 2 * Copyright (c) 2005, 2014, 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 26package com.sun.source.util; 27 28import 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} on 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} 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 of 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<Integer,Void> { 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é 74 * @author Jonathan Gibbons 75 * @since 1.6 76 */ 77@jdk.Exported 78public class TreeScanner<R,P> implements TreeVisitor<R,P> { 79 80 /** 81 * Scans a single node. 82 * @param tree the node to be scanned 83 * @param p a parameter value passed to the visit method 84 * @return the result value from the visit method 85 */ 86 public R scan(Tree tree, P p) { 87 return (tree == null) ? null : tree.accept(this, p); 88 } 89 90 private R scanAndReduce(Tree node, P p, R r) { 91 return reduce(scan(node, p), r); 92 } 93 94 /** 95 * Scans a sequence of nodes. 96 * @param nodes the nodes to be scanned 97 * @param p a parameter value to be passed to the visit method for each node 98 * @return the combined return value from the visit methods. 99 * The values are combined using the {@link #reduce reduce} method. 100 */ 101 public R scan(Iterable<? extends Tree> nodes, P p) { 102 R r = null; 103 if (nodes != null) { 104 boolean first = true; 105 for (Tree node : nodes) { 106 r = (first ? scan(node, p) : scanAndReduce(node, p, r)); 107 first = false; 108 } 109 } 110 return r; 111 } 112 113 private R scanAndReduce(Iterable<? extends Tree> nodes, P p, R r) { 114 return reduce(scan(nodes, p), r); 115 } 116 117 /** 118 * Reduces two results into a combined result. 119 * The default implementation is to return the first parameter. 120 * The general contract of the method is that it may take any action whatsoever. 121 * @param r1 the first of the values to be combined 122 * @param r2 the second of the values to be combined 123 * @return the result of combining the two parameters 124 */ 125 public R reduce(R r1, R r2) { 126 return r1; 127 } 128 129 130/* *************************************************************************** 131 * Visitor methods 132 ****************************************************************************/ 133 134 /** 135 * {@inheritDoc} This implementation scans the children in left to right order. 136 * 137 * @param node {@inheritDoc} 138 * @param p {@inheritDoc} 139 * @return the result of scanning 140 */ 141 @Override 142 public R visitCompilationUnit(CompilationUnitTree node, P p) { 143 R r = scan(node.getPackage(), p); 144 r = scanAndReduce(node.getImports(), p, r); 145 r = scanAndReduce(node.getTypeDecls(), p, r); 146 return r; 147 } 148 149 /** 150 * {@inheritDoc} This implementation scans the children in left to right order. 151 * 152 * @param node {@inheritDoc} 153 * @param p {@inheritDoc} 154 * @return the result of scanning 155 */ 156 @Override 157 public R visitPackage(PackageTree node, P p) { 158 R r = scan(node.getAnnotations(), p); 159 r = scanAndReduce(node.getPackageName(), p, r); 160 return r; 161 } 162 163 /** 164 * {@inheritDoc} This implementation scans the children in left to right order. 165 * 166 * @param node {@inheritDoc} 167 * @param p {@inheritDoc} 168 * @return the result of scanning 169 */ 170 @Override 171 public R visitImport(ImportTree node, P p) { 172 return scan(node.getQualifiedIdentifier(), p); 173 } 174 175 /** 176 * {@inheritDoc} This implementation scans the children in left to right order. 177 * 178 * @param node {@inheritDoc} 179 * @param p {@inheritDoc} 180 * @return the result of scanning 181 */ 182 @Override 183 public R visitClass(ClassTree node, P p) { 184 R r = scan(node.getModifiers(), p); 185 r = scanAndReduce(node.getTypeParameters(), p, r); 186 r = scanAndReduce(node.getExtendsClause(), p, r); 187 r = scanAndReduce(node.getImplementsClause(), p, r); 188 r = scanAndReduce(node.getMembers(), p, r); 189 return r; 190 } 191 192 /** 193 * {@inheritDoc} This implementation scans the children in left to right order. 194 * 195 * @param node {@inheritDoc} 196 * @param p {@inheritDoc} 197 * @return the result of scanning 198 */ 199 @Override 200 public R visitMethod(MethodTree node, P p) { 201 R r = scan(node.getModifiers(), p); 202 r = scanAndReduce(node.getReturnType(), p, r); 203 r = scanAndReduce(node.getTypeParameters(), p, r); 204 r = scanAndReduce(node.getParameters(), p, r); 205 r = scanAndReduce(node.getReceiverParameter(), p, r); 206 r = scanAndReduce(node.getThrows(), p, r); 207 r = scanAndReduce(node.getBody(), p, r); 208 r = scanAndReduce(node.getDefaultValue(), p, r); 209 return r; 210 } 211 212 /** 213 * {@inheritDoc} This implementation scans the children in left to right order. 214 * 215 * @param node {@inheritDoc} 216 * @param p {@inheritDoc} 217 * @return the result of scanning 218 */ 219 @Override 220 public R visitVariable(VariableTree node, P p) { 221 R r = scan(node.getModifiers(), p); 222 r = scanAndReduce(node.getType(), p, r); 223 r = scanAndReduce(node.getNameExpression(), p, r); 224 r = scanAndReduce(node.getInitializer(), p, r); 225 return r; 226 } 227 228 /** 229 * {@inheritDoc} This implementation returns {@code null}. 230 * 231 * @param node {@inheritDoc} 232 * @param p {@inheritDoc} 233 * @return the result of scanning 234 */ 235 @Override 236 public R visitEmptyStatement(EmptyStatementTree node, P p) { 237 return null; 238 } 239 240 /** 241 * {@inheritDoc} This implementation scans the children in left to right order. 242 * 243 * @param node {@inheritDoc} 244 * @param p {@inheritDoc} 245 * @return the result of scanning 246 */ 247 @Override 248 public R visitBlock(BlockTree node, P p) { 249 return scan(node.getStatements(), p); 250 } 251 252 /** 253 * {@inheritDoc} This implementation scans the children in left to right order. 254 * 255 * @param node {@inheritDoc} 256 * @param p {@inheritDoc} 257 * @return the result of scanning 258 */ 259 @Override 260 public R visitDoWhileLoop(DoWhileLoopTree node, P p) { 261 R r = scan(node.getStatement(), p); 262 r = scanAndReduce(node.getCondition(), p, r); 263 return r; 264 } 265 266 /** 267 * {@inheritDoc} This implementation scans the children in left to right order. 268 * 269 * @param node {@inheritDoc} 270 * @param p {@inheritDoc} 271 * @return the result of scanning 272 */ 273 @Override 274 public R visitWhileLoop(WhileLoopTree node, P p) { 275 R r = scan(node.getCondition(), p); 276 r = scanAndReduce(node.getStatement(), p, r); 277 return r; 278 } 279 280 /** 281 * {@inheritDoc} This implementation scans the children in left to right order. 282 * 283 * @param node {@inheritDoc} 284 * @param p {@inheritDoc} 285 * @return the result of scanning 286 */ 287 @Override 288 public R visitForLoop(ForLoopTree node, P p) { 289 R r = scan(node.getInitializer(), p); 290 r = scanAndReduce(node.getCondition(), p, r); 291 r = scanAndReduce(node.getUpdate(), p, r); 292 r = scanAndReduce(node.getStatement(), p, r); 293 return r; 294 } 295 296 /** 297 * {@inheritDoc} This implementation scans the children in left to right order. 298 * 299 * @param node {@inheritDoc} 300 * @param p {@inheritDoc} 301 * @return the result of scanning 302 */ 303 @Override 304 public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { 305 R r = scan(node.getVariable(), p); 306 r = scanAndReduce(node.getExpression(), p, r); 307 r = scanAndReduce(node.getStatement(), p, r); 308 return r; 309 } 310 311 /** 312 * {@inheritDoc} This implementation scans the children in left to right order. 313 * 314 * @param node {@inheritDoc} 315 * @param p {@inheritDoc} 316 * @return the result of scanning 317 */ 318 @Override 319 public R visitLabeledStatement(LabeledStatementTree node, P p) { 320 return scan(node.getStatement(), p); 321 } 322 323 /** 324 * {@inheritDoc} This implementation scans the children in left to right order. 325 * 326 * @param node {@inheritDoc} 327 * @param p {@inheritDoc} 328 * @return the result of scanning 329 */ 330 @Override 331 public R visitSwitch(SwitchTree node, P p) { 332 R r = scan(node.getExpression(), p); 333 r = scanAndReduce(node.getCases(), p, r); 334 return r; 335 } 336 337 /** 338 * {@inheritDoc} This implementation scans the children in left to right order. 339 * 340 * @param node {@inheritDoc} 341 * @param p {@inheritDoc} 342 * @return the result of scanning 343 */ 344 @Override 345 public R visitCase(CaseTree node, P p) { 346 R r = scan(node.getExpression(), p); 347 r = scanAndReduce(node.getStatements(), p, r); 348 return r; 349 } 350 351 /** 352 * {@inheritDoc} This implementation scans the children in left to right order. 353 * 354 * @param node {@inheritDoc} 355 * @param p {@inheritDoc} 356 * @return the result of scanning 357 */ 358 @Override 359 public R visitSynchronized(SynchronizedTree node, P p) { 360 R r = scan(node.getExpression(), p); 361 r = scanAndReduce(node.getBlock(), p, r); 362 return r; 363 } 364 365 /** 366 * {@inheritDoc} This implementation scans the children in left to right order. 367 * 368 * @param node {@inheritDoc} 369 * @param p {@inheritDoc} 370 * @return the result of scanning 371 */ 372 @Override 373 public R visitTry(TryTree node, P p) { 374 R r = scan(node.getResources(), p); 375 r = scanAndReduce(node.getBlock(), p, r); 376 r = scanAndReduce(node.getCatches(), p, r); 377 r = scanAndReduce(node.getFinallyBlock(), p, r); 378 return r; 379 } 380 381 /** 382 * {@inheritDoc} This implementation scans the children in left to right order. 383 * 384 * @param node {@inheritDoc} 385 * @param p {@inheritDoc} 386 * @return the result of scanning 387 */ 388 @Override 389 public R visitCatch(CatchTree node, P p) { 390 R r = scan(node.getParameter(), p); 391 r = scanAndReduce(node.getBlock(), p, r); 392 return r; 393 } 394 395 /** 396 * {@inheritDoc} This implementation scans the children in left to right order. 397 * 398 * @param node {@inheritDoc} 399 * @param p {@inheritDoc} 400 * @return the result of scanning 401 */ 402 @Override 403 public R visitConditionalExpression(ConditionalExpressionTree node, P p) { 404 R r = scan(node.getCondition(), p); 405 r = scanAndReduce(node.getTrueExpression(), p, r); 406 r = scanAndReduce(node.getFalseExpression(), p, r); 407 return r; 408 } 409 410 /** 411 * {@inheritDoc} This implementation scans the children in left to right order. 412 * 413 * @param node {@inheritDoc} 414 * @param p {@inheritDoc} 415 * @return the result of scanning 416 */ 417 @Override 418 public R visitIf(IfTree node, P p) { 419 R r = scan(node.getCondition(), p); 420 r = scanAndReduce(node.getThenStatement(), p, r); 421 r = scanAndReduce(node.getElseStatement(), p, r); 422 return r; 423 } 424 425 /** 426 * {@inheritDoc} This implementation scans the children in left to right order. 427 * 428 * @param node {@inheritDoc} 429 * @param p {@inheritDoc} 430 * @return the result of scanning 431 */ 432 @Override 433 public R visitExpressionStatement(ExpressionStatementTree node, P p) { 434 return scan(node.getExpression(), p); 435 } 436 437 /** 438 * {@inheritDoc} This implementation returns {@code null}. 439 * 440 * @param node {@inheritDoc} 441 * @param p {@inheritDoc} 442 * @return the result of scanning 443 */ 444 @Override 445 public R visitBreak(BreakTree node, P p) { 446 return null; 447 } 448 449 /** 450 * {@inheritDoc} This implementation returns {@code null}. 451 * 452 * @param node {@inheritDoc} 453 * @param p {@inheritDoc} 454 * @return the result of scanning 455 */ 456 @Override 457 public R visitContinue(ContinueTree node, P p) { 458 return null; 459 } 460 461 /** 462 * {@inheritDoc} This implementation scans the children in left to right order. 463 * 464 * @param node {@inheritDoc} 465 * @param p {@inheritDoc} 466 * @return the result of scanning 467 */ 468 @Override 469 public R visitReturn(ReturnTree node, P p) { 470 return scan(node.getExpression(), p); 471 } 472 473 /** 474 * {@inheritDoc} This implementation scans the children in left to right order. 475 * 476 * @param node {@inheritDoc} 477 * @param p {@inheritDoc} 478 * @return the result of scanning 479 */ 480 @Override 481 public R visitThrow(ThrowTree node, P p) { 482 return scan(node.getExpression(), p); 483 } 484 485 /** 486 * {@inheritDoc} This implementation scans the children in left to right order. 487 * 488 * @param node {@inheritDoc} 489 * @param p {@inheritDoc} 490 * @return the result of scanning 491 */ 492 @Override 493 public R visitAssert(AssertTree node, P p) { 494 R r = scan(node.getCondition(), p); 495 r = scanAndReduce(node.getDetail(), p, r); 496 return r; 497 } 498 499 /** 500 * {@inheritDoc} This implementation scans the children in left to right order. 501 * 502 * @param node {@inheritDoc} 503 * @param p {@inheritDoc} 504 * @return the result of scanning 505 */ 506 @Override 507 public R visitMethodInvocation(MethodInvocationTree node, P p) { 508 R r = scan(node.getTypeArguments(), p); 509 r = scanAndReduce(node.getMethodSelect(), p, r); 510 r = scanAndReduce(node.getArguments(), p, r); 511 return r; 512 } 513 514 /** 515 * {@inheritDoc} This implementation scans the children in left to right order. 516 * 517 * @param node {@inheritDoc} 518 * @param p {@inheritDoc} 519 * @return the result of scanning 520 */ 521 @Override 522 public R visitNewClass(NewClassTree node, P p) { 523 R r = scan(node.getEnclosingExpression(), p); 524 r = scanAndReduce(node.getIdentifier(), p, r); 525 r = scanAndReduce(node.getTypeArguments(), p, r); 526 r = scanAndReduce(node.getArguments(), p, r); 527 r = scanAndReduce(node.getClassBody(), p, r); 528 return r; 529 } 530 531 /** 532 * {@inheritDoc} This implementation scans the children in left to right order. 533 * 534 * @param node {@inheritDoc} 535 * @param p {@inheritDoc} 536 * @return the result of scanning 537 */ 538 @Override 539 public R visitNewArray(NewArrayTree node, P p) { 540 R r = scan(node.getType(), p); 541 r = scanAndReduce(node.getDimensions(), p, r); 542 r = scanAndReduce(node.getInitializers(), p, r); 543 r = scanAndReduce(node.getAnnotations(), p, r); 544 for (Iterable< ? extends Tree> dimAnno : node.getDimAnnotations()) { 545 r = scanAndReduce(dimAnno, p, r); 546 } 547 return r; 548 } 549 550 /** 551 * {@inheritDoc} This implementation scans the children in left to right order. 552 * 553 * @param node {@inheritDoc} 554 * @param p {@inheritDoc} 555 * @return the result of scanning 556 */ 557 @Override 558 public R visitLambdaExpression(LambdaExpressionTree node, P p) { 559 R r = scan(node.getParameters(), p); 560 r = scanAndReduce(node.getBody(), p, r); 561 return r; 562 } 563 564 /** 565 * {@inheritDoc} This implementation scans the children in left to right order. 566 * 567 * @param node {@inheritDoc} 568 * @param p {@inheritDoc} 569 * @return the result of scanning 570 */ 571 @Override 572 public R visitParenthesized(ParenthesizedTree node, P p) { 573 return scan(node.getExpression(), p); 574 } 575 576 /** 577 * {@inheritDoc} This implementation scans the children in left to right order. 578 * 579 * @param node {@inheritDoc} 580 * @param p {@inheritDoc} 581 * @return the result of scanning 582 */ 583 @Override 584 public R visitAssignment(AssignmentTree node, P p) { 585 R r = scan(node.getVariable(), p); 586 r = scanAndReduce(node.getExpression(), p, r); 587 return r; 588 } 589 590 /** 591 * {@inheritDoc} This implementation scans the children in left to right order. 592 * 593 * @param node {@inheritDoc} 594 * @param p {@inheritDoc} 595 * @return the result of scanning 596 */ 597 @Override 598 public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { 599 R r = scan(node.getVariable(), p); 600 r = scanAndReduce(node.getExpression(), p, r); 601 return r; 602 } 603 604 /** 605 * {@inheritDoc} This implementation scans the children in left to right order. 606 * 607 * @param node {@inheritDoc} 608 * @param p {@inheritDoc} 609 * @return the result of scanning 610 */ 611 @Override 612 public R visitUnary(UnaryTree node, P p) { 613 return scan(node.getExpression(), p); 614 } 615 616 /** 617 * {@inheritDoc} This implementation scans the children in left to right order. 618 * 619 * @param node {@inheritDoc} 620 * @param p {@inheritDoc} 621 * @return the result of scanning 622 */ 623 @Override 624 public R visitBinary(BinaryTree node, P p) { 625 R r = scan(node.getLeftOperand(), p); 626 r = scanAndReduce(node.getRightOperand(), p, r); 627 return r; 628 } 629 630 /** 631 * {@inheritDoc} This implementation scans the children in left to right order. 632 * 633 * @param node {@inheritDoc} 634 * @param p {@inheritDoc} 635 * @return the result of scanning 636 */ 637 @Override 638 public R visitTypeCast(TypeCastTree node, P p) { 639 R r = scan(node.getType(), p); 640 r = scanAndReduce(node.getExpression(), p, r); 641 return r; 642 } 643 644 /** 645 * {@inheritDoc} This implementation scans the children in left to right order. 646 * 647 * @param node {@inheritDoc} 648 * @param p {@inheritDoc} 649 * @return the result of scanning 650 */ 651 @Override 652 public R visitInstanceOf(InstanceOfTree node, P p) { 653 R r = scan(node.getExpression(), p); 654 r = scanAndReduce(node.getType(), p, r); 655 return r; 656 } 657 658 /** 659 * {@inheritDoc} This implementation scans the children in left to right order. 660 * 661 * @param node {@inheritDoc} 662 * @param p {@inheritDoc} 663 * @return the result of scanning 664 */ 665 @Override 666 public R visitArrayAccess(ArrayAccessTree node, P p) { 667 R r = scan(node.getExpression(), p); 668 r = scanAndReduce(node.getIndex(), p, r); 669 return r; 670 } 671 672 /** 673 * {@inheritDoc} This implementation scans the children in left to right order. 674 * 675 * @param node {@inheritDoc} 676 * @param p {@inheritDoc} 677 * @return the result of scanning 678 */ 679 @Override 680 public R visitMemberSelect(MemberSelectTree node, P p) { 681 return scan(node.getExpression(), p); 682 } 683 684 /** 685 * {@inheritDoc} This implementation scans the children in left to right order. 686 * 687 * @param node {@inheritDoc} 688 * @param p {@inheritDoc} 689 * @return the result of scanning 690 */ 691 @Override 692 public R visitMemberReference(MemberReferenceTree node, P p) { 693 R r = scan(node.getQualifierExpression(), p); 694 r = scanAndReduce(node.getTypeArguments(), p, r); 695 return r; 696 } 697 698 /** 699 * {@inheritDoc} This implementation returns {@code null}. 700 * 701 * @param node {@inheritDoc} 702 * @param p {@inheritDoc} 703 * @return the result of scanning 704 */ 705 @Override 706 public R visitIdentifier(IdentifierTree node, P p) { 707 return null; 708 } 709 710 /** 711 * {@inheritDoc} This implementation returns {@code null}. 712 * 713 * @param node {@inheritDoc} 714 * @param p {@inheritDoc} 715 * @return the result of scanning 716 */ 717 @Override 718 public R visitLiteral(LiteralTree node, P p) { 719 return null; 720 } 721 722 /** 723 * {@inheritDoc} This implementation returns {@code null}. 724 * 725 * @param node {@inheritDoc} 726 * @param p {@inheritDoc} 727 * @return the result of scanning 728 */ 729 @Override 730 public R visitPrimitiveType(PrimitiveTypeTree node, P p) { 731 return null; 732 } 733 734 /** 735 * {@inheritDoc} This implementation scans the children in left to right order. 736 * 737 * @param node {@inheritDoc} 738 * @param p {@inheritDoc} 739 * @return the result of scanning 740 */ 741 @Override 742 public R visitArrayType(ArrayTypeTree node, P p) { 743 return scan(node.getType(), p); 744 } 745 746 /** 747 * {@inheritDoc} This implementation scans the children in left to right order. 748 * 749 * @param node {@inheritDoc} 750 * @param p {@inheritDoc} 751 * @return the result of scanning 752 */ 753 @Override 754 public R visitParameterizedType(ParameterizedTypeTree node, P p) { 755 R r = scan(node.getType(), p); 756 r = scanAndReduce(node.getTypeArguments(), p, r); 757 return r; 758 } 759 760 /** 761 * {@inheritDoc} This implementation scans the children in left to right order. 762 * 763 * @param node {@inheritDoc} 764 * @param p {@inheritDoc} 765 * @return the result of scanning 766 */ 767 @Override 768 public R visitUnionType(UnionTypeTree node, P p) { 769 return scan(node.getTypeAlternatives(), p); 770 } 771 772 /** 773 * {@inheritDoc} This implementation scans the children in left to right order. 774 * 775 * @param node {@inheritDoc} 776 * @param p {@inheritDoc} 777 * @return the result of scanning 778 */ 779 @Override 780 public R visitIntersectionType(IntersectionTypeTree node, P p) { 781 return scan(node.getBounds(), p); 782 } 783 784 /** 785 * {@inheritDoc} This implementation scans the children in left to right order. 786 * 787 * @param node {@inheritDoc} 788 * @param p {@inheritDoc} 789 * @return the result of scanning 790 */ 791 @Override 792 public R visitTypeParameter(TypeParameterTree node, P p) { 793 R r = scan(node.getAnnotations(), p); 794 r = scanAndReduce(node.getBounds(), p, r); 795 return r; 796 } 797 798 /** 799 * {@inheritDoc} This implementation scans the children in left to right order. 800 * 801 * @param node {@inheritDoc} 802 * @param p {@inheritDoc} 803 * @return the result of scanning 804 */ 805 @Override 806 public R visitWildcard(WildcardTree node, P p) { 807 return scan(node.getBound(), p); 808 } 809 810 /** 811 * {@inheritDoc} This implementation scans the children in left to right order. 812 * 813 * @param node {@inheritDoc} 814 * @param p {@inheritDoc} 815 * @return the result of scanning 816 */ 817 @Override 818 public R visitModifiers(ModifiersTree node, P p) { 819 return scan(node.getAnnotations(), p); 820 } 821 822 /** 823 * {@inheritDoc} This implementation scans the children in left to right order. 824 * 825 * @param node {@inheritDoc} 826 * @param p {@inheritDoc} 827 * @return the result of scanning 828 */ 829 @Override 830 public R visitAnnotation(AnnotationTree node, P p) { 831 R r = scan(node.getAnnotationType(), p); 832 r = scanAndReduce(node.getArguments(), p, r); 833 return r; 834 } 835 836 /** 837 * {@inheritDoc} This implementation scans the children in left to right order. 838 * 839 * @param node {@inheritDoc} 840 * @param p {@inheritDoc} 841 * @return the result of scanning 842 */ 843 @Override 844 public R visitAnnotatedType(AnnotatedTypeTree node, P p) { 845 R r = scan(node.getAnnotations(), p); 846 r = scanAndReduce(node.getUnderlyingType(), p, r); 847 return r; 848 } 849 850 /** 851 * {@inheritDoc} This implementation returns {@code null}. 852 * 853 * @param node {@inheritDoc} 854 * @param p {@inheritDoc} 855 * @return the result of scanning 856 */ 857 @Override 858 public R visitOther(Tree node, P p) { 859 return null; 860 } 861 862 /** 863 * {@inheritDoc} This implementation returns {@code null}. 864 * 865 * @param node {@inheritDoc} 866 * @param p {@inheritDoc} 867 * @return the result of scanning 868 */ 869 @Override 870 public R visitErroneous(ErroneousTree node, P p) { 871 return null; 872 } 873} 874