src/share/classes/com/sun/source/util/SimpleTreeVisitor.java

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

     1 /*
     2  * Copyright (c) 2005, 2013, 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  */
    26 package com.sun.source.util;
    28 import com.sun.source.tree.*;
    30 /**
    31  * A simple visitor for tree nodes.
    32  *
    33  * @author Peter von der Ahé
    34  * @since 1.6
    35  */
    36 @jdk.Exported
    37 public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
    38     protected final R DEFAULT_VALUE;
    40     protected SimpleTreeVisitor() {
    41         DEFAULT_VALUE = null;
    42     }
    44     protected SimpleTreeVisitor(R defaultValue) {
    45         DEFAULT_VALUE = defaultValue;
    46     }
    48     protected R defaultAction(Tree node, P p) {
    49         return DEFAULT_VALUE;
    50     }
    52     public final R visit(Tree node, P p) {
    53         return (node == null) ? null : node.accept(this, p);
    54     }
    56     public final R visit(Iterable<? extends Tree> nodes, P p) {
    57         R r = null;
    58         if (nodes != null)
    59             for (Tree node : nodes)
    60                 r = visit(node, p);
    61         return r;
    62     }
    64     public R visitCompilationUnit(CompilationUnitTree node, P p) {
    65         return defaultAction(node, p);
    66     }
    68     public R visitImport(ImportTree node, P p) {
    69         return defaultAction(node, p);
    70     }
    72     public R visitClass(ClassTree node, P p) {
    73         return defaultAction(node, p);
    74     }
    76     public R visitMethod(MethodTree node, P p) {
    77         return defaultAction(node, p);
    78     }
    80     public R visitVariable(VariableTree node, P p) {
    81         return defaultAction(node, p);
    82     }
    84     public R visitEmptyStatement(EmptyStatementTree node, P p) {
    85         return defaultAction(node, p);
    86     }
    88     public R visitBlock(BlockTree node, P p) {
    89         return defaultAction(node, p);
    90     }
    92     public R visitDoWhileLoop(DoWhileLoopTree node, P p) {
    93         return defaultAction(node, p);
    94     }
    96     public R visitWhileLoop(WhileLoopTree node, P p) {
    97         return defaultAction(node, p);
    98     }
   100     public R visitForLoop(ForLoopTree node, P p) {
   101         return defaultAction(node, p);
   102     }
   104     public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
   105         return defaultAction(node, p);
   106     }
   108     public R visitLabeledStatement(LabeledStatementTree node, P p) {
   109         return defaultAction(node, p);
   110     }
   112     public R visitSwitch(SwitchTree node, P p) {
   113         return defaultAction(node, p);
   114     }
   116     public R visitCase(CaseTree node, P p) {
   117         return defaultAction(node, p);
   118     }
   120     public R visitSynchronized(SynchronizedTree node, P p) {
   121         return defaultAction(node, p);
   122     }
   124     public R visitTry(TryTree node, P p) {
   125         return defaultAction(node, p);
   126     }
   128     public R visitCatch(CatchTree node, P p) {
   129         return defaultAction(node, p);
   130     }
   132     public R visitConditionalExpression(ConditionalExpressionTree node, P p) {
   133         return defaultAction(node, p);
   134     }
   136     public R visitIf(IfTree node, P p) {
   137         return defaultAction(node, p);
   138     }
   140     public R visitExpressionStatement(ExpressionStatementTree node, P p) {
   141         return defaultAction(node, p);
   142     }
   144     public R visitBreak(BreakTree node, P p) {
   145         return defaultAction(node, p);
   146     }
   148     public R visitContinue(ContinueTree node, P p) {
   149         return defaultAction(node, p);
   150     }
   152     public R visitReturn(ReturnTree node, P p) {
   153         return defaultAction(node, p);
   154     }
   156     public R visitThrow(ThrowTree node, P p) {
   157         return defaultAction(node, p);
   158     }
   160     public R visitAssert(AssertTree node, P p) {
   161         return defaultAction(node, p);
   162     }
   164     public R visitMethodInvocation(MethodInvocationTree node, P p) {
   165         return defaultAction(node, p);
   166     }
   168     public R visitNewClass(NewClassTree node, P p) {
   169         return defaultAction(node, p);
   170     }
   172     public R visitNewArray(NewArrayTree node, P p) {
   173         return defaultAction(node, p);
   174     }
   176     public R visitLambdaExpression(LambdaExpressionTree node, P p) {
   177         return defaultAction(node, p);
   178     }
   180     public R visitParenthesized(ParenthesizedTree node, P p) {
   181         return defaultAction(node, p);
   182     }
   184     public R visitAssignment(AssignmentTree node, P p) {
   185         return defaultAction(node, p);
   186     }
   188     public R visitCompoundAssignment(CompoundAssignmentTree node, P p) {
   189         return defaultAction(node, p);
   190     }
   192     public R visitUnary(UnaryTree node, P p) {
   193         return defaultAction(node, p);
   194     }
   196     public R visitBinary(BinaryTree node, P p) {
   197         return defaultAction(node, p);
   198     }
   200     public R visitTypeCast(TypeCastTree node, P p) {
   201         return defaultAction(node, p);
   202     }
   204     public R visitInstanceOf(InstanceOfTree node, P p) {
   205         return defaultAction(node, p);
   206     }
   208     public R visitArrayAccess(ArrayAccessTree node, P p) {
   209         return defaultAction(node, p);
   210     }
   212     public R visitMemberSelect(MemberSelectTree node, P p) {
   213         return defaultAction(node, p);
   214     }
   216     public R visitMemberReference(MemberReferenceTree node, P p) {
   217         return defaultAction(node, p);
   218     }
   220     public R visitIdentifier(IdentifierTree node, P p) {
   221         return defaultAction(node, p);
   222     }
   224     public R visitLiteral(LiteralTree node, P p) {
   225         return defaultAction(node, p);
   226     }
   228     public R visitPrimitiveType(PrimitiveTypeTree node, P p) {
   229         return defaultAction(node, p);
   230     }
   232     public R visitArrayType(ArrayTypeTree node, P p) {
   233         return defaultAction(node, p);
   234     }
   236     public R visitParameterizedType(ParameterizedTypeTree node, P p) {
   237         return defaultAction(node, p);
   238     }
   240     public R visitUnionType(UnionTypeTree node, P p) {
   241         return defaultAction(node, p);
   242     }
   244     public R visitIntersectionType(IntersectionTypeTree node, P p) {
   245         return defaultAction(node, p);
   246     }
   248     public R visitTypeParameter(TypeParameterTree node, P p) {
   249         return defaultAction(node, p);
   250     }
   252     public R visitWildcard(WildcardTree node, P p) {
   253         return defaultAction(node, p);
   254     }
   256     public R visitModifiers(ModifiersTree node, P p) {
   257         return defaultAction(node, p);
   258     }
   260     public R visitAnnotation(AnnotationTree node, P p) {
   261         return defaultAction(node, p);
   262     }
   264     public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
   265         return defaultAction(node, p);
   266     }
   268     public R visitErroneous(ErroneousTree node, P p) {
   269         return defaultAction(node, p);
   270     }
   272     public R visitOther(Tree node, P p) {
   273         return defaultAction(node, p);
   274     }
   275 }

mercurial