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 */ 25 26 package com.sun.source.tree; 27 28 /** 29 * A visitor of trees, in the style of the visitor design pattern. 30 * Classes implementing this interface are used to operate 31 * on a tree when the kind of tree is unknown at compile time. 32 * When a visitor is passed to an tree's {@link Tree#accept 33 * accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable 34 * to that tree is invoked. 35 * 36 * <p> Classes implementing this interface may or may not throw a 37 * {@code NullPointerException} if the additional parameter {@code p} 38 * is {@code null}; see documentation of the implementing class for 39 * details. 40 * 41 * <p> <b>WARNING:</b> It is possible that methods will be added to 42 * this interface to accommodate new, currently unknown, language 43 * structures added to future versions of the Java™ programming 44 * language. Therefore, visitor classes directly implementing this 45 * interface may be source incompatible with future versions of the 46 * platform. 47 * 48 * @param <R> the return type of this visitor's methods. Use {@link 49 * Void} for visitors that do not need to return results. 50 * @param <P> the type of the additional parameter to this visitor's 51 * methods. Use {@code Void} for visitors that do not need an 52 * additional parameter. 53 * 54 * @author Peter von der Ahé 55 * @author Jonathan Gibbons 56 * 57 * @since 1.6 58 */ 59 @jdk.Exported 60 public interface TreeVisitor<R,P> { visitAnnotatedType(AnnotatedTypeTree node, P p)61 R visitAnnotatedType(AnnotatedTypeTree node, P p); visitAnnotation(AnnotationTree node, P p)62 R visitAnnotation(AnnotationTree node, P p); visitMethodInvocation(MethodInvocationTree node, P p)63 R visitMethodInvocation(MethodInvocationTree node, P p); visitAssert(AssertTree node, P p)64 R visitAssert(AssertTree node, P p); visitAssignment(AssignmentTree node, P p)65 R visitAssignment(AssignmentTree node, P p); visitCompoundAssignment(CompoundAssignmentTree node, P p)66 R visitCompoundAssignment(CompoundAssignmentTree node, P p); visitBinary(BinaryTree node, P p)67 R visitBinary(BinaryTree node, P p); visitBlock(BlockTree node, P p)68 R visitBlock(BlockTree node, P p); visitBreak(BreakTree node, P p)69 R visitBreak(BreakTree node, P p); visitCase(CaseTree node, P p)70 R visitCase(CaseTree node, P p); visitCatch(CatchTree node, P p)71 R visitCatch(CatchTree node, P p); visitClass(ClassTree node, P p)72 R visitClass(ClassTree node, P p); visitConditionalExpression(ConditionalExpressionTree node, P p)73 R visitConditionalExpression(ConditionalExpressionTree node, P p); visitContinue(ContinueTree node, P p)74 R visitContinue(ContinueTree node, P p); visitDoWhileLoop(DoWhileLoopTree node, P p)75 R visitDoWhileLoop(DoWhileLoopTree node, P p); visitErroneous(ErroneousTree node, P p)76 R visitErroneous(ErroneousTree node, P p); visitExpressionStatement(ExpressionStatementTree node, P p)77 R visitExpressionStatement(ExpressionStatementTree node, P p); visitEnhancedForLoop(EnhancedForLoopTree node, P p)78 R visitEnhancedForLoop(EnhancedForLoopTree node, P p); visitForLoop(ForLoopTree node, P p)79 R visitForLoop(ForLoopTree node, P p); visitIdentifier(IdentifierTree node, P p)80 R visitIdentifier(IdentifierTree node, P p); visitIf(IfTree node, P p)81 R visitIf(IfTree node, P p); visitImport(ImportTree node, P p)82 R visitImport(ImportTree node, P p); visitArrayAccess(ArrayAccessTree node, P p)83 R visitArrayAccess(ArrayAccessTree node, P p); visitLabeledStatement(LabeledStatementTree node, P p)84 R visitLabeledStatement(LabeledStatementTree node, P p); visitLiteral(LiteralTree node, P p)85 R visitLiteral(LiteralTree node, P p); visitMethod(MethodTree node, P p)86 R visitMethod(MethodTree node, P p); visitModifiers(ModifiersTree node, P p)87 R visitModifiers(ModifiersTree node, P p); visitNewArray(NewArrayTree node, P p)88 R visitNewArray(NewArrayTree node, P p); visitNewClass(NewClassTree node, P p)89 R visitNewClass(NewClassTree node, P p); visitLambdaExpression(LambdaExpressionTree node, P p)90 R visitLambdaExpression(LambdaExpressionTree node, P p); visitParenthesized(ParenthesizedTree node, P p)91 R visitParenthesized(ParenthesizedTree node, P p); visitReturn(ReturnTree node, P p)92 R visitReturn(ReturnTree node, P p); visitMemberSelect(MemberSelectTree node, P p)93 R visitMemberSelect(MemberSelectTree node, P p); visitMemberReference(MemberReferenceTree node, P p)94 R visitMemberReference(MemberReferenceTree node, P p); visitEmptyStatement(EmptyStatementTree node, P p)95 R visitEmptyStatement(EmptyStatementTree node, P p); visitSwitch(SwitchTree node, P p)96 R visitSwitch(SwitchTree node, P p); visitSynchronized(SynchronizedTree node, P p)97 R visitSynchronized(SynchronizedTree node, P p); visitThrow(ThrowTree node, P p)98 R visitThrow(ThrowTree node, P p); visitCompilationUnit(CompilationUnitTree node, P p)99 R visitCompilationUnit(CompilationUnitTree node, P p); visitTry(TryTree node, P p)100 R visitTry(TryTree node, P p); visitParameterizedType(ParameterizedTypeTree node, P p)101 R visitParameterizedType(ParameterizedTypeTree node, P p); visitUnionType(UnionTypeTree node, P p)102 R visitUnionType(UnionTypeTree node, P p); visitIntersectionType(IntersectionTypeTree node, P p)103 R visitIntersectionType(IntersectionTypeTree node, P p); visitArrayType(ArrayTypeTree node, P p)104 R visitArrayType(ArrayTypeTree node, P p); visitTypeCast(TypeCastTree node, P p)105 R visitTypeCast(TypeCastTree node, P p); visitPrimitiveType(PrimitiveTypeTree node, P p)106 R visitPrimitiveType(PrimitiveTypeTree node, P p); visitTypeParameter(TypeParameterTree node, P p)107 R visitTypeParameter(TypeParameterTree node, P p); visitInstanceOf(InstanceOfTree node, P p)108 R visitInstanceOf(InstanceOfTree node, P p); visitUnary(UnaryTree node, P p)109 R visitUnary(UnaryTree node, P p); visitVariable(VariableTree node, P p)110 R visitVariable(VariableTree node, P p); visitWhileLoop(WhileLoopTree node, P p)111 R visitWhileLoop(WhileLoopTree node, P p); visitWildcard(WildcardTree node, P p)112 R visitWildcard(WildcardTree node, P p); visitOther(Tree node, P p)113 R visitOther(Tree node, P p); 114 } 115