1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/source/tree/Tree.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,632 @@ 1.4 +/* 1.5 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. 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. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.source.tree; 1.30 + 1.31 +/** 1.32 + * Common interface for all nodes in an abstract syntax tree. 1.33 + * 1.34 + * <p><b>WARNING:</b> This interface and its sub-interfaces are 1.35 + * subject to change as the Java™ programming language evolves. 1.36 + * These interfaces are implemented by the JDK Java compiler (javac) 1.37 + * and should not be implemented either directly or indirectly by 1.38 + * other applications. 1.39 + * 1.40 + * @author Peter von der Ahé 1.41 + * @author Jonathan Gibbons 1.42 + * 1.43 + * @since 1.6 1.44 + */ 1.45 +@jdk.Exported 1.46 +public interface Tree { 1.47 + 1.48 + /** 1.49 + * Enumerates all kinds of trees. 1.50 + */ 1.51 + @jdk.Exported 1.52 + public enum Kind { 1.53 + 1.54 + ANNOTATED_TYPE(AnnotatedTypeTree.class), 1.55 + 1.56 + /** 1.57 + * Used for instances of {@link AnnotationTree} 1.58 + * representing declaration annotations. 1.59 + */ 1.60 + ANNOTATION(AnnotationTree.class), 1.61 + 1.62 + /** 1.63 + * Used for instances of {@link AnnotationTree} 1.64 + * representing type annotations. 1.65 + */ 1.66 + TYPE_ANNOTATION(AnnotationTree.class), 1.67 + 1.68 + /** 1.69 + * Used for instances of {@link ArrayAccessTree}. 1.70 + */ 1.71 + ARRAY_ACCESS(ArrayAccessTree.class), 1.72 + 1.73 + /** 1.74 + * Used for instances of {@link ArrayTypeTree}. 1.75 + */ 1.76 + ARRAY_TYPE(ArrayTypeTree.class), 1.77 + 1.78 + /** 1.79 + * Used for instances of {@link AssertTree}. 1.80 + */ 1.81 + ASSERT(AssertTree.class), 1.82 + 1.83 + /** 1.84 + * Used for instances of {@link AssignmentTree}. 1.85 + */ 1.86 + ASSIGNMENT(AssignmentTree.class), 1.87 + 1.88 + /** 1.89 + * Used for instances of {@link BlockTree}. 1.90 + */ 1.91 + BLOCK(BlockTree.class), 1.92 + 1.93 + /** 1.94 + * Used for instances of {@link BreakTree}. 1.95 + */ 1.96 + BREAK(BreakTree.class), 1.97 + 1.98 + /** 1.99 + * Used for instances of {@link CaseTree}. 1.100 + */ 1.101 + CASE(CaseTree.class), 1.102 + 1.103 + /** 1.104 + * Used for instances of {@link CatchTree}. 1.105 + */ 1.106 + CATCH(CatchTree.class), 1.107 + 1.108 + /** 1.109 + * Used for instances of {@link ClassTree} representing classes. 1.110 + */ 1.111 + CLASS(ClassTree.class), 1.112 + 1.113 + /** 1.114 + * Used for instances of {@link CompilationUnitTree}. 1.115 + */ 1.116 + COMPILATION_UNIT(CompilationUnitTree.class), 1.117 + 1.118 + /** 1.119 + * Used for instances of {@link ConditionalExpressionTree}. 1.120 + */ 1.121 + CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class), 1.122 + 1.123 + /** 1.124 + * Used for instances of {@link ContinueTree}. 1.125 + */ 1.126 + CONTINUE(ContinueTree.class), 1.127 + 1.128 + /** 1.129 + * Used for instances of {@link DoWhileLoopTree}. 1.130 + */ 1.131 + DO_WHILE_LOOP(DoWhileLoopTree.class), 1.132 + 1.133 + /** 1.134 + * Used for instances of {@link EnhancedForLoopTree}. 1.135 + */ 1.136 + ENHANCED_FOR_LOOP(EnhancedForLoopTree.class), 1.137 + 1.138 + /** 1.139 + * Used for instances of {@link ExpressionStatementTree}. 1.140 + */ 1.141 + EXPRESSION_STATEMENT(ExpressionStatementTree.class), 1.142 + 1.143 + /** 1.144 + * Used for instances of {@link MemberSelectTree}. 1.145 + */ 1.146 + MEMBER_SELECT(MemberSelectTree.class), 1.147 + 1.148 + /** 1.149 + * Used for instances of {@link MemberReferenceTree}. 1.150 + */ 1.151 + MEMBER_REFERENCE(MemberReferenceTree.class), 1.152 + 1.153 + /** 1.154 + * Used for instances of {@link ForLoopTree}. 1.155 + */ 1.156 + FOR_LOOP(ForLoopTree.class), 1.157 + 1.158 + /** 1.159 + * Used for instances of {@link IdentifierTree}. 1.160 + */ 1.161 + IDENTIFIER(IdentifierTree.class), 1.162 + 1.163 + /** 1.164 + * Used for instances of {@link IfTree}. 1.165 + */ 1.166 + IF(IfTree.class), 1.167 + 1.168 + /** 1.169 + * Used for instances of {@link ImportTree}. 1.170 + */ 1.171 + IMPORT(ImportTree.class), 1.172 + 1.173 + /** 1.174 + * Used for instances of {@link InstanceOfTree}. 1.175 + */ 1.176 + INSTANCE_OF(InstanceOfTree.class), 1.177 + 1.178 + /** 1.179 + * Used for instances of {@link LabeledStatementTree}. 1.180 + */ 1.181 + LABELED_STATEMENT(LabeledStatementTree.class), 1.182 + 1.183 + /** 1.184 + * Used for instances of {@link MethodTree}. 1.185 + */ 1.186 + METHOD(MethodTree.class), 1.187 + 1.188 + /** 1.189 + * Used for instances of {@link MethodInvocationTree}. 1.190 + */ 1.191 + METHOD_INVOCATION(MethodInvocationTree.class), 1.192 + 1.193 + /** 1.194 + * Used for instances of {@link ModifiersTree}. 1.195 + */ 1.196 + MODIFIERS(ModifiersTree.class), 1.197 + 1.198 + /** 1.199 + * Used for instances of {@link NewArrayTree}. 1.200 + */ 1.201 + NEW_ARRAY(NewArrayTree.class), 1.202 + 1.203 + /** 1.204 + * Used for instances of {@link NewClassTree}. 1.205 + */ 1.206 + NEW_CLASS(NewClassTree.class), 1.207 + 1.208 + /** 1.209 + * Used for instances of {@link LambdaExpressionTree}. 1.210 + */ 1.211 + LAMBDA_EXPRESSION(LambdaExpressionTree.class), 1.212 + 1.213 + /** 1.214 + * Used for instances of {@link ParenthesizedTree}. 1.215 + */ 1.216 + PARENTHESIZED(ParenthesizedTree.class), 1.217 + 1.218 + /** 1.219 + * Used for instances of {@link PrimitiveTypeTree}. 1.220 + */ 1.221 + PRIMITIVE_TYPE(PrimitiveTypeTree.class), 1.222 + 1.223 + /** 1.224 + * Used for instances of {@link ReturnTree}. 1.225 + */ 1.226 + RETURN(ReturnTree.class), 1.227 + 1.228 + /** 1.229 + * Used for instances of {@link EmptyStatementTree}. 1.230 + */ 1.231 + EMPTY_STATEMENT(EmptyStatementTree.class), 1.232 + 1.233 + /** 1.234 + * Used for instances of {@link SwitchTree}. 1.235 + */ 1.236 + SWITCH(SwitchTree.class), 1.237 + 1.238 + /** 1.239 + * Used for instances of {@link SynchronizedTree}. 1.240 + */ 1.241 + SYNCHRONIZED(SynchronizedTree.class), 1.242 + 1.243 + /** 1.244 + * Used for instances of {@link ThrowTree}. 1.245 + */ 1.246 + THROW(ThrowTree.class), 1.247 + 1.248 + /** 1.249 + * Used for instances of {@link TryTree}. 1.250 + */ 1.251 + TRY(TryTree.class), 1.252 + 1.253 + /** 1.254 + * Used for instances of {@link ParameterizedTypeTree}. 1.255 + */ 1.256 + PARAMETERIZED_TYPE(ParameterizedTypeTree.class), 1.257 + 1.258 + /** 1.259 + * Used for instances of {@link UnionTypeTree}. 1.260 + */ 1.261 + UNION_TYPE(UnionTypeTree.class), 1.262 + 1.263 + /** 1.264 + * Used for instances of {@link IntersectionTypeTree}. 1.265 + */ 1.266 + INTERSECTION_TYPE(IntersectionTypeTree.class), 1.267 + 1.268 + /** 1.269 + * Used for instances of {@link TypeCastTree}. 1.270 + */ 1.271 + TYPE_CAST(TypeCastTree.class), 1.272 + 1.273 + /** 1.274 + * Used for instances of {@link TypeParameterTree}. 1.275 + */ 1.276 + TYPE_PARAMETER(TypeParameterTree.class), 1.277 + 1.278 + /** 1.279 + * Used for instances of {@link VariableTree}. 1.280 + */ 1.281 + VARIABLE(VariableTree.class), 1.282 + 1.283 + /** 1.284 + * Used for instances of {@link WhileLoopTree}. 1.285 + */ 1.286 + WHILE_LOOP(WhileLoopTree.class), 1.287 + 1.288 + /** 1.289 + * Used for instances of {@link UnaryTree} representing postfix 1.290 + * increment operator {@code ++}. 1.291 + */ 1.292 + POSTFIX_INCREMENT(UnaryTree.class), 1.293 + 1.294 + /** 1.295 + * Used for instances of {@link UnaryTree} representing postfix 1.296 + * decrement operator {@code --}. 1.297 + */ 1.298 + POSTFIX_DECREMENT(UnaryTree.class), 1.299 + 1.300 + /** 1.301 + * Used for instances of {@link UnaryTree} representing prefix 1.302 + * increment operator {@code ++}. 1.303 + */ 1.304 + PREFIX_INCREMENT(UnaryTree.class), 1.305 + 1.306 + /** 1.307 + * Used for instances of {@link UnaryTree} representing prefix 1.308 + * decrement operator {@code --}. 1.309 + */ 1.310 + PREFIX_DECREMENT(UnaryTree.class), 1.311 + 1.312 + /** 1.313 + * Used for instances of {@link UnaryTree} representing unary plus 1.314 + * operator {@code +}. 1.315 + */ 1.316 + UNARY_PLUS(UnaryTree.class), 1.317 + 1.318 + /** 1.319 + * Used for instances of {@link UnaryTree} representing unary minus 1.320 + * operator {@code -}. 1.321 + */ 1.322 + UNARY_MINUS(UnaryTree.class), 1.323 + 1.324 + /** 1.325 + * Used for instances of {@link UnaryTree} representing bitwise 1.326 + * complement operator {@code ~}. 1.327 + */ 1.328 + BITWISE_COMPLEMENT(UnaryTree.class), 1.329 + 1.330 + /** 1.331 + * Used for instances of {@link UnaryTree} representing logical 1.332 + * complement operator {@code !}. 1.333 + */ 1.334 + LOGICAL_COMPLEMENT(UnaryTree.class), 1.335 + 1.336 + /** 1.337 + * Used for instances of {@link BinaryTree} representing 1.338 + * multiplication {@code *}. 1.339 + */ 1.340 + MULTIPLY(BinaryTree.class), 1.341 + 1.342 + /** 1.343 + * Used for instances of {@link BinaryTree} representing 1.344 + * division {@code /}. 1.345 + */ 1.346 + DIVIDE(BinaryTree.class), 1.347 + 1.348 + /** 1.349 + * Used for instances of {@link BinaryTree} representing 1.350 + * remainder {@code %}. 1.351 + */ 1.352 + REMAINDER(BinaryTree.class), 1.353 + 1.354 + /** 1.355 + * Used for instances of {@link BinaryTree} representing 1.356 + * addition or string concatenation {@code +}. 1.357 + */ 1.358 + PLUS(BinaryTree.class), 1.359 + 1.360 + /** 1.361 + * Used for instances of {@link BinaryTree} representing 1.362 + * subtraction {@code -}. 1.363 + */ 1.364 + MINUS(BinaryTree.class), 1.365 + 1.366 + /** 1.367 + * Used for instances of {@link BinaryTree} representing 1.368 + * left shift {@code <<}. 1.369 + */ 1.370 + LEFT_SHIFT(BinaryTree.class), 1.371 + 1.372 + /** 1.373 + * Used for instances of {@link BinaryTree} representing 1.374 + * right shift {@code >>}. 1.375 + */ 1.376 + RIGHT_SHIFT(BinaryTree.class), 1.377 + 1.378 + /** 1.379 + * Used for instances of {@link BinaryTree} representing 1.380 + * unsigned right shift {@code >>>}. 1.381 + */ 1.382 + UNSIGNED_RIGHT_SHIFT(BinaryTree.class), 1.383 + 1.384 + /** 1.385 + * Used for instances of {@link BinaryTree} representing 1.386 + * less-than {@code <}. 1.387 + */ 1.388 + LESS_THAN(BinaryTree.class), 1.389 + 1.390 + /** 1.391 + * Used for instances of {@link BinaryTree} representing 1.392 + * greater-than {@code >}. 1.393 + */ 1.394 + GREATER_THAN(BinaryTree.class), 1.395 + 1.396 + /** 1.397 + * Used for instances of {@link BinaryTree} representing 1.398 + * less-than-equal {@code <=}. 1.399 + */ 1.400 + LESS_THAN_EQUAL(BinaryTree.class), 1.401 + 1.402 + /** 1.403 + * Used for instances of {@link BinaryTree} representing 1.404 + * greater-than-equal {@code >=}. 1.405 + */ 1.406 + GREATER_THAN_EQUAL(BinaryTree.class), 1.407 + 1.408 + /** 1.409 + * Used for instances of {@link BinaryTree} representing 1.410 + * equal-to {@code ==}. 1.411 + */ 1.412 + EQUAL_TO(BinaryTree.class), 1.413 + 1.414 + /** 1.415 + * Used for instances of {@link BinaryTree} representing 1.416 + * not-equal-to {@code !=}. 1.417 + */ 1.418 + NOT_EQUAL_TO(BinaryTree.class), 1.419 + 1.420 + /** 1.421 + * Used for instances of {@link BinaryTree} representing 1.422 + * bitwise and logical "and" {@code &}. 1.423 + */ 1.424 + AND(BinaryTree.class), 1.425 + 1.426 + /** 1.427 + * Used for instances of {@link BinaryTree} representing 1.428 + * bitwise and logical "xor" {@code ^}. 1.429 + */ 1.430 + XOR(BinaryTree.class), 1.431 + 1.432 + /** 1.433 + * Used for instances of {@link BinaryTree} representing 1.434 + * bitwise and logical "or" {@code |}. 1.435 + */ 1.436 + OR(BinaryTree.class), 1.437 + 1.438 + /** 1.439 + * Used for instances of {@link BinaryTree} representing 1.440 + * conditional-and {@code &&}. 1.441 + */ 1.442 + CONDITIONAL_AND(BinaryTree.class), 1.443 + 1.444 + /** 1.445 + * Used for instances of {@link BinaryTree} representing 1.446 + * conditional-or {@code ||}. 1.447 + */ 1.448 + CONDITIONAL_OR(BinaryTree.class), 1.449 + 1.450 + /** 1.451 + * Used for instances of {@link CompoundAssignmentTree} representing 1.452 + * multiplication assignment {@code *=}. 1.453 + */ 1.454 + MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class), 1.455 + 1.456 + /** 1.457 + * Used for instances of {@link CompoundAssignmentTree} representing 1.458 + * division assignment {@code /=}. 1.459 + */ 1.460 + DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class), 1.461 + 1.462 + /** 1.463 + * Used for instances of {@link CompoundAssignmentTree} representing 1.464 + * remainder assignment {@code %=}. 1.465 + */ 1.466 + REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class), 1.467 + 1.468 + /** 1.469 + * Used for instances of {@link CompoundAssignmentTree} representing 1.470 + * addition or string concatenation assignment {@code +=}. 1.471 + */ 1.472 + PLUS_ASSIGNMENT(CompoundAssignmentTree.class), 1.473 + 1.474 + /** 1.475 + * Used for instances of {@link CompoundAssignmentTree} representing 1.476 + * subtraction assignment {@code -=}. 1.477 + */ 1.478 + MINUS_ASSIGNMENT(CompoundAssignmentTree.class), 1.479 + 1.480 + /** 1.481 + * Used for instances of {@link CompoundAssignmentTree} representing 1.482 + * left shift assignment {@code <<=}. 1.483 + */ 1.484 + LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class), 1.485 + 1.486 + /** 1.487 + * Used for instances of {@link CompoundAssignmentTree} representing 1.488 + * right shift assignment {@code >>=}. 1.489 + */ 1.490 + RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class), 1.491 + 1.492 + /** 1.493 + * Used for instances of {@link CompoundAssignmentTree} representing 1.494 + * unsigned right shift assignment {@code >>>=}. 1.495 + */ 1.496 + UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class), 1.497 + 1.498 + /** 1.499 + * Used for instances of {@link CompoundAssignmentTree} representing 1.500 + * bitwise and logical "and" assignment {@code &=}. 1.501 + */ 1.502 + AND_ASSIGNMENT(CompoundAssignmentTree.class), 1.503 + 1.504 + /** 1.505 + * Used for instances of {@link CompoundAssignmentTree} representing 1.506 + * bitwise and logical "xor" assignment {@code ^=}. 1.507 + */ 1.508 + XOR_ASSIGNMENT(CompoundAssignmentTree.class), 1.509 + 1.510 + /** 1.511 + * Used for instances of {@link CompoundAssignmentTree} representing 1.512 + * bitwise and logical "or" assignment {@code |=}. 1.513 + */ 1.514 + OR_ASSIGNMENT(CompoundAssignmentTree.class), 1.515 + 1.516 + /** 1.517 + * Used for instances of {@link LiteralTree} representing 1.518 + * an integral literal expression of type {@code int}. 1.519 + */ 1.520 + INT_LITERAL(LiteralTree.class), 1.521 + 1.522 + /** 1.523 + * Used for instances of {@link LiteralTree} representing 1.524 + * an integral literal expression of type {@code long}. 1.525 + */ 1.526 + LONG_LITERAL(LiteralTree.class), 1.527 + 1.528 + /** 1.529 + * Used for instances of {@link LiteralTree} representing 1.530 + * a floating-point literal expression of type {@code float}. 1.531 + */ 1.532 + FLOAT_LITERAL(LiteralTree.class), 1.533 + 1.534 + /** 1.535 + * Used for instances of {@link LiteralTree} representing 1.536 + * a floating-point literal expression of type {@code double}. 1.537 + */ 1.538 + DOUBLE_LITERAL(LiteralTree.class), 1.539 + 1.540 + /** 1.541 + * Used for instances of {@link LiteralTree} representing 1.542 + * a boolean literal expression of type {@code boolean}. 1.543 + */ 1.544 + BOOLEAN_LITERAL(LiteralTree.class), 1.545 + 1.546 + /** 1.547 + * Used for instances of {@link LiteralTree} representing 1.548 + * a character literal expression of type {@code char}. 1.549 + */ 1.550 + CHAR_LITERAL(LiteralTree.class), 1.551 + 1.552 + /** 1.553 + * Used for instances of {@link LiteralTree} representing 1.554 + * a string literal expression of type {@link String}. 1.555 + */ 1.556 + STRING_LITERAL(LiteralTree.class), 1.557 + 1.558 + /** 1.559 + * Used for instances of {@link LiteralTree} representing 1.560 + * the use of {@code null}. 1.561 + */ 1.562 + NULL_LITERAL(LiteralTree.class), 1.563 + 1.564 + /** 1.565 + * Used for instances of {@link WildcardTree} representing 1.566 + * an unbounded wildcard type argument. 1.567 + */ 1.568 + UNBOUNDED_WILDCARD(WildcardTree.class), 1.569 + 1.570 + /** 1.571 + * Used for instances of {@link WildcardTree} representing 1.572 + * an extends bounded wildcard type argument. 1.573 + */ 1.574 + EXTENDS_WILDCARD(WildcardTree.class), 1.575 + 1.576 + /** 1.577 + * Used for instances of {@link WildcardTree} representing 1.578 + * a super bounded wildcard type argument. 1.579 + */ 1.580 + SUPER_WILDCARD(WildcardTree.class), 1.581 + 1.582 + /** 1.583 + * Used for instances of {@link ErroneousTree}. 1.584 + */ 1.585 + ERRONEOUS(ErroneousTree.class), 1.586 + 1.587 + /** 1.588 + * Used for instances of {@link ClassTree} representing interfaces. 1.589 + */ 1.590 + INTERFACE(ClassTree.class), 1.591 + 1.592 + /** 1.593 + * Used for instances of {@link ClassTree} representing enums. 1.594 + */ 1.595 + ENUM(ClassTree.class), 1.596 + 1.597 + /** 1.598 + * Used for instances of {@link ClassTree} representing annotation types. 1.599 + */ 1.600 + ANNOTATION_TYPE(ClassTree.class), 1.601 + 1.602 + /** 1.603 + * An implementation-reserved node. This is the not the node 1.604 + * you are looking for. 1.605 + */ 1.606 + OTHER(null); 1.607 + 1.608 + 1.609 + Kind(Class<? extends Tree> intf) { 1.610 + associatedInterface = intf; 1.611 + } 1.612 + 1.613 + public Class<? extends Tree> asInterface() { 1.614 + return associatedInterface; 1.615 + } 1.616 + 1.617 + private final Class<? extends Tree> associatedInterface; 1.618 + } 1.619 + 1.620 + /** 1.621 + * Gets the kind of this tree. 1.622 + * 1.623 + * @return the kind of this tree. 1.624 + */ 1.625 + Kind getKind(); 1.626 + 1.627 + /** 1.628 + * Accept method used to implement the visitor pattern. The 1.629 + * visitor pattern is used to implement operations on trees. 1.630 + * 1.631 + * @param <R> result type of this operation. 1.632 + * @param <D> type of additional data. 1.633 + */ 1.634 + <R,D> R accept(TreeVisitor<R,D> visitor, D data); 1.635 +}