author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 44878 | langtools/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java@9dd9cf7919ff |
child 51563 | de411d537aae |
permissions | -rw-r--r-- |
10 | 1 |
/* |
44878 | 2 |
* Copyright (c) 2005, 2017, 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.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 |
|
44878 | 33 |
* accept} method, the <code>visit<i>Xyz</i></code> method most applicable |
10 | 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 |
public interface TreeVisitor<R,P> { |
|
25287 | 60 |
/** |
61 |
* Visits an AnnotatedTypeTree node. |
|
62 |
* @param node the node being visited |
|
63 |
* @param p a parameter value |
|
64 |
* @return a result value |
|
65 |
*/ |
|
15385 | 66 |
R visitAnnotatedType(AnnotatedTypeTree node, P p); |
25287 | 67 |
|
68 |
/** |
|
69 |
* Visits an AnnotatedTree node. |
|
70 |
* @param node the node being visited |
|
71 |
* @param p a parameter value |
|
72 |
* @return a result value |
|
73 |
*/ |
|
10 | 74 |
R visitAnnotation(AnnotationTree node, P p); |
25287 | 75 |
|
76 |
/** |
|
77 |
* Visits a MethodInvocationTree node. |
|
78 |
* @param node the node being visited |
|
79 |
* @param p a parameter value |
|
80 |
* @return a result value |
|
81 |
*/ |
|
10 | 82 |
R visitMethodInvocation(MethodInvocationTree node, P p); |
25287 | 83 |
|
84 |
/** |
|
85 |
* Visits an AssertTree node. |
|
86 |
* @param node the node being visited |
|
87 |
* @param p a parameter value |
|
88 |
* @return a result value |
|
89 |
*/ |
|
10 | 90 |
R visitAssert(AssertTree node, P p); |
25287 | 91 |
|
92 |
/** |
|
93 |
* Visits an AssignmentTree node. |
|
94 |
* @param node the node being visited |
|
95 |
* @param p a parameter value |
|
96 |
* @return a result value |
|
97 |
*/ |
|
10 | 98 |
R visitAssignment(AssignmentTree node, P p); |
25287 | 99 |
|
100 |
/** |
|
101 |
* Visits a CompoundAssignmentTree node. |
|
102 |
* @param node the node being visited |
|
103 |
* @param p a parameter value |
|
104 |
* @return a result value |
|
105 |
*/ |
|
10 | 106 |
R visitCompoundAssignment(CompoundAssignmentTree node, P p); |
25287 | 107 |
|
108 |
/** |
|
109 |
* Visits a BinaryTree node. |
|
110 |
* @param node the node being visited |
|
111 |
* @param p a parameter value |
|
112 |
* @return a result value |
|
113 |
*/ |
|
10 | 114 |
R visitBinary(BinaryTree node, P p); |
25287 | 115 |
|
116 |
/** |
|
117 |
* Visits a BlockTree node. |
|
118 |
* @param node the node being visited |
|
119 |
* @param p a parameter value |
|
120 |
* @return a result value |
|
121 |
*/ |
|
10 | 122 |
R visitBlock(BlockTree node, P p); |
25287 | 123 |
|
124 |
/** |
|
125 |
* Visits a BreakTree node. |
|
126 |
* @param node the node being visited |
|
127 |
* @param p a parameter value |
|
128 |
* @return a result value |
|
129 |
*/ |
|
10 | 130 |
R visitBreak(BreakTree node, P p); |
25287 | 131 |
|
132 |
/** |
|
133 |
* Visits a CaseTree node. |
|
134 |
* @param node the node being visited |
|
135 |
* @param p a parameter value |
|
136 |
* @return a result value |
|
137 |
*/ |
|
10 | 138 |
R visitCase(CaseTree node, P p); |
25287 | 139 |
|
140 |
/** |
|
141 |
* Visits a CatchTree node. |
|
142 |
* @param node the node being visited |
|
143 |
* @param p a parameter value |
|
144 |
* @return a result value |
|
145 |
*/ |
|
10 | 146 |
R visitCatch(CatchTree node, P p); |
25287 | 147 |
|
148 |
/** |
|
149 |
* Visits a ClassTree node. |
|
150 |
* @param node the node being visited |
|
151 |
* @param p a parameter value |
|
152 |
* @return a result value |
|
153 |
*/ |
|
10 | 154 |
R visitClass(ClassTree node, P p); |
25287 | 155 |
|
156 |
/** |
|
157 |
* Visits a ConditionalExpressionTree node. |
|
158 |
* @param node the node being visited |
|
159 |
* @param p a parameter value |
|
160 |
* @return a result value |
|
161 |
*/ |
|
10 | 162 |
R visitConditionalExpression(ConditionalExpressionTree node, P p); |
25287 | 163 |
|
164 |
/** |
|
165 |
* Visits a ContinueTree node. |
|
166 |
* @param node the node being visited |
|
167 |
* @param p a parameter value |
|
168 |
* @return a result value |
|
169 |
*/ |
|
10 | 170 |
R visitContinue(ContinueTree node, P p); |
25287 | 171 |
|
172 |
/** |
|
173 |
* Visits a DoWhileTree node. |
|
174 |
* @param node the node being visited |
|
175 |
* @param p a parameter value |
|
176 |
* @return a result value |
|
177 |
*/ |
|
10 | 178 |
R visitDoWhileLoop(DoWhileLoopTree node, P p); |
25287 | 179 |
|
180 |
/** |
|
181 |
* Visits an ErroneousTree node. |
|
182 |
* @param node the node being visited |
|
183 |
* @param p a parameter value |
|
184 |
* @return a result value |
|
185 |
*/ |
|
10 | 186 |
R visitErroneous(ErroneousTree node, P p); |
25287 | 187 |
|
188 |
/** |
|
189 |
* Visits an ExpressionStatementTree node. |
|
190 |
* @param node the node being visited |
|
191 |
* @param p a parameter value |
|
192 |
* @return a result value |
|
193 |
*/ |
|
10 | 194 |
R visitExpressionStatement(ExpressionStatementTree node, P p); |
25287 | 195 |
|
196 |
/** |
|
197 |
* Visits an EnhancedForLoopTree node. |
|
198 |
* @param node the node being visited |
|
199 |
* @param p a parameter value |
|
200 |
* @return a result value |
|
201 |
*/ |
|
10 | 202 |
R visitEnhancedForLoop(EnhancedForLoopTree node, P p); |
25287 | 203 |
|
204 |
/** |
|
205 |
* Visits a ForLoopTree node. |
|
206 |
* @param node the node being visited |
|
207 |
* @param p a parameter value |
|
208 |
* @return a result value |
|
209 |
*/ |
|
10 | 210 |
R visitForLoop(ForLoopTree node, P p); |
25287 | 211 |
|
212 |
/** |
|
213 |
* Visits an IdentifierTree node. |
|
214 |
* @param node the node being visited |
|
215 |
* @param p a parameter value |
|
216 |
* @return a result value |
|
217 |
*/ |
|
10 | 218 |
R visitIdentifier(IdentifierTree node, P p); |
25287 | 219 |
|
220 |
/** |
|
221 |
* Visits an IfTree node. |
|
222 |
* @param node the node being visited |
|
223 |
* @param p a parameter value |
|
224 |
* @return a result value |
|
225 |
*/ |
|
10 | 226 |
R visitIf(IfTree node, P p); |
25287 | 227 |
|
228 |
/** |
|
229 |
* Visits an ImportTree node. |
|
230 |
* @param node the node being visited |
|
231 |
* @param p a parameter value |
|
232 |
* @return a result value |
|
233 |
*/ |
|
10 | 234 |
R visitImport(ImportTree node, P p); |
25287 | 235 |
|
236 |
/** |
|
237 |
* Visits an ArrayAccessTree node. |
|
238 |
* @param node the node being visited |
|
239 |
* @param p a parameter value |
|
240 |
* @return a result value |
|
241 |
*/ |
|
10 | 242 |
R visitArrayAccess(ArrayAccessTree node, P p); |
25287 | 243 |
|
244 |
/** |
|
245 |
* Visits a LabeledStatementTree node. |
|
246 |
* @param node the node being visited |
|
247 |
* @param p a parameter value |
|
248 |
* @return a result value |
|
249 |
*/ |
|
10 | 250 |
R visitLabeledStatement(LabeledStatementTree node, P p); |
25287 | 251 |
|
252 |
/** |
|
253 |
* Visits a LiteralTree node. |
|
254 |
* @param node the node being visited |
|
255 |
* @param p a parameter value |
|
256 |
* @return a result value |
|
257 |
*/ |
|
10 | 258 |
R visitLiteral(LiteralTree node, P p); |
25287 | 259 |
|
260 |
/** |
|
261 |
* Visits a MethodTree node. |
|
262 |
* @param node the node being visited |
|
263 |
* @param p a parameter value |
|
264 |
* @return a result value |
|
265 |
*/ |
|
10 | 266 |
R visitMethod(MethodTree node, P p); |
25287 | 267 |
|
268 |
/** |
|
269 |
* Visits a ModifiersTree node. |
|
270 |
* @param node the node being visited |
|
271 |
* @param p a parameter value |
|
272 |
* @return a result value |
|
273 |
*/ |
|
10 | 274 |
R visitModifiers(ModifiersTree node, P p); |
25287 | 275 |
|
276 |
/** |
|
277 |
* Visits a NewArrayTree node. |
|
278 |
* @param node the node being visited |
|
279 |
* @param p a parameter value |
|
280 |
* @return a result value |
|
281 |
*/ |
|
10 | 282 |
R visitNewArray(NewArrayTree node, P p); |
25287 | 283 |
|
284 |
/** |
|
285 |
* Visits a NewClassTree node. |
|
286 |
* @param node the node being visited |
|
287 |
* @param p a parameter value |
|
288 |
* @return a result value |
|
289 |
*/ |
|
10 | 290 |
R visitNewClass(NewClassTree node, P p); |
25287 | 291 |
|
292 |
/** |
|
293 |
* Visits a LambdaExpressionTree node. |
|
294 |
* @param node the node being visited |
|
295 |
* @param p a parameter value |
|
296 |
* @return a result value |
|
297 |
*/ |
|
11141 | 298 |
R visitLambdaExpression(LambdaExpressionTree node, P p); |
25287 | 299 |
|
300 |
/** |
|
301 |
* Visits a PackageTree node. |
|
302 |
* @param node the node being visited |
|
303 |
* @param p a parameter value |
|
304 |
* @return a result value |
|
305 |
*/ |
|
24069 | 306 |
R visitPackage(PackageTree node, P p); |
25287 | 307 |
|
308 |
/** |
|
309 |
* Visits a ParenthesizedTree node. |
|
310 |
* @param node the node being visited |
|
311 |
* @param p a parameter value |
|
312 |
* @return a result value |
|
313 |
*/ |
|
10 | 314 |
R visitParenthesized(ParenthesizedTree node, P p); |
25287 | 315 |
|
316 |
/** |
|
317 |
* Visits a ReturnTree node. |
|
318 |
* @param node the node being visited |
|
319 |
* @param p a parameter value |
|
320 |
* @return a result value |
|
321 |
*/ |
|
10 | 322 |
R visitReturn(ReturnTree node, P p); |
25287 | 323 |
|
324 |
/** |
|
325 |
* Visits a MemberSelectTree node. |
|
326 |
* @param node the node being visited |
|
327 |
* @param p a parameter value |
|
328 |
* @return a result value |
|
329 |
*/ |
|
10 | 330 |
R visitMemberSelect(MemberSelectTree node, P p); |
25287 | 331 |
|
332 |
/** |
|
333 |
* Visits a MemberReferenceTree node. |
|
334 |
* @param node the node being visited |
|
335 |
* @param p a parameter value |
|
336 |
* @return a result value |
|
337 |
*/ |
|
11142 | 338 |
R visitMemberReference(MemberReferenceTree node, P p); |
25287 | 339 |
|
340 |
/** |
|
341 |
* Visits an EmptyStatementTree node. |
|
342 |
* @param node the node being visited |
|
343 |
* @param p a parameter value |
|
344 |
* @return a result value |
|
345 |
*/ |
|
10 | 346 |
R visitEmptyStatement(EmptyStatementTree node, P p); |
25287 | 347 |
|
348 |
/** |
|
349 |
* Visits a SwitchTree node. |
|
350 |
* @param node the node being visited |
|
351 |
* @param p a parameter value |
|
352 |
* @return a result value |
|
353 |
*/ |
|
10 | 354 |
R visitSwitch(SwitchTree node, P p); |
25287 | 355 |
|
356 |
/** |
|
357 |
* Visits a SynchronizedTree node. |
|
358 |
* @param node the node being visited |
|
359 |
* @param p a parameter value |
|
360 |
* @return a result value |
|
361 |
*/ |
|
10 | 362 |
R visitSynchronized(SynchronizedTree node, P p); |
25287 | 363 |
|
364 |
/** |
|
365 |
* Visits a ThrowTree node. |
|
366 |
* @param node the node being visited |
|
367 |
* @param p a parameter value |
|
368 |
* @return a result value |
|
369 |
*/ |
|
10 | 370 |
R visitThrow(ThrowTree node, P p); |
25287 | 371 |
|
372 |
/** |
|
373 |
* Visits a CompilationUnitTree node. |
|
374 |
* @param node the node being visited |
|
375 |
* @param p a parameter value |
|
376 |
* @return a result value |
|
377 |
*/ |
|
10 | 378 |
R visitCompilationUnit(CompilationUnitTree node, P p); |
25287 | 379 |
|
380 |
/** |
|
381 |
* Visits a TryTree node. |
|
382 |
* @param node the node being visited |
|
383 |
* @param p a parameter value |
|
384 |
* @return a result value |
|
385 |
*/ |
|
10 | 386 |
R visitTry(TryTree node, P p); |
25287 | 387 |
|
388 |
/** |
|
389 |
* Visits a ParameterizedTypeTree node. |
|
390 |
* @param node the node being visited |
|
391 |
* @param p a parameter value |
|
392 |
* @return a result value |
|
393 |
*/ |
|
10 | 394 |
R visitParameterizedType(ParameterizedTypeTree node, P p); |
25287 | 395 |
|
396 |
/** |
|
397 |
* Visits a UnionTypeTree node. |
|
398 |
* @param node the node being visited |
|
399 |
* @param p a parameter value |
|
400 |
* @return a result value |
|
401 |
*/ |
|
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8031
diff
changeset
|
402 |
R visitUnionType(UnionTypeTree node, P p); |
25287 | 403 |
|
404 |
/** |
|
405 |
* Visits an IntersectionTypeTree node. |
|
406 |
* @param node the node being visited |
|
407 |
* @param p a parameter value |
|
408 |
* @return a result value |
|
409 |
*/ |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
410 |
R visitIntersectionType(IntersectionTypeTree node, P p); |
25287 | 411 |
|
412 |
/** |
|
413 |
* Visits an ArrayTypeTree node. |
|
414 |
* @param node the node being visited |
|
415 |
* @param p a parameter value |
|
416 |
* @return a result value |
|
417 |
*/ |
|
10 | 418 |
R visitArrayType(ArrayTypeTree node, P p); |
25287 | 419 |
|
420 |
/** |
|
421 |
* Visits a TypeCastTree node. |
|
422 |
* @param node the node being visited |
|
423 |
* @param p a parameter value |
|
424 |
* @return a result value |
|
425 |
*/ |
|
10 | 426 |
R visitTypeCast(TypeCastTree node, P p); |
25287 | 427 |
|
428 |
/** |
|
429 |
* Visits a PrimitiveTypeTree node. |
|
430 |
* @param node the node being visited |
|
431 |
* @param p a parameter value |
|
432 |
* @return a result value |
|
433 |
*/ |
|
10 | 434 |
R visitPrimitiveType(PrimitiveTypeTree node, P p); |
25287 | 435 |
|
436 |
/** |
|
437 |
* Visits a TypeParameterTree node. |
|
438 |
* @param node the node being visited |
|
439 |
* @param p a parameter value |
|
440 |
* @return a result value |
|
441 |
*/ |
|
10 | 442 |
R visitTypeParameter(TypeParameterTree node, P p); |
25287 | 443 |
|
444 |
/** |
|
445 |
* Visits an InstanceOfTree node. |
|
446 |
* @param node the node being visited |
|
447 |
* @param p a parameter value |
|
448 |
* @return a result value |
|
449 |
*/ |
|
10 | 450 |
R visitInstanceOf(InstanceOfTree node, P p); |
25287 | 451 |
|
452 |
/** |
|
453 |
* Visits a UnaryTree node. |
|
454 |
* @param node the node being visited |
|
455 |
* @param p a parameter value |
|
456 |
* @return a result value |
|
457 |
*/ |
|
10 | 458 |
R visitUnary(UnaryTree node, P p); |
25287 | 459 |
|
460 |
/** |
|
461 |
* Visits a VariableTree node. |
|
462 |
* @param node the node being visited |
|
463 |
* @param p a parameter value |
|
464 |
* @return a result value |
|
465 |
*/ |
|
10 | 466 |
R visitVariable(VariableTree node, P p); |
25287 | 467 |
|
468 |
/** |
|
469 |
* Visits a WhileLoopTree node. |
|
470 |
* @param node the node being visited |
|
471 |
* @param p a parameter value |
|
472 |
* @return a result value |
|
473 |
*/ |
|
10 | 474 |
R visitWhileLoop(WhileLoopTree node, P p); |
25287 | 475 |
|
476 |
/** |
|
477 |
* Visits a WildcardTypeTree node. |
|
478 |
* @param node the node being visited |
|
479 |
* @param p a parameter value |
|
480 |
* @return a result value |
|
481 |
*/ |
|
10 | 482 |
R visitWildcard(WildcardTree node, P p); |
25287 | 483 |
|
484 |
/** |
|
36526 | 485 |
* Visits a ModuleTree node. |
486 |
* @param node the node being visited |
|
487 |
* @param p a parameter value |
|
488 |
* @return a result value |
|
489 |
*/ |
|
490 |
R visitModule(ModuleTree node, P p); |
|
491 |
||
492 |
/** |
|
493 |
* Visits an ExportsTree node. |
|
494 |
* @param node the node being visited |
|
495 |
* @param p a parameter value |
|
496 |
* @return a result value |
|
497 |
*/ |
|
498 |
R visitExports(ExportsTree node, P p); |
|
499 |
||
500 |
/** |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
501 |
* Visits an OpensTree node. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
502 |
* @param node the node being visited |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
503 |
* @param p a parameter value |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
504 |
* @return a result value |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
505 |
*/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
506 |
R visitOpens(OpensTree node, P p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
507 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
508 |
/** |
36526 | 509 |
* Visits a ProvidesTree node. |
510 |
* @param node the node being visited |
|
511 |
* @param p a parameter value |
|
512 |
* @return a result value |
|
513 |
*/ |
|
514 |
R visitProvides(ProvidesTree node, P p); |
|
515 |
||
516 |
/** |
|
517 |
* Visits a RequiresTree node. |
|
518 |
* @param node the node being visited |
|
519 |
* @param p a parameter value |
|
520 |
* @return a result value |
|
521 |
*/ |
|
522 |
R visitRequires(RequiresTree node, P p); |
|
523 |
||
524 |
/** |
|
525 |
* Visits a UsesTree node. |
|
526 |
* @param node the node being visited |
|
527 |
* @param p a parameter value |
|
528 |
* @return a result value |
|
529 |
*/ |
|
530 |
R visitUses(UsesTree node, P p); |
|
531 |
||
532 |
/** |
|
25287 | 533 |
* Visits an unknown type of Tree node. |
534 |
* This can occur if the language evolves and new kinds |
|
535 |
* of nodes are added to the {@code Tree} hierarchy. |
|
536 |
* @param node the node being visited |
|
537 |
* @param p a parameter value |
|
538 |
* @return a result value |
|
539 |
*/ |
|
10 | 540 |
R visitOther(Tree node, P p); |
541 |
} |