Fri, 04 Oct 2013 10:00:28 -0700
8025913: Rename jdk.Supported to jdk.Exported
Reviewed-by: psandoz, forax, lancea, alanb, mchung, jjg
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.tree;
28 /**
29 * Common interface for all nodes in an abstract syntax tree.
30 *
31 * <p><b>WARNING:</b> This interface and its sub-interfaces are
32 * subject to change as the Java™ programming language evolves.
33 * These interfaces are implemented by the JDK Java compiler (javac)
34 * and should not be implemented either directly or indirectly by
35 * other applications.
36 *
37 * @author Peter von der Ahé
38 * @author Jonathan Gibbons
39 *
40 * @since 1.6
41 */
42 @jdk.Exported
43 public interface Tree {
45 /**
46 * Enumerates all kinds of trees.
47 */
48 @jdk.Exported
49 public enum Kind {
51 ANNOTATED_TYPE(AnnotatedTypeTree.class),
53 /**
54 * Used for instances of {@link AnnotationTree}
55 * representing declaration annotations.
56 */
57 ANNOTATION(AnnotationTree.class),
59 /**
60 * Used for instances of {@link AnnotationTree}
61 * representing type annotations.
62 */
63 TYPE_ANNOTATION(AnnotationTree.class),
65 /**
66 * Used for instances of {@link ArrayAccessTree}.
67 */
68 ARRAY_ACCESS(ArrayAccessTree.class),
70 /**
71 * Used for instances of {@link ArrayTypeTree}.
72 */
73 ARRAY_TYPE(ArrayTypeTree.class),
75 /**
76 * Used for instances of {@link AssertTree}.
77 */
78 ASSERT(AssertTree.class),
80 /**
81 * Used for instances of {@link AssignmentTree}.
82 */
83 ASSIGNMENT(AssignmentTree.class),
85 /**
86 * Used for instances of {@link BlockTree}.
87 */
88 BLOCK(BlockTree.class),
90 /**
91 * Used for instances of {@link BreakTree}.
92 */
93 BREAK(BreakTree.class),
95 /**
96 * Used for instances of {@link CaseTree}.
97 */
98 CASE(CaseTree.class),
100 /**
101 * Used for instances of {@link CatchTree}.
102 */
103 CATCH(CatchTree.class),
105 /**
106 * Used for instances of {@link ClassTree} representing classes.
107 */
108 CLASS(ClassTree.class),
110 /**
111 * Used for instances of {@link CompilationUnitTree}.
112 */
113 COMPILATION_UNIT(CompilationUnitTree.class),
115 /**
116 * Used for instances of {@link ConditionalExpressionTree}.
117 */
118 CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class),
120 /**
121 * Used for instances of {@link ContinueTree}.
122 */
123 CONTINUE(ContinueTree.class),
125 /**
126 * Used for instances of {@link DoWhileLoopTree}.
127 */
128 DO_WHILE_LOOP(DoWhileLoopTree.class),
130 /**
131 * Used for instances of {@link EnhancedForLoopTree}.
132 */
133 ENHANCED_FOR_LOOP(EnhancedForLoopTree.class),
135 /**
136 * Used for instances of {@link ExpressionStatementTree}.
137 */
138 EXPRESSION_STATEMENT(ExpressionStatementTree.class),
140 /**
141 * Used for instances of {@link MemberSelectTree}.
142 */
143 MEMBER_SELECT(MemberSelectTree.class),
145 /**
146 * Used for instances of {@link MemberReferenceTree}.
147 */
148 MEMBER_REFERENCE(MemberReferenceTree.class),
150 /**
151 * Used for instances of {@link ForLoopTree}.
152 */
153 FOR_LOOP(ForLoopTree.class),
155 /**
156 * Used for instances of {@link IdentifierTree}.
157 */
158 IDENTIFIER(IdentifierTree.class),
160 /**
161 * Used for instances of {@link IfTree}.
162 */
163 IF(IfTree.class),
165 /**
166 * Used for instances of {@link ImportTree}.
167 */
168 IMPORT(ImportTree.class),
170 /**
171 * Used for instances of {@link InstanceOfTree}.
172 */
173 INSTANCE_OF(InstanceOfTree.class),
175 /**
176 * Used for instances of {@link LabeledStatementTree}.
177 */
178 LABELED_STATEMENT(LabeledStatementTree.class),
180 /**
181 * Used for instances of {@link MethodTree}.
182 */
183 METHOD(MethodTree.class),
185 /**
186 * Used for instances of {@link MethodInvocationTree}.
187 */
188 METHOD_INVOCATION(MethodInvocationTree.class),
190 /**
191 * Used for instances of {@link ModifiersTree}.
192 */
193 MODIFIERS(ModifiersTree.class),
195 /**
196 * Used for instances of {@link NewArrayTree}.
197 */
198 NEW_ARRAY(NewArrayTree.class),
200 /**
201 * Used for instances of {@link NewClassTree}.
202 */
203 NEW_CLASS(NewClassTree.class),
205 /**
206 * Used for instances of {@link LambdaExpressionTree}.
207 */
208 LAMBDA_EXPRESSION(LambdaExpressionTree.class),
210 /**
211 * Used for instances of {@link ParenthesizedTree}.
212 */
213 PARENTHESIZED(ParenthesizedTree.class),
215 /**
216 * Used for instances of {@link PrimitiveTypeTree}.
217 */
218 PRIMITIVE_TYPE(PrimitiveTypeTree.class),
220 /**
221 * Used for instances of {@link ReturnTree}.
222 */
223 RETURN(ReturnTree.class),
225 /**
226 * Used for instances of {@link EmptyStatementTree}.
227 */
228 EMPTY_STATEMENT(EmptyStatementTree.class),
230 /**
231 * Used for instances of {@link SwitchTree}.
232 */
233 SWITCH(SwitchTree.class),
235 /**
236 * Used for instances of {@link SynchronizedTree}.
237 */
238 SYNCHRONIZED(SynchronizedTree.class),
240 /**
241 * Used for instances of {@link ThrowTree}.
242 */
243 THROW(ThrowTree.class),
245 /**
246 * Used for instances of {@link TryTree}.
247 */
248 TRY(TryTree.class),
250 /**
251 * Used for instances of {@link ParameterizedTypeTree}.
252 */
253 PARAMETERIZED_TYPE(ParameterizedTypeTree.class),
255 /**
256 * Used for instances of {@link UnionTypeTree}.
257 */
258 UNION_TYPE(UnionTypeTree.class),
260 /**
261 * Used for instances of {@link IntersectionTypeTree}.
262 */
263 INTERSECTION_TYPE(IntersectionTypeTree.class),
265 /**
266 * Used for instances of {@link TypeCastTree}.
267 */
268 TYPE_CAST(TypeCastTree.class),
270 /**
271 * Used for instances of {@link TypeParameterTree}.
272 */
273 TYPE_PARAMETER(TypeParameterTree.class),
275 /**
276 * Used for instances of {@link VariableTree}.
277 */
278 VARIABLE(VariableTree.class),
280 /**
281 * Used for instances of {@link WhileLoopTree}.
282 */
283 WHILE_LOOP(WhileLoopTree.class),
285 /**
286 * Used for instances of {@link UnaryTree} representing postfix
287 * increment operator {@code ++}.
288 */
289 POSTFIX_INCREMENT(UnaryTree.class),
291 /**
292 * Used for instances of {@link UnaryTree} representing postfix
293 * decrement operator {@code --}.
294 */
295 POSTFIX_DECREMENT(UnaryTree.class),
297 /**
298 * Used for instances of {@link UnaryTree} representing prefix
299 * increment operator {@code ++}.
300 */
301 PREFIX_INCREMENT(UnaryTree.class),
303 /**
304 * Used for instances of {@link UnaryTree} representing prefix
305 * decrement operator {@code --}.
306 */
307 PREFIX_DECREMENT(UnaryTree.class),
309 /**
310 * Used for instances of {@link UnaryTree} representing unary plus
311 * operator {@code +}.
312 */
313 UNARY_PLUS(UnaryTree.class),
315 /**
316 * Used for instances of {@link UnaryTree} representing unary minus
317 * operator {@code -}.
318 */
319 UNARY_MINUS(UnaryTree.class),
321 /**
322 * Used for instances of {@link UnaryTree} representing bitwise
323 * complement operator {@code ~}.
324 */
325 BITWISE_COMPLEMENT(UnaryTree.class),
327 /**
328 * Used for instances of {@link UnaryTree} representing logical
329 * complement operator {@code !}.
330 */
331 LOGICAL_COMPLEMENT(UnaryTree.class),
333 /**
334 * Used for instances of {@link BinaryTree} representing
335 * multiplication {@code *}.
336 */
337 MULTIPLY(BinaryTree.class),
339 /**
340 * Used for instances of {@link BinaryTree} representing
341 * division {@code /}.
342 */
343 DIVIDE(BinaryTree.class),
345 /**
346 * Used for instances of {@link BinaryTree} representing
347 * remainder {@code %}.
348 */
349 REMAINDER(BinaryTree.class),
351 /**
352 * Used for instances of {@link BinaryTree} representing
353 * addition or string concatenation {@code +}.
354 */
355 PLUS(BinaryTree.class),
357 /**
358 * Used for instances of {@link BinaryTree} representing
359 * subtraction {@code -}.
360 */
361 MINUS(BinaryTree.class),
363 /**
364 * Used for instances of {@link BinaryTree} representing
365 * left shift {@code <<}.
366 */
367 LEFT_SHIFT(BinaryTree.class),
369 /**
370 * Used for instances of {@link BinaryTree} representing
371 * right shift {@code >>}.
372 */
373 RIGHT_SHIFT(BinaryTree.class),
375 /**
376 * Used for instances of {@link BinaryTree} representing
377 * unsigned right shift {@code >>>}.
378 */
379 UNSIGNED_RIGHT_SHIFT(BinaryTree.class),
381 /**
382 * Used for instances of {@link BinaryTree} representing
383 * less-than {@code <}.
384 */
385 LESS_THAN(BinaryTree.class),
387 /**
388 * Used for instances of {@link BinaryTree} representing
389 * greater-than {@code >}.
390 */
391 GREATER_THAN(BinaryTree.class),
393 /**
394 * Used for instances of {@link BinaryTree} representing
395 * less-than-equal {@code <=}.
396 */
397 LESS_THAN_EQUAL(BinaryTree.class),
399 /**
400 * Used for instances of {@link BinaryTree} representing
401 * greater-than-equal {@code >=}.
402 */
403 GREATER_THAN_EQUAL(BinaryTree.class),
405 /**
406 * Used for instances of {@link BinaryTree} representing
407 * equal-to {@code ==}.
408 */
409 EQUAL_TO(BinaryTree.class),
411 /**
412 * Used for instances of {@link BinaryTree} representing
413 * not-equal-to {@code !=}.
414 */
415 NOT_EQUAL_TO(BinaryTree.class),
417 /**
418 * Used for instances of {@link BinaryTree} representing
419 * bitwise and logical "and" {@code &}.
420 */
421 AND(BinaryTree.class),
423 /**
424 * Used for instances of {@link BinaryTree} representing
425 * bitwise and logical "xor" {@code ^}.
426 */
427 XOR(BinaryTree.class),
429 /**
430 * Used for instances of {@link BinaryTree} representing
431 * bitwise and logical "or" {@code |}.
432 */
433 OR(BinaryTree.class),
435 /**
436 * Used for instances of {@link BinaryTree} representing
437 * conditional-and {@code &&}.
438 */
439 CONDITIONAL_AND(BinaryTree.class),
441 /**
442 * Used for instances of {@link BinaryTree} representing
443 * conditional-or {@code ||}.
444 */
445 CONDITIONAL_OR(BinaryTree.class),
447 /**
448 * Used for instances of {@link CompoundAssignmentTree} representing
449 * multiplication assignment {@code *=}.
450 */
451 MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class),
453 /**
454 * Used for instances of {@link CompoundAssignmentTree} representing
455 * division assignment {@code /=}.
456 */
457 DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class),
459 /**
460 * Used for instances of {@link CompoundAssignmentTree} representing
461 * remainder assignment {@code %=}.
462 */
463 REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class),
465 /**
466 * Used for instances of {@link CompoundAssignmentTree} representing
467 * addition or string concatenation assignment {@code +=}.
468 */
469 PLUS_ASSIGNMENT(CompoundAssignmentTree.class),
471 /**
472 * Used for instances of {@link CompoundAssignmentTree} representing
473 * subtraction assignment {@code -=}.
474 */
475 MINUS_ASSIGNMENT(CompoundAssignmentTree.class),
477 /**
478 * Used for instances of {@link CompoundAssignmentTree} representing
479 * left shift assignment {@code <<=}.
480 */
481 LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
483 /**
484 * Used for instances of {@link CompoundAssignmentTree} representing
485 * right shift assignment {@code >>=}.
486 */
487 RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
489 /**
490 * Used for instances of {@link CompoundAssignmentTree} representing
491 * unsigned right shift assignment {@code >>>=}.
492 */
493 UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
495 /**
496 * Used for instances of {@link CompoundAssignmentTree} representing
497 * bitwise and logical "and" assignment {@code &=}.
498 */
499 AND_ASSIGNMENT(CompoundAssignmentTree.class),
501 /**
502 * Used for instances of {@link CompoundAssignmentTree} representing
503 * bitwise and logical "xor" assignment {@code ^=}.
504 */
505 XOR_ASSIGNMENT(CompoundAssignmentTree.class),
507 /**
508 * Used for instances of {@link CompoundAssignmentTree} representing
509 * bitwise and logical "or" assignment {@code |=}.
510 */
511 OR_ASSIGNMENT(CompoundAssignmentTree.class),
513 /**
514 * Used for instances of {@link LiteralTree} representing
515 * an integral literal expression of type {@code int}.
516 */
517 INT_LITERAL(LiteralTree.class),
519 /**
520 * Used for instances of {@link LiteralTree} representing
521 * an integral literal expression of type {@code long}.
522 */
523 LONG_LITERAL(LiteralTree.class),
525 /**
526 * Used for instances of {@link LiteralTree} representing
527 * a floating-point literal expression of type {@code float}.
528 */
529 FLOAT_LITERAL(LiteralTree.class),
531 /**
532 * Used for instances of {@link LiteralTree} representing
533 * a floating-point literal expression of type {@code double}.
534 */
535 DOUBLE_LITERAL(LiteralTree.class),
537 /**
538 * Used for instances of {@link LiteralTree} representing
539 * a boolean literal expression of type {@code boolean}.
540 */
541 BOOLEAN_LITERAL(LiteralTree.class),
543 /**
544 * Used for instances of {@link LiteralTree} representing
545 * a character literal expression of type {@code char}.
546 */
547 CHAR_LITERAL(LiteralTree.class),
549 /**
550 * Used for instances of {@link LiteralTree} representing
551 * a string literal expression of type {@link String}.
552 */
553 STRING_LITERAL(LiteralTree.class),
555 /**
556 * Used for instances of {@link LiteralTree} representing
557 * the use of {@code null}.
558 */
559 NULL_LITERAL(LiteralTree.class),
561 /**
562 * Used for instances of {@link WildcardTree} representing
563 * an unbounded wildcard type argument.
564 */
565 UNBOUNDED_WILDCARD(WildcardTree.class),
567 /**
568 * Used for instances of {@link WildcardTree} representing
569 * an extends bounded wildcard type argument.
570 */
571 EXTENDS_WILDCARD(WildcardTree.class),
573 /**
574 * Used for instances of {@link WildcardTree} representing
575 * a super bounded wildcard type argument.
576 */
577 SUPER_WILDCARD(WildcardTree.class),
579 /**
580 * Used for instances of {@link ErroneousTree}.
581 */
582 ERRONEOUS(ErroneousTree.class),
584 /**
585 * Used for instances of {@link ClassTree} representing interfaces.
586 */
587 INTERFACE(ClassTree.class),
589 /**
590 * Used for instances of {@link ClassTree} representing enums.
591 */
592 ENUM(ClassTree.class),
594 /**
595 * Used for instances of {@link ClassTree} representing annotation types.
596 */
597 ANNOTATION_TYPE(ClassTree.class),
599 /**
600 * An implementation-reserved node. This is the not the node
601 * you are looking for.
602 */
603 OTHER(null);
606 Kind(Class<? extends Tree> intf) {
607 associatedInterface = intf;
608 }
610 public Class<? extends Tree> asInterface() {
611 return associatedInterface;
612 }
614 private final Class<? extends Tree> associatedInterface;
615 }
617 /**
618 * Gets the kind of this tree.
619 *
620 * @return the kind of this tree.
621 */
622 Kind getKind();
624 /**
625 * Accept method used to implement the visitor pattern. The
626 * visitor pattern is used to implement operations on trees.
627 *
628 * @param <R> result type of this operation.
629 * @param <D> type of additional data.
630 */
631 <R,D> R accept(TreeVisitor<R,D> visitor, D data);
632 }