author | jjg |
Wed, 23 Jan 2013 13:27:24 -0800 | |
changeset 15385 | ee1eebe7e210 |
parent 14725 | 65836e833f59 |
child 16303 | b5dca0b42963 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15385 | 2 |
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.source.util; |
|
27 |
||
28 |
import com.sun.source.tree.*; |
|
29 |
||
30 |
/** |
|
31 |
* A simple visitor for tree nodes. |
|
32 |
* |
|
33 |
* @author Peter von der Ahé |
|
34 |
* @since 1.6 |
|
35 |
*/ |
|
36 |
public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> { |
|
37 |
protected final R DEFAULT_VALUE; |
|
38 |
||
39 |
protected SimpleTreeVisitor() { |
|
40 |
DEFAULT_VALUE = null; |
|
41 |
} |
|
42 |
||
43 |
protected SimpleTreeVisitor(R defaultValue) { |
|
44 |
DEFAULT_VALUE = defaultValue; |
|
45 |
} |
|
46 |
||
47 |
protected R defaultAction(Tree node, P p) { |
|
48 |
return DEFAULT_VALUE; |
|
49 |
} |
|
50 |
||
51 |
public final R visit(Tree node, P p) { |
|
52 |
return (node == null) ? null : node.accept(this, p); |
|
53 |
} |
|
54 |
||
55 |
public final R visit(Iterable<? extends Tree> nodes, P p) { |
|
56 |
R r = null; |
|
57 |
if (nodes != null) |
|
58 |
for (Tree node : nodes) |
|
59 |
r = visit(node, p); |
|
60 |
return r; |
|
61 |
} |
|
62 |
||
63 |
public R visitCompilationUnit(CompilationUnitTree node, P p) { |
|
64 |
return defaultAction(node, p); |
|
65 |
} |
|
66 |
||
67 |
public R visitImport(ImportTree node, P p) { |
|
68 |
return defaultAction(node, p); |
|
69 |
} |
|
70 |
||
71 |
public R visitClass(ClassTree node, P p) { |
|
72 |
return defaultAction(node, p); |
|
73 |
} |
|
74 |
||
75 |
public R visitMethod(MethodTree node, P p) { |
|
76 |
return defaultAction(node, p); |
|
77 |
} |
|
78 |
||
79 |
public R visitVariable(VariableTree node, P p) { |
|
80 |
return defaultAction(node, p); |
|
81 |
} |
|
82 |
||
83 |
public R visitEmptyStatement(EmptyStatementTree node, P p) { |
|
84 |
return defaultAction(node, p); |
|
85 |
} |
|
86 |
||
87 |
public R visitBlock(BlockTree node, P p) { |
|
88 |
return defaultAction(node, p); |
|
89 |
} |
|
90 |
||
91 |
public R visitDoWhileLoop(DoWhileLoopTree node, P p) { |
|
92 |
return defaultAction(node, p); |
|
93 |
} |
|
94 |
||
95 |
public R visitWhileLoop(WhileLoopTree node, P p) { |
|
96 |
return defaultAction(node, p); |
|
97 |
} |
|
98 |
||
99 |
public R visitForLoop(ForLoopTree node, P p) { |
|
100 |
return defaultAction(node, p); |
|
101 |
} |
|
102 |
||
103 |
public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { |
|
104 |
return defaultAction(node, p); |
|
105 |
} |
|
106 |
||
107 |
public R visitLabeledStatement(LabeledStatementTree node, P p) { |
|
108 |
return defaultAction(node, p); |
|
109 |
} |
|
110 |
||
111 |
public R visitSwitch(SwitchTree node, P p) { |
|
112 |
return defaultAction(node, p); |
|
113 |
} |
|
114 |
||
115 |
public R visitCase(CaseTree node, P p) { |
|
116 |
return defaultAction(node, p); |
|
117 |
} |
|
118 |
||
119 |
public R visitSynchronized(SynchronizedTree node, P p) { |
|
120 |
return defaultAction(node, p); |
|
121 |
} |
|
122 |
||
123 |
public R visitTry(TryTree node, P p) { |
|
124 |
return defaultAction(node, p); |
|
125 |
} |
|
126 |
||
127 |
public R visitCatch(CatchTree node, P p) { |
|
128 |
return defaultAction(node, p); |
|
129 |
} |
|
130 |
||
131 |
public R visitConditionalExpression(ConditionalExpressionTree node, P p) { |
|
132 |
return defaultAction(node, p); |
|
133 |
} |
|
134 |
||
135 |
public R visitIf(IfTree node, P p) { |
|
136 |
return defaultAction(node, p); |
|
137 |
} |
|
138 |
||
139 |
public R visitExpressionStatement(ExpressionStatementTree node, P p) { |
|
140 |
return defaultAction(node, p); |
|
141 |
} |
|
142 |
||
143 |
public R visitBreak(BreakTree node, P p) { |
|
144 |
return defaultAction(node, p); |
|
145 |
} |
|
146 |
||
147 |
public R visitContinue(ContinueTree node, P p) { |
|
148 |
return defaultAction(node, p); |
|
149 |
} |
|
150 |
||
151 |
public R visitReturn(ReturnTree node, P p) { |
|
152 |
return defaultAction(node, p); |
|
153 |
} |
|
154 |
||
155 |
public R visitThrow(ThrowTree node, P p) { |
|
156 |
return defaultAction(node, p); |
|
157 |
} |
|
158 |
||
159 |
public R visitAssert(AssertTree node, P p) { |
|
160 |
return defaultAction(node, p); |
|
161 |
} |
|
162 |
||
163 |
public R visitMethodInvocation(MethodInvocationTree node, P p) { |
|
164 |
return defaultAction(node, p); |
|
165 |
} |
|
166 |
||
167 |
public R visitNewClass(NewClassTree node, P p) { |
|
168 |
return defaultAction(node, p); |
|
169 |
} |
|
170 |
||
171 |
public R visitNewArray(NewArrayTree node, P p) { |
|
172 |
return defaultAction(node, p); |
|
173 |
} |
|
174 |
||
11141 | 175 |
public R visitLambdaExpression(LambdaExpressionTree node, P p) { |
176 |
return defaultAction(node, p); |
|
177 |
} |
|
178 |
||
10 | 179 |
public R visitParenthesized(ParenthesizedTree node, P p) { |
180 |
return defaultAction(node, p); |
|
181 |
} |
|
182 |
||
183 |
public R visitAssignment(AssignmentTree node, P p) { |
|
184 |
return defaultAction(node, p); |
|
185 |
} |
|
186 |
||
187 |
public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { |
|
188 |
return defaultAction(node, p); |
|
189 |
} |
|
190 |
||
191 |
public R visitUnary(UnaryTree node, P p) { |
|
192 |
return defaultAction(node, p); |
|
193 |
} |
|
194 |
||
195 |
public R visitBinary(BinaryTree node, P p) { |
|
196 |
return defaultAction(node, p); |
|
197 |
} |
|
198 |
||
199 |
public R visitTypeCast(TypeCastTree node, P p) { |
|
200 |
return defaultAction(node, p); |
|
201 |
} |
|
202 |
||
203 |
public R visitInstanceOf(InstanceOfTree node, P p) { |
|
204 |
return defaultAction(node, p); |
|
205 |
} |
|
206 |
||
207 |
public R visitArrayAccess(ArrayAccessTree node, P p) { |
|
208 |
return defaultAction(node, p); |
|
209 |
} |
|
210 |
||
211 |
public R visitMemberSelect(MemberSelectTree node, P p) { |
|
212 |
return defaultAction(node, p); |
|
213 |
} |
|
214 |
||
11142 | 215 |
public R visitMemberReference(MemberReferenceTree node, P p) { |
216 |
return defaultAction(node, p); |
|
217 |
} |
|
218 |
||
10 | 219 |
public R visitIdentifier(IdentifierTree node, P p) { |
220 |
return defaultAction(node, p); |
|
221 |
} |
|
222 |
||
223 |
public R visitLiteral(LiteralTree node, P p) { |
|
224 |
return defaultAction(node, p); |
|
225 |
} |
|
226 |
||
227 |
public R visitPrimitiveType(PrimitiveTypeTree node, P p) { |
|
228 |
return defaultAction(node, p); |
|
229 |
} |
|
230 |
||
231 |
public R visitArrayType(ArrayTypeTree node, P p) { |
|
232 |
return defaultAction(node, p); |
|
233 |
} |
|
234 |
||
235 |
public R visitParameterizedType(ParameterizedTypeTree node, P p) { |
|
236 |
return defaultAction(node, p); |
|
237 |
} |
|
238 |
||
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8031
diff
changeset
|
239 |
public R visitUnionType(UnionTypeTree node, P p) { |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
240 |
return defaultAction(node, p); |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
241 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
242 |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
243 |
public R visitIntersectionType(IntersectionTypeTree node, P p) { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
244 |
return defaultAction(node, p); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
245 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
246 |
|
10 | 247 |
public R visitTypeParameter(TypeParameterTree node, P p) { |
248 |
return defaultAction(node, p); |
|
249 |
} |
|
250 |
||
251 |
public R visitWildcard(WildcardTree node, P p) { |
|
252 |
return defaultAction(node, p); |
|
253 |
} |
|
254 |
||
255 |
public R visitModifiers(ModifiersTree node, P p) { |
|
256 |
return defaultAction(node, p); |
|
257 |
} |
|
258 |
||
259 |
public R visitAnnotation(AnnotationTree node, P p) { |
|
260 |
return defaultAction(node, p); |
|
261 |
} |
|
262 |
||
15385 | 263 |
public R visitAnnotatedType(AnnotatedTypeTree node, P p) { |
264 |
return defaultAction(node, p); |
|
265 |
} |
|
266 |
||
10 | 267 |
public R visitErroneous(ErroneousTree node, P p) { |
268 |
return defaultAction(node, p); |
|
269 |
} |
|
270 |
||
271 |
public R visitOther(Tree node, P p) { |
|
272 |
return defaultAction(node, p); |
|
273 |
} |
|
274 |
} |