src/share/classes/com/sun/source/tree/Tree.java

Wed, 06 Apr 2011 19:30:57 -0700

author
darcy
date
Wed, 06 Apr 2011 19:30:57 -0700
changeset 969
8cc5b440fdde
parent 815
d17f37522154
child 1142
c896d95e7469
permissions
-rw-r--r--

7033809: Rename "disjunctive" to "union" in javax.lang.model
Reviewed-by: mcimadamore, jjg

     1 /*
     2  * Copyright (c) 2005, 2011, 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&trade; 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&eacute;
    38  * @author Jonathan Gibbons
    39  *
    40  * @since 1.6
    41  */
    42 public interface Tree {
    44     /**
    45      * Enumerates all kinds of trees.
    46      */
    47     public enum Kind {
    49         /**
    50          * Used for instances of {@link AnnotationTree}.
    51          */
    52         ANNOTATION(AnnotationTree.class),
    54         /**
    55          * Used for instances of {@link ArrayAccessTree}.
    56          */
    57         ARRAY_ACCESS(ArrayAccessTree.class),
    59         /**
    60          * Used for instances of {@link ArrayTypeTree}.
    61          */
    62         ARRAY_TYPE(ArrayTypeTree.class),
    64         /**
    65          * Used for instances of {@link AssertTree}.
    66          */
    67         ASSERT(AssertTree.class),
    69         /**
    70          * Used for instances of {@link AssignmentTree}.
    71          */
    72         ASSIGNMENT(AssignmentTree.class),
    74         /**
    75          * Used for instances of {@link BlockTree}.
    76          */
    77         BLOCK(BlockTree.class),
    79         /**
    80          * Used for instances of {@link BreakTree}.
    81          */
    82         BREAK(BreakTree.class),
    84         /**
    85          * Used for instances of {@link CaseTree}.
    86          */
    87         CASE(CaseTree.class),
    89         /**
    90          * Used for instances of {@link CatchTree}.
    91          */
    92         CATCH(CatchTree.class),
    94         /**
    95          * Used for instances of {@link ClassTree} representing classes.
    96          */
    97         CLASS(ClassTree.class),
    99         /**
   100          * Used for instances of {@link CompilationUnitTree}.
   101          */
   102         COMPILATION_UNIT(CompilationUnitTree.class),
   104         /**
   105          * Used for instances of {@link ConditionalExpressionTree}.
   106          */
   107         CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class),
   109         /**
   110          * Used for instances of {@link ContinueTree}.
   111          */
   112         CONTINUE(ContinueTree.class),
   114         /**
   115          * Used for instances of {@link DoWhileLoopTree}.
   116          */
   117         DO_WHILE_LOOP(DoWhileLoopTree.class),
   119         /**
   120          * Used for instances of {@link EnhancedForLoopTree}.
   121          */
   122         ENHANCED_FOR_LOOP(EnhancedForLoopTree.class),
   124         /**
   125          * Used for instances of {@link ExpressionStatementTree}.
   126          */
   127         EXPRESSION_STATEMENT(ExpressionStatementTree.class),
   129         /**
   130          * Used for instances of {@link MemberSelectTree}.
   131          */
   132         MEMBER_SELECT(MemberSelectTree.class),
   134         /**
   135          * Used for instances of {@link ForLoopTree}.
   136          */
   137         FOR_LOOP(ForLoopTree.class),
   139         /**
   140          * Used for instances of {@link IdentifierTree}.
   141          */
   142         IDENTIFIER(IdentifierTree.class),
   144         /**
   145          * Used for instances of {@link IfTree}.
   146          */
   147         IF(IfTree.class),
   149         /**
   150          * Used for instances of {@link ImportTree}.
   151          */
   152         IMPORT(ImportTree.class),
   154         /**
   155          * Used for instances of {@link InstanceOfTree}.
   156          */
   157         INSTANCE_OF(InstanceOfTree.class),
   159         /**
   160          * Used for instances of {@link LabeledStatementTree}.
   161          */
   162         LABELED_STATEMENT(LabeledStatementTree.class),
   164         /**
   165          * Used for instances of {@link MethodTree}.
   166          */
   167         METHOD(MethodTree.class),
   169         /**
   170          * Used for instances of {@link MethodInvocationTree}.
   171          */
   172         METHOD_INVOCATION(MethodInvocationTree.class),
   174         /**
   175          * Used for instances of {@link ModifiersTree}.
   176          */
   177         MODIFIERS(ModifiersTree.class),
   179         /**
   180          * Used for instances of {@link NewArrayTree}.
   181          */
   182         NEW_ARRAY(NewArrayTree.class),
   184         /**
   185          * Used for instances of {@link NewClassTree}.
   186          */
   187         NEW_CLASS(NewClassTree.class),
   189         /**
   190          * Used for instances of {@link ParenthesizedTree}.
   191          */
   192         PARENTHESIZED(ParenthesizedTree.class),
   194         /**
   195          * Used for instances of {@link PrimitiveTypeTree}.
   196          */
   197         PRIMITIVE_TYPE(PrimitiveTypeTree.class),
   199         /**
   200          * Used for instances of {@link ReturnTree}.
   201          */
   202         RETURN(ReturnTree.class),
   204         /**
   205          * Used for instances of {@link EmptyStatementTree}.
   206          */
   207         EMPTY_STATEMENT(EmptyStatementTree.class),
   209         /**
   210          * Used for instances of {@link SwitchTree}.
   211          */
   212         SWITCH(SwitchTree.class),
   214         /**
   215          * Used for instances of {@link SynchronizedTree}.
   216          */
   217         SYNCHRONIZED(SynchronizedTree.class),
   219         /**
   220          * Used for instances of {@link ThrowTree}.
   221          */
   222         THROW(ThrowTree.class),
   224         /**
   225          * Used for instances of {@link TryTree}.
   226          */
   227         TRY(TryTree.class),
   229         /**
   230          * Used for instances of {@link ParameterizedTypeTree}.
   231          */
   232         PARAMETERIZED_TYPE(ParameterizedTypeTree.class),
   234         /**
   235          * Used for instances of {@link UnionTypeTree}.
   236          */
   237         UNION_TYPE(UnionTypeTree.class),
   239         /**
   240          * Used for instances of {@link TypeCastTree}.
   241          */
   242         TYPE_CAST(TypeCastTree.class),
   244         /**
   245          * Used for instances of {@link TypeParameterTree}.
   246          */
   247         TYPE_PARAMETER(TypeParameterTree.class),
   249         /**
   250          * Used for instances of {@link VariableTree}.
   251          */
   252         VARIABLE(VariableTree.class),
   254         /**
   255          * Used for instances of {@link WhileLoopTree}.
   256          */
   257         WHILE_LOOP(WhileLoopTree.class),
   259         /**
   260          * Used for instances of {@link UnaryTree} representing postfix
   261          * increment operator {@code ++}.
   262          */
   263         POSTFIX_INCREMENT(UnaryTree.class),
   265         /**
   266          * Used for instances of {@link UnaryTree} representing postfix
   267          * decrement operator {@code --}.
   268          */
   269         POSTFIX_DECREMENT(UnaryTree.class),
   271         /**
   272          * Used for instances of {@link UnaryTree} representing prefix
   273          * increment operator {@code ++}.
   274          */
   275         PREFIX_INCREMENT(UnaryTree.class),
   277         /**
   278          * Used for instances of {@link UnaryTree} representing prefix
   279          * decrement operator {@code --}.
   280          */
   281         PREFIX_DECREMENT(UnaryTree.class),
   283         /**
   284          * Used for instances of {@link UnaryTree} representing unary plus
   285          * operator {@code +}.
   286          */
   287         UNARY_PLUS(UnaryTree.class),
   289         /**
   290          * Used for instances of {@link UnaryTree} representing unary minus
   291          * operator {@code -}.
   292          */
   293         UNARY_MINUS(UnaryTree.class),
   295         /**
   296          * Used for instances of {@link UnaryTree} representing bitwise
   297          * complement operator {@code ~}.
   298          */
   299         BITWISE_COMPLEMENT(UnaryTree.class),
   301         /**
   302          * Used for instances of {@link UnaryTree} representing logical
   303          * complement operator {@code !}.
   304          */
   305         LOGICAL_COMPLEMENT(UnaryTree.class),
   307         /**
   308          * Used for instances of {@link BinaryTree} representing
   309          * multiplication {@code *}.
   310          */
   311         MULTIPLY(BinaryTree.class),
   313         /**
   314          * Used for instances of {@link BinaryTree} representing
   315          * division {@code /}.
   316          */
   317         DIVIDE(BinaryTree.class),
   319         /**
   320          * Used for instances of {@link BinaryTree} representing
   321          * remainder {@code %}.
   322          */
   323         REMAINDER(BinaryTree.class),
   325         /**
   326          * Used for instances of {@link BinaryTree} representing
   327          * addition or string concatenation {@code +}.
   328          */
   329         PLUS(BinaryTree.class),
   331         /**
   332          * Used for instances of {@link BinaryTree} representing
   333          * subtraction {@code -}.
   334          */
   335         MINUS(BinaryTree.class),
   337         /**
   338          * Used for instances of {@link BinaryTree} representing
   339          * left shift {@code <<}.
   340          */
   341         LEFT_SHIFT(BinaryTree.class),
   343         /**
   344          * Used for instances of {@link BinaryTree} representing
   345          * right shift {@code >>}.
   346          */
   347         RIGHT_SHIFT(BinaryTree.class),
   349         /**
   350          * Used for instances of {@link BinaryTree} representing
   351          * unsigned right shift {@code >>>}.
   352          */
   353         UNSIGNED_RIGHT_SHIFT(BinaryTree.class),
   355         /**
   356          * Used for instances of {@link BinaryTree} representing
   357          * less-than {@code <}.
   358          */
   359         LESS_THAN(BinaryTree.class),
   361         /**
   362          * Used for instances of {@link BinaryTree} representing
   363          * greater-than {@code >}.
   364          */
   365         GREATER_THAN(BinaryTree.class),
   367         /**
   368          * Used for instances of {@link BinaryTree} representing
   369          * less-than-equal {@code <=}.
   370          */
   371         LESS_THAN_EQUAL(BinaryTree.class),
   373         /**
   374          * Used for instances of {@link BinaryTree} representing
   375          * greater-than-equal {@code >=}.
   376          */
   377         GREATER_THAN_EQUAL(BinaryTree.class),
   379         /**
   380          * Used for instances of {@link BinaryTree} representing
   381          * equal-to {@code ==}.
   382          */
   383         EQUAL_TO(BinaryTree.class),
   385         /**
   386          * Used for instances of {@link BinaryTree} representing
   387          * not-equal-to {@code !=}.
   388          */
   389         NOT_EQUAL_TO(BinaryTree.class),
   391         /**
   392          * Used for instances of {@link BinaryTree} representing
   393          * bitwise and logical "and" {@code &}.
   394          */
   395         AND(BinaryTree.class),
   397         /**
   398          * Used for instances of {@link BinaryTree} representing
   399          * bitwise and logical "xor" {@code ^}.
   400          */
   401         XOR(BinaryTree.class),
   403         /**
   404          * Used for instances of {@link BinaryTree} representing
   405          * bitwise and logical "or" {@code |}.
   406          */
   407         OR(BinaryTree.class),
   409         /**
   410          * Used for instances of {@link BinaryTree} representing
   411          * conditional-and {@code &&}.
   412          */
   413         CONDITIONAL_AND(BinaryTree.class),
   415         /**
   416          * Used for instances of {@link BinaryTree} representing
   417          * conditional-or {@code ||}.
   418          */
   419         CONDITIONAL_OR(BinaryTree.class),
   421         /**
   422          * Used for instances of {@link CompoundAssignmentTree} representing
   423          * multiplication assignment {@code *=}.
   424          */
   425         MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class),
   427         /**
   428          * Used for instances of {@link CompoundAssignmentTree} representing
   429          * division assignment {@code /=}.
   430          */
   431         DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class),
   433         /**
   434          * Used for instances of {@link CompoundAssignmentTree} representing
   435          * remainder assignment {@code %=}.
   436          */
   437         REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class),
   439         /**
   440          * Used for instances of {@link CompoundAssignmentTree} representing
   441          * addition or string concatenation assignment {@code +=}.
   442          */
   443         PLUS_ASSIGNMENT(CompoundAssignmentTree.class),
   445         /**
   446          * Used for instances of {@link CompoundAssignmentTree} representing
   447          * subtraction assignment {@code -=}.
   448          */
   449         MINUS_ASSIGNMENT(CompoundAssignmentTree.class),
   451         /**
   452          * Used for instances of {@link CompoundAssignmentTree} representing
   453          * left shift assignment {@code <<=}.
   454          */
   455         LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   457         /**
   458          * Used for instances of {@link CompoundAssignmentTree} representing
   459          * right shift assignment {@code >>=}.
   460          */
   461         RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   463         /**
   464          * Used for instances of {@link CompoundAssignmentTree} representing
   465          * unsigned right shift assignment {@code >>>=}.
   466          */
   467         UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   469         /**
   470          * Used for instances of {@link CompoundAssignmentTree} representing
   471          * bitwise and logical "and" assignment {@code &=}.
   472          */
   473         AND_ASSIGNMENT(CompoundAssignmentTree.class),
   475         /**
   476          * Used for instances of {@link CompoundAssignmentTree} representing
   477          * bitwise and logical "xor" assignment {@code ^=}.
   478          */
   479         XOR_ASSIGNMENT(CompoundAssignmentTree.class),
   481         /**
   482          * Used for instances of {@link CompoundAssignmentTree} representing
   483          * bitwise and logical "or" assignment {@code |=}.
   484          */
   485         OR_ASSIGNMENT(CompoundAssignmentTree.class),
   487         /**
   488          * Used for instances of {@link LiteralTree} representing
   489          * an integral literal expression of type {@code int}.
   490          */
   491         INT_LITERAL(LiteralTree.class),
   493         /**
   494          * Used for instances of {@link LiteralTree} representing
   495          * an integral literal expression of type {@code long}.
   496          */
   497         LONG_LITERAL(LiteralTree.class),
   499         /**
   500          * Used for instances of {@link LiteralTree} representing
   501          * a floating-point literal expression of type {@code float}.
   502          */
   503         FLOAT_LITERAL(LiteralTree.class),
   505         /**
   506          * Used for instances of {@link LiteralTree} representing
   507          * a floating-point literal expression of type {@code double}.
   508          */
   509         DOUBLE_LITERAL(LiteralTree.class),
   511         /**
   512          * Used for instances of {@link LiteralTree} representing
   513          * a boolean literal expression of type {@code boolean}.
   514          */
   515         BOOLEAN_LITERAL(LiteralTree.class),
   517         /**
   518          * Used for instances of {@link LiteralTree} representing
   519          * a character literal expression of type {@code char}.
   520          */
   521         CHAR_LITERAL(LiteralTree.class),
   523         /**
   524          * Used for instances of {@link LiteralTree} representing
   525          * a string literal expression of type {@link String}.
   526          */
   527         STRING_LITERAL(LiteralTree.class),
   529         /**
   530          * Used for instances of {@link LiteralTree} representing
   531          * the use of {@code null}.
   532          */
   533         NULL_LITERAL(LiteralTree.class),
   535         /**
   536          * Used for instances of {@link WildcardTree} representing
   537          * an unbounded wildcard type argument.
   538          */
   539         UNBOUNDED_WILDCARD(WildcardTree.class),
   541         /**
   542          * Used for instances of {@link WildcardTree} representing
   543          * an extends bounded wildcard type argument.
   544          */
   545         EXTENDS_WILDCARD(WildcardTree.class),
   547         /**
   548          * Used for instances of {@link WildcardTree} representing
   549          * a super bounded wildcard type argument.
   550          */
   551         SUPER_WILDCARD(WildcardTree.class),
   553         /**
   554          * Used for instances of {@link ErroneousTree}.
   555          */
   556         ERRONEOUS(ErroneousTree.class),
   558         /**
   559          * Used for instances of {@link ClassTree} representing interfaces.
   560          */
   561         INTERFACE(ClassTree.class),
   563         /**
   564          * Used for instances of {@link ClassTree} representing enums.
   565          */
   566         ENUM(ClassTree.class),
   568         /**
   569          * Used for instances of {@link ClassTree} representing annotation types.
   570          */
   571         ANNOTATION_TYPE(ClassTree.class),
   573         /**
   574          * An implementation-reserved node. This is the not the node
   575          * you are looking for.
   576          */
   577         OTHER(null);
   580         Kind(Class<? extends Tree> intf) {
   581             associatedInterface = intf;
   582         }
   584         public Class<? extends Tree> asInterface() {
   585             return associatedInterface;
   586         }
   588         private final Class<? extends Tree> associatedInterface;
   589     }
   591     /**
   592      * Gets the kind of this tree.
   593      *
   594      * @return the kind of this tree.
   595      */
   596     Kind getKind();
   598     /**
   599      * Accept method used to implement the visitor pattern.  The
   600      * visitor pattern is used to implement operations on trees.
   601      *
   602      * @param <R> result type of this operation.
   603      * @param <D> type of additonal data.
   604      */
   605     <R,D> R accept(TreeVisitor<R,D> visitor, D data);
   606 }

mercurial