1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/source/tree/TreeVisitor.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,108 @@ 1.4 +/* 1.5 + * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package com.sun.source.tree; 1.30 + 1.31 +/** 1.32 + * A visitor of trees, in the style of the visitor design pattern. 1.33 + * Classes implementing this interface are used to operate 1.34 + * on a tree when the kind of tree is unknown at compile time. 1.35 + * When a visitor is passed to an tree's {@link Tree#accept 1.36 + * accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable 1.37 + * to that tree is invoked. 1.38 + * 1.39 + * <p> Classes implementing this interface may or may not throw a 1.40 + * {@code NullPointerException} if the additional parameter {@code p} 1.41 + * is {@code null}; see documentation of the implementing class for 1.42 + * details. 1.43 + * 1.44 + * <p> <b>WARNING:</b> It is possible that methods will be added to 1.45 + * this interface to accommodate new, currently unknown, language 1.46 + * structures added to future versions of the Java™ programming 1.47 + * language. Therefore, visitor classes directly implementing this 1.48 + * interface may be source incompatible with future versions of the 1.49 + * platform. 1.50 + * 1.51 + * @param <R> the return type of this visitor's methods. Use {@link 1.52 + * Void} for visitors that do not need to return results. 1.53 + * @param <P> the type of the additional parameter to this visitor's 1.54 + * methods. Use {@code Void} for visitors that do not need an 1.55 + * additional parameter. 1.56 + * 1.57 + * @author Peter von der Ahé 1.58 + * @author Jonathan Gibbons 1.59 + * 1.60 + * @since 1.6 1.61 + */ 1.62 +public interface TreeVisitor<R,P> { 1.63 + R visitAnnotation(AnnotationTree node, P p); 1.64 + R visitMethodInvocation(MethodInvocationTree node, P p); 1.65 + R visitAssert(AssertTree node, P p); 1.66 + R visitAssignment(AssignmentTree node, P p); 1.67 + R visitCompoundAssignment(CompoundAssignmentTree node, P p); 1.68 + R visitBinary(BinaryTree node, P p); 1.69 + R visitBlock(BlockTree node, P p); 1.70 + R visitBreak(BreakTree node, P p); 1.71 + R visitCase(CaseTree node, P p); 1.72 + R visitCatch(CatchTree node, P p); 1.73 + R visitClass(ClassTree node, P p); 1.74 + R visitConditionalExpression(ConditionalExpressionTree node, P p); 1.75 + R visitContinue(ContinueTree node, P p); 1.76 + R visitDoWhileLoop(DoWhileLoopTree node, P p); 1.77 + R visitErroneous(ErroneousTree node, P p); 1.78 + R visitExpressionStatement(ExpressionStatementTree node, P p); 1.79 + R visitEnhancedForLoop(EnhancedForLoopTree node, P p); 1.80 + R visitForLoop(ForLoopTree node, P p); 1.81 + R visitIdentifier(IdentifierTree node, P p); 1.82 + R visitIf(IfTree node, P p); 1.83 + R visitImport(ImportTree node, P p); 1.84 + R visitArrayAccess(ArrayAccessTree node, P p); 1.85 + R visitLabeledStatement(LabeledStatementTree node, P p); 1.86 + R visitLiteral(LiteralTree node, P p); 1.87 + R visitMethod(MethodTree node, P p); 1.88 + R visitModifiers(ModifiersTree node, P p); 1.89 + R visitNewArray(NewArrayTree node, P p); 1.90 + R visitNewClass(NewClassTree node, P p); 1.91 + R visitParenthesized(ParenthesizedTree node, P p); 1.92 + R visitReturn(ReturnTree node, P p); 1.93 + R visitMemberSelect(MemberSelectTree node, P p); 1.94 + R visitEmptyStatement(EmptyStatementTree node, P p); 1.95 + R visitSwitch(SwitchTree node, P p); 1.96 + R visitSynchronized(SynchronizedTree node, P p); 1.97 + R visitThrow(ThrowTree node, P p); 1.98 + R visitCompilationUnit(CompilationUnitTree node, P p); 1.99 + R visitTry(TryTree node, P p); 1.100 + R visitParameterizedType(ParameterizedTypeTree node, P p); 1.101 + R visitArrayType(ArrayTypeTree node, P p); 1.102 + R visitTypeCast(TypeCastTree node, P p); 1.103 + R visitPrimitiveType(PrimitiveTypeTree node, P p); 1.104 + R visitTypeParameter(TypeParameterTree node, P p); 1.105 + R visitInstanceOf(InstanceOfTree node, P p); 1.106 + R visitUnary(UnaryTree node, P p); 1.107 + R visitVariable(VariableTree node, P p); 1.108 + R visitWhileLoop(WhileLoopTree node, P p); 1.109 + R visitWildcard(WildcardTree node, P p); 1.110 + R visitOther(Tree node, P p); 1.111 +}