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

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1
9a66ca7c79fa
child 308
03944ee4fac4
permissions
-rw-r--r--

Initial load

     1 /*
     2  * Copyright 2005-2006 Sun Microsystems, Inc.  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.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any 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 Sun's 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 {
    48         /**
    49          * Used for instances of {@link AnnotationTree}.
    50          */
    51         ANNOTATION(AnnotationTree.class),
    53         /**
    54          * Used for instances of {@link ArrayAccessTree}.
    55          */
    56         ARRAY_ACCESS(ArrayAccessTree.class),
    58         /**
    59          * Used for instances of {@link ArrayTypeTree}.
    60          */
    61         ARRAY_TYPE(ArrayTypeTree.class),
    63         /**
    64          * Used for instances of {@link AssertTree}.
    65          */
    66         ASSERT(AssertTree.class),
    68         /**
    69          * Used for instances of {@link AssignmentTree}.
    70          */
    71         ASSIGNMENT(AssignmentTree.class),
    73         /**
    74          * Used for instances of {@link BlockTree}.
    75          */
    76         BLOCK(BlockTree.class),
    78         /**
    79          * Used for instances of {@link BreakTree}.
    80          */
    81         BREAK(BreakTree.class),
    83         /**
    84          * Used for instances of {@link CaseTree}.
    85          */
    86         CASE(CaseTree.class),
    88         /**
    89          * Used for instances of {@link CatchTree}.
    90          */
    91         CATCH(CatchTree.class),
    93         /**
    94          * Used for instances of {@link ClassTree}.
    95          */
    96         CLASS(ClassTree.class),
    98         /**
    99          * Used for instances of {@link CompilationUnitTree}.
   100          */
   101         COMPILATION_UNIT(CompilationUnitTree.class),
   103         /**
   104          * Used for instances of {@link ConditionalExpressionTree}.
   105          */
   106         CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class),
   108         /**
   109          * Used for instances of {@link ContinueTree}.
   110          */
   111         CONTINUE(ContinueTree.class),
   113         /**
   114          * Used for instances of {@link DoWhileLoopTree}.
   115          */
   116         DO_WHILE_LOOP(DoWhileLoopTree.class),
   118         /**
   119          * Used for instances of {@link EnhancedForLoopTree}.
   120          */
   121         ENHANCED_FOR_LOOP(EnhancedForLoopTree.class),
   123         /**
   124          * Used for instances of {@link ExpressionStatementTree}.
   125          */
   126         EXPRESSION_STATEMENT(ExpressionStatementTree.class),
   128         /**
   129          * Used for instances of {@link MemberSelectTree}.
   130          */
   131         MEMBER_SELECT(MemberSelectTree.class),
   133         /**
   134          * Used for instances of {@link ForLoopTree}.
   135          */
   136         FOR_LOOP(ForLoopTree.class),
   138         /**
   139          * Used for instances of {@link IdentifierTree}.
   140          */
   141         IDENTIFIER(IdentifierTree.class),
   143         /**
   144          * Used for instances of {@link IfTree}.
   145          */
   146         IF(IfTree.class),
   148         /**
   149          * Used for instances of {@link ImportTree}.
   150          */
   151         IMPORT(ImportTree.class),
   153         /**
   154          * Used for instances of {@link InstanceOfTree}.
   155          */
   156         INSTANCE_OF(InstanceOfTree.class),
   158         /**
   159          * Used for instances of {@link LabeledStatementTree}.
   160          */
   161         LABELED_STATEMENT(LabeledStatementTree.class),
   163         /**
   164          * Used for instances of {@link MethodTree}.
   165          */
   166         METHOD(MethodTree.class),
   168         /**
   169          * Used for instances of {@link MethodInvocationTree}.
   170          */
   171         METHOD_INVOCATION(MethodInvocationTree.class),
   173         /**
   174          * Used for instances of {@link ModifiersTree}.
   175          */
   176         MODIFIERS(ModifiersTree.class),
   178         /**
   179          * Used for instances of {@link NewArrayTree}.
   180          */
   181         NEW_ARRAY(NewArrayTree.class),
   183         /**
   184          * Used for instances of {@link NewClassTree}.
   185          */
   186         NEW_CLASS(NewClassTree.class),
   188         /**
   189          * Used for instances of {@link ParenthesizedTree}.
   190          */
   191         PARENTHESIZED(ParenthesizedTree.class),
   193         /**
   194          * Used for instances of {@link PrimitiveTypeTree}.
   195          */
   196         PRIMITIVE_TYPE(PrimitiveTypeTree.class),
   198         /**
   199          * Used for instances of {@link ReturnTree}.
   200          */
   201         RETURN(ReturnTree.class),
   203         /**
   204          * Used for instances of {@link EmptyStatementTree}.
   205          */
   206         EMPTY_STATEMENT(EmptyStatementTree.class),
   208         /**
   209          * Used for instances of {@link SwitchTree}.
   210          */
   211         SWITCH(SwitchTree.class),
   213         /**
   214          * Used for instances of {@link SynchronizedTree}.
   215          */
   216         SYNCHRONIZED(SynchronizedTree.class),
   218         /**
   219          * Used for instances of {@link ThrowTree}.
   220          */
   221         THROW(ThrowTree.class),
   223         /**
   224          * Used for instances of {@link TryTree}.
   225          */
   226         TRY(TryTree.class),
   228         /**
   229          * Used for instances of {@link ParameterizedTypeTree}.
   230          */
   231         PARAMETERIZED_TYPE(ParameterizedTypeTree.class),
   233         /**
   234          * Used for instances of {@link TypeCastTree}.
   235          */
   236         TYPE_CAST(TypeCastTree.class),
   238         /**
   239          * Used for instances of {@link TypeParameterTree}.
   240          */
   241         TYPE_PARAMETER(TypeParameterTree.class),
   243         /**
   244          * Used for instances of {@link VariableTree}.
   245          */
   246         VARIABLE(VariableTree.class),
   248         /**
   249          * Used for instances of {@link WhileLoopTree}.
   250          */
   251         WHILE_LOOP(WhileLoopTree.class),
   253         /**
   254          * Used for instances of {@link UnaryTree} representing postfix
   255          * increment operator {@code ++}.
   256          */
   257         POSTFIX_INCREMENT(UnaryTree.class),
   259         /**
   260          * Used for instances of {@link UnaryTree} representing postfix
   261          * decrement operator {@code --}.
   262          */
   263         POSTFIX_DECREMENT(UnaryTree.class),
   265         /**
   266          * Used for instances of {@link UnaryTree} representing prefix
   267          * increment operator {@code ++}.
   268          */
   269         PREFIX_INCREMENT(UnaryTree.class),
   271         /**
   272          * Used for instances of {@link UnaryTree} representing prefix
   273          * decrement operator {@code --}.
   274          */
   275         PREFIX_DECREMENT(UnaryTree.class),
   277         /**
   278          * Used for instances of {@link UnaryTree} representing unary plus
   279          * operator {@code +}.
   280          */
   281         UNARY_PLUS(UnaryTree.class),
   283         /**
   284          * Used for instances of {@link UnaryTree} representing unary minus
   285          * operator {@code -}.
   286          */
   287         UNARY_MINUS(UnaryTree.class),
   289         /**
   290          * Used for instances of {@link UnaryTree} representing bitwise
   291          * complement operator {@code ~}.
   292          */
   293         BITWISE_COMPLEMENT(UnaryTree.class),
   295         /**
   296          * Used for instances of {@link UnaryTree} representing logical
   297          * complement operator {@code !}.
   298          */
   299         LOGICAL_COMPLEMENT(UnaryTree.class),
   301         /**
   302          * Used for instances of {@link BinaryTree} representing
   303          * multiplication {@code *}.
   304          */
   305         MULTIPLY(BinaryTree.class),
   307         /**
   308          * Used for instances of {@link BinaryTree} representing
   309          * division {@code /}.
   310          */
   311         DIVIDE(BinaryTree.class),
   313         /**
   314          * Used for instances of {@link BinaryTree} representing
   315          * remainder {@code %}.
   316          */
   317         REMAINDER(BinaryTree.class),
   319         /**
   320          * Used for instances of {@link BinaryTree} representing
   321          * addition or string concatenation {@code +}.
   322          */
   323         PLUS(BinaryTree.class),
   325         /**
   326          * Used for instances of {@link BinaryTree} representing
   327          * subtraction {@code -}.
   328          */
   329         MINUS(BinaryTree.class),
   331         /**
   332          * Used for instances of {@link BinaryTree} representing
   333          * left shift {@code <<}.
   334          */
   335         LEFT_SHIFT(BinaryTree.class),
   337         /**
   338          * Used for instances of {@link BinaryTree} representing
   339          * right shift {@code >>}.
   340          */
   341         RIGHT_SHIFT(BinaryTree.class),
   343         /**
   344          * Used for instances of {@link BinaryTree} representing
   345          * unsigned right shift {@code >>>}.
   346          */
   347         UNSIGNED_RIGHT_SHIFT(BinaryTree.class),
   349         /**
   350          * Used for instances of {@link BinaryTree} representing
   351          * less-than {@code <}.
   352          */
   353         LESS_THAN(BinaryTree.class),
   355         /**
   356          * Used for instances of {@link BinaryTree} representing
   357          * greater-than {@code >}.
   358          */
   359         GREATER_THAN(BinaryTree.class),
   361         /**
   362          * Used for instances of {@link BinaryTree} representing
   363          * less-than-equal {@code <=}.
   364          */
   365         LESS_THAN_EQUAL(BinaryTree.class),
   367         /**
   368          * Used for instances of {@link BinaryTree} representing
   369          * greater-than-equal {@code >=}.
   370          */
   371         GREATER_THAN_EQUAL(BinaryTree.class),
   373         /**
   374          * Used for instances of {@link BinaryTree} representing
   375          * equal-to {@code ==}.
   376          */
   377         EQUAL_TO(BinaryTree.class),
   379         /**
   380          * Used for instances of {@link BinaryTree} representing
   381          * not-equal-to {@code !=}.
   382          */
   383         NOT_EQUAL_TO(BinaryTree.class),
   385         /**
   386          * Used for instances of {@link BinaryTree} representing
   387          * bitwise and logical "and" {@code &}.
   388          */
   389         AND(BinaryTree.class),
   391         /**
   392          * Used for instances of {@link BinaryTree} representing
   393          * bitwise and logical "xor" {@code ^}.
   394          */
   395         XOR(BinaryTree.class),
   397         /**
   398          * Used for instances of {@link BinaryTree} representing
   399          * bitwise and logical "or" {@code |}.
   400          */
   401         OR(BinaryTree.class),
   403         /**
   404          * Used for instances of {@link BinaryTree} representing
   405          * conditional-and {@code &&}.
   406          */
   407         CONDITIONAL_AND(BinaryTree.class),
   409         /**
   410          * Used for instances of {@link BinaryTree} representing
   411          * conditional-or {@code ||}.
   412          */
   413         CONDITIONAL_OR(BinaryTree.class),
   415         /**
   416          * Used for instances of {@link CompoundAssignmentTree} representing
   417          * multiplication assignment {@code *=}.
   418          */
   419         MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class),
   421         /**
   422          * Used for instances of {@link CompoundAssignmentTree} representing
   423          * division assignment {@code /=}.
   424          */
   425         DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class),
   427         /**
   428          * Used for instances of {@link CompoundAssignmentTree} representing
   429          * remainder assignment {@code %=}.
   430          */
   431         REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class),
   433         /**
   434          * Used for instances of {@link CompoundAssignmentTree} representing
   435          * addition or string concatenation assignment {@code +=}.
   436          */
   437         PLUS_ASSIGNMENT(CompoundAssignmentTree.class),
   439         /**
   440          * Used for instances of {@link CompoundAssignmentTree} representing
   441          * subtraction assignment {@code -=}.
   442          */
   443         MINUS_ASSIGNMENT(CompoundAssignmentTree.class),
   445         /**
   446          * Used for instances of {@link CompoundAssignmentTree} representing
   447          * left shift assignment {@code <<=}.
   448          */
   449         LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   451         /**
   452          * Used for instances of {@link CompoundAssignmentTree} representing
   453          * right shift assignment {@code >>=}.
   454          */
   455         RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   457         /**
   458          * Used for instances of {@link CompoundAssignmentTree} representing
   459          * unsigned right shift assignment {@code >>>=}.
   460          */
   461         UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   463         /**
   464          * Used for instances of {@link CompoundAssignmentTree} representing
   465          * bitwise and logical "and" assignment {@code &=}.
   466          */
   467         AND_ASSIGNMENT(CompoundAssignmentTree.class),
   469         /**
   470          * Used for instances of {@link CompoundAssignmentTree} representing
   471          * bitwise and logical "xor" assignment {@code ^=}.
   472          */
   473         XOR_ASSIGNMENT(CompoundAssignmentTree.class),
   475         /**
   476          * Used for instances of {@link CompoundAssignmentTree} representing
   477          * bitwise and logical "or" assignment {@code |=}.
   478          */
   479         OR_ASSIGNMENT(CompoundAssignmentTree.class),
   481         /**
   482          * Used for instances of {@link LiteralTree} representing
   483          * an integral literal expression of type {@code int}.
   484          */
   485         INT_LITERAL(LiteralTree.class),
   487         /**
   488          * Used for instances of {@link LiteralTree} representing
   489          * an integral literal expression of type {@code long}.
   490          */
   491         LONG_LITERAL(LiteralTree.class),
   493         /**
   494          * Used for instances of {@link LiteralTree} representing
   495          * a floating-point literal expression of type {@code float}.
   496          */
   497         FLOAT_LITERAL(LiteralTree.class),
   499         /**
   500          * Used for instances of {@link LiteralTree} representing
   501          * a floating-point literal expression of type {@code double}.
   502          */
   503         DOUBLE_LITERAL(LiteralTree.class),
   505         /**
   506          * Used for instances of {@link LiteralTree} representing
   507          * a boolean literal expression of type {@code boolean}.
   508          */
   509         BOOLEAN_LITERAL(LiteralTree.class),
   511         /**
   512          * Used for instances of {@link LiteralTree} representing
   513          * a character literal expression of type {@code char}.
   514          */
   515         CHAR_LITERAL(LiteralTree.class),
   517         /**
   518          * Used for instances of {@link LiteralTree} representing
   519          * a string literal expression of type {@link String}.
   520          */
   521         STRING_LITERAL(LiteralTree.class),
   523         /**
   524          * Used for instances of {@link LiteralTree} representing
   525          * the use of {@code null}.
   526          */
   527         NULL_LITERAL(LiteralTree.class),
   529         /**
   530          * Used for instances of {@link WildcardTree} representing
   531          * an unbounded wildcard type argument.
   532          */
   533         UNBOUNDED_WILDCARD(WildcardTree.class),
   535         /**
   536          * Used for instances of {@link WildcardTree} representing
   537          * an extends bounded wildcard type argument.
   538          */
   539         EXTENDS_WILDCARD(WildcardTree.class),
   541         /**
   542          * Used for instances of {@link WildcardTree} representing
   543          * a super bounded wildcard type argument.
   544          */
   545         SUPER_WILDCARD(WildcardTree.class),
   547         /**
   548          * Used for instances of {@link ErroneousTree}.
   549          */
   550         ERRONEOUS(ErroneousTree.class),
   552         /**
   553          * An implementation-reserved node. This is the not the node
   554          * you are looking for.
   555          */
   556         OTHER(null);
   559         Kind(Class<? extends Tree> intf) {
   560             associatedInterface = intf;
   561         }
   563         public Class<? extends Tree> asInterface() {
   564             return associatedInterface;
   565         }
   567         private final Class<? extends Tree> associatedInterface;
   568     }
   570     /**
   571      * Gets the kind of this tree.
   572      *
   573      * @return the kind of this tree.
   574      */
   575     Kind getKind();
   577     /**
   578      * Accept method used to implement the visitor pattern.  The
   579      * visitor pattern is used to implement operations on trees.
   580      *
   581      * @param <R> result type of this operation.
   582      * @param <D> type of additonal data.
   583      */
   584     <R,D> R accept(TreeVisitor<R,D> visitor, D data);
   585 }

mercurial