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

Fri, 27 Aug 2010 17:21:17 -0700

author
jjg
date
Fri, 27 Aug 2010 17:21:17 -0700
changeset 662
b4e7a57af8df
parent 582
366a7b9b5627
child 722
4851ff2ffc10
permissions
-rw-r--r--

6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
Reviewed-by: mcimadamore

     1 /*
     2  * Copyright (c) 2005, 2006, 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         ANNOTATED_TYPE(AnnotatedTypeTree.class),
    51         /**
    52          * Used for instances of {@link AnnotationTree}.
    53          */
    54         ANNOTATION(AnnotationTree.class),
    56         /**
    57          * Used for instances of {@link ArrayAccessTree}.
    58          */
    59         ARRAY_ACCESS(ArrayAccessTree.class),
    61         /**
    62          * Used for instances of {@link ArrayTypeTree}.
    63          */
    64         ARRAY_TYPE(ArrayTypeTree.class),
    66         /**
    67          * Used for instances of {@link AssertTree}.
    68          */
    69         ASSERT(AssertTree.class),
    71         /**
    72          * Used for instances of {@link AssignmentTree}.
    73          */
    74         ASSIGNMENT(AssignmentTree.class),
    76         /**
    77          * Used for instances of {@link BlockTree}.
    78          */
    79         BLOCK(BlockTree.class),
    81         /**
    82          * Used for instances of {@link BreakTree}.
    83          */
    84         BREAK(BreakTree.class),
    86         /**
    87          * Used for instances of {@link CaseTree}.
    88          */
    89         CASE(CaseTree.class),
    91         /**
    92          * Used for instances of {@link CatchTree}.
    93          */
    94         CATCH(CatchTree.class),
    96         /**
    97          * Used for instances of {@link ClassTree} representing classes.
    98          */
    99         CLASS(ClassTree.class),
   101         /**
   102          * Used for instances of {@link CompilationUnitTree}.
   103          */
   104         COMPILATION_UNIT(CompilationUnitTree.class),
   106         /**
   107          * Used for instances of {@link ConditionalExpressionTree}.
   108          */
   109         CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class),
   111         /**
   112          * Used for instances of {@link ContinueTree}.
   113          */
   114         CONTINUE(ContinueTree.class),
   116         /**
   117          * Used for instances of {@link DoWhileLoopTree}.
   118          */
   119         DO_WHILE_LOOP(DoWhileLoopTree.class),
   121         /**
   122          * Used for instances of {@link EnhancedForLoopTree}.
   123          */
   124         ENHANCED_FOR_LOOP(EnhancedForLoopTree.class),
   126         /**
   127          * Used for instances of {@link ExpressionStatementTree}.
   128          */
   129         EXPRESSION_STATEMENT(ExpressionStatementTree.class),
   131         /**
   132          * Used for instances of {@link MemberSelectTree}.
   133          */
   134         MEMBER_SELECT(MemberSelectTree.class),
   136         /**
   137          * Used for instances of {@link ForLoopTree}.
   138          */
   139         FOR_LOOP(ForLoopTree.class),
   141         /**
   142          * Used for instances of {@link IdentifierTree}.
   143          */
   144         IDENTIFIER(IdentifierTree.class),
   146         /**
   147          * Used for instances of {@link IfTree}.
   148          */
   149         IF(IfTree.class),
   151         /**
   152          * Used for instances of {@link ImportTree}.
   153          */
   154         IMPORT(ImportTree.class),
   156         /**
   157          * Used for instances of {@link InstanceOfTree}.
   158          */
   159         INSTANCE_OF(InstanceOfTree.class),
   161         /**
   162          * Used for instances of {@link LabeledStatementTree}.
   163          */
   164         LABELED_STATEMENT(LabeledStatementTree.class),
   166         /**
   167          * Used for instances of {@link MethodTree}.
   168          */
   169         METHOD(MethodTree.class),
   171         /**
   172          * Used for instances of {@link MethodInvocationTree}.
   173          */
   174         METHOD_INVOCATION(MethodInvocationTree.class),
   176         /**
   177          * Used for instances of {@link ModifiersTree}.
   178          */
   179         MODIFIERS(ModifiersTree.class),
   181         /**
   182          * Used for instances of {@link NewArrayTree}.
   183          */
   184         NEW_ARRAY(NewArrayTree.class),
   186         /**
   187          * Used for instances of {@link NewClassTree}.
   188          */
   189         NEW_CLASS(NewClassTree.class),
   191         /**
   192          * Used for instances of {@link ParenthesizedTree}.
   193          */
   194         PARENTHESIZED(ParenthesizedTree.class),
   196         /**
   197          * Used for instances of {@link PrimitiveTypeTree}.
   198          */
   199         PRIMITIVE_TYPE(PrimitiveTypeTree.class),
   201         /**
   202          * Used for instances of {@link ReturnTree}.
   203          */
   204         RETURN(ReturnTree.class),
   206         /**
   207          * Used for instances of {@link EmptyStatementTree}.
   208          */
   209         EMPTY_STATEMENT(EmptyStatementTree.class),
   211         /**
   212          * Used for instances of {@link SwitchTree}.
   213          */
   214         SWITCH(SwitchTree.class),
   216         /**
   217          * Used for instances of {@link SynchronizedTree}.
   218          */
   219         SYNCHRONIZED(SynchronizedTree.class),
   221         /**
   222          * Used for instances of {@link ThrowTree}.
   223          */
   224         THROW(ThrowTree.class),
   226         /**
   227          * Used for instances of {@link TryTree}.
   228          */
   229         TRY(TryTree.class),
   231         /**
   232          * Used for instances of {@link ParameterizedTypeTree}.
   233          */
   234         PARAMETERIZED_TYPE(ParameterizedTypeTree.class),
   236         /**
   237          * Used for instances of {@link DisjointTypeTree}.
   238          */
   239         DISJOINT_TYPE(DisjointTypeTree.class),
   241         /**
   242          * Used for instances of {@link TypeCastTree}.
   243          */
   244         TYPE_CAST(TypeCastTree.class),
   246         /**
   247          * Used for instances of {@link TypeParameterTree}.
   248          */
   249         TYPE_PARAMETER(TypeParameterTree.class),
   251         /**
   252          * Used for instances of {@link VariableTree}.
   253          */
   254         VARIABLE(VariableTree.class),
   256         /**
   257          * Used for instances of {@link WhileLoopTree}.
   258          */
   259         WHILE_LOOP(WhileLoopTree.class),
   261         /**
   262          * Used for instances of {@link UnaryTree} representing postfix
   263          * increment operator {@code ++}.
   264          */
   265         POSTFIX_INCREMENT(UnaryTree.class),
   267         /**
   268          * Used for instances of {@link UnaryTree} representing postfix
   269          * decrement operator {@code --}.
   270          */
   271         POSTFIX_DECREMENT(UnaryTree.class),
   273         /**
   274          * Used for instances of {@link UnaryTree} representing prefix
   275          * increment operator {@code ++}.
   276          */
   277         PREFIX_INCREMENT(UnaryTree.class),
   279         /**
   280          * Used for instances of {@link UnaryTree} representing prefix
   281          * decrement operator {@code --}.
   282          */
   283         PREFIX_DECREMENT(UnaryTree.class),
   285         /**
   286          * Used for instances of {@link UnaryTree} representing unary plus
   287          * operator {@code +}.
   288          */
   289         UNARY_PLUS(UnaryTree.class),
   291         /**
   292          * Used for instances of {@link UnaryTree} representing unary minus
   293          * operator {@code -}.
   294          */
   295         UNARY_MINUS(UnaryTree.class),
   297         /**
   298          * Used for instances of {@link UnaryTree} representing bitwise
   299          * complement operator {@code ~}.
   300          */
   301         BITWISE_COMPLEMENT(UnaryTree.class),
   303         /**
   304          * Used for instances of {@link UnaryTree} representing logical
   305          * complement operator {@code !}.
   306          */
   307         LOGICAL_COMPLEMENT(UnaryTree.class),
   309         /**
   310          * Used for instances of {@link BinaryTree} representing
   311          * multiplication {@code *}.
   312          */
   313         MULTIPLY(BinaryTree.class),
   315         /**
   316          * Used for instances of {@link BinaryTree} representing
   317          * division {@code /}.
   318          */
   319         DIVIDE(BinaryTree.class),
   321         /**
   322          * Used for instances of {@link BinaryTree} representing
   323          * remainder {@code %}.
   324          */
   325         REMAINDER(BinaryTree.class),
   327         /**
   328          * Used for instances of {@link BinaryTree} representing
   329          * addition or string concatenation {@code +}.
   330          */
   331         PLUS(BinaryTree.class),
   333         /**
   334          * Used for instances of {@link BinaryTree} representing
   335          * subtraction {@code -}.
   336          */
   337         MINUS(BinaryTree.class),
   339         /**
   340          * Used for instances of {@link BinaryTree} representing
   341          * left shift {@code <<}.
   342          */
   343         LEFT_SHIFT(BinaryTree.class),
   345         /**
   346          * Used for instances of {@link BinaryTree} representing
   347          * right shift {@code >>}.
   348          */
   349         RIGHT_SHIFT(BinaryTree.class),
   351         /**
   352          * Used for instances of {@link BinaryTree} representing
   353          * unsigned right shift {@code >>>}.
   354          */
   355         UNSIGNED_RIGHT_SHIFT(BinaryTree.class),
   357         /**
   358          * Used for instances of {@link BinaryTree} representing
   359          * less-than {@code <}.
   360          */
   361         LESS_THAN(BinaryTree.class),
   363         /**
   364          * Used for instances of {@link BinaryTree} representing
   365          * greater-than {@code >}.
   366          */
   367         GREATER_THAN(BinaryTree.class),
   369         /**
   370          * Used for instances of {@link BinaryTree} representing
   371          * less-than-equal {@code <=}.
   372          */
   373         LESS_THAN_EQUAL(BinaryTree.class),
   375         /**
   376          * Used for instances of {@link BinaryTree} representing
   377          * greater-than-equal {@code >=}.
   378          */
   379         GREATER_THAN_EQUAL(BinaryTree.class),
   381         /**
   382          * Used for instances of {@link BinaryTree} representing
   383          * equal-to {@code ==}.
   384          */
   385         EQUAL_TO(BinaryTree.class),
   387         /**
   388          * Used for instances of {@link BinaryTree} representing
   389          * not-equal-to {@code !=}.
   390          */
   391         NOT_EQUAL_TO(BinaryTree.class),
   393         /**
   394          * Used for instances of {@link BinaryTree} representing
   395          * bitwise and logical "and" {@code &}.
   396          */
   397         AND(BinaryTree.class),
   399         /**
   400          * Used for instances of {@link BinaryTree} representing
   401          * bitwise and logical "xor" {@code ^}.
   402          */
   403         XOR(BinaryTree.class),
   405         /**
   406          * Used for instances of {@link BinaryTree} representing
   407          * bitwise and logical "or" {@code |}.
   408          */
   409         OR(BinaryTree.class),
   411         /**
   412          * Used for instances of {@link BinaryTree} representing
   413          * conditional-and {@code &&}.
   414          */
   415         CONDITIONAL_AND(BinaryTree.class),
   417         /**
   418          * Used for instances of {@link BinaryTree} representing
   419          * conditional-or {@code ||}.
   420          */
   421         CONDITIONAL_OR(BinaryTree.class),
   423         /**
   424          * Used for instances of {@link CompoundAssignmentTree} representing
   425          * multiplication assignment {@code *=}.
   426          */
   427         MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class),
   429         /**
   430          * Used for instances of {@link CompoundAssignmentTree} representing
   431          * division assignment {@code /=}.
   432          */
   433         DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class),
   435         /**
   436          * Used for instances of {@link CompoundAssignmentTree} representing
   437          * remainder assignment {@code %=}.
   438          */
   439         REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class),
   441         /**
   442          * Used for instances of {@link CompoundAssignmentTree} representing
   443          * addition or string concatenation assignment {@code +=}.
   444          */
   445         PLUS_ASSIGNMENT(CompoundAssignmentTree.class),
   447         /**
   448          * Used for instances of {@link CompoundAssignmentTree} representing
   449          * subtraction assignment {@code -=}.
   450          */
   451         MINUS_ASSIGNMENT(CompoundAssignmentTree.class),
   453         /**
   454          * Used for instances of {@link CompoundAssignmentTree} representing
   455          * left shift assignment {@code <<=}.
   456          */
   457         LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   459         /**
   460          * Used for instances of {@link CompoundAssignmentTree} representing
   461          * right shift assignment {@code >>=}.
   462          */
   463         RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   465         /**
   466          * Used for instances of {@link CompoundAssignmentTree} representing
   467          * unsigned right shift assignment {@code >>>=}.
   468          */
   469         UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
   471         /**
   472          * Used for instances of {@link CompoundAssignmentTree} representing
   473          * bitwise and logical "and" assignment {@code &=}.
   474          */
   475         AND_ASSIGNMENT(CompoundAssignmentTree.class),
   477         /**
   478          * Used for instances of {@link CompoundAssignmentTree} representing
   479          * bitwise and logical "xor" assignment {@code ^=}.
   480          */
   481         XOR_ASSIGNMENT(CompoundAssignmentTree.class),
   483         /**
   484          * Used for instances of {@link CompoundAssignmentTree} representing
   485          * bitwise and logical "or" assignment {@code |=}.
   486          */
   487         OR_ASSIGNMENT(CompoundAssignmentTree.class),
   489         /**
   490          * Used for instances of {@link LiteralTree} representing
   491          * an integral literal expression of type {@code int}.
   492          */
   493         INT_LITERAL(LiteralTree.class),
   495         /**
   496          * Used for instances of {@link LiteralTree} representing
   497          * an integral literal expression of type {@code long}.
   498          */
   499         LONG_LITERAL(LiteralTree.class),
   501         /**
   502          * Used for instances of {@link LiteralTree} representing
   503          * a floating-point literal expression of type {@code float}.
   504          */
   505         FLOAT_LITERAL(LiteralTree.class),
   507         /**
   508          * Used for instances of {@link LiteralTree} representing
   509          * a floating-point literal expression of type {@code double}.
   510          */
   511         DOUBLE_LITERAL(LiteralTree.class),
   513         /**
   514          * Used for instances of {@link LiteralTree} representing
   515          * a boolean literal expression of type {@code boolean}.
   516          */
   517         BOOLEAN_LITERAL(LiteralTree.class),
   519         /**
   520          * Used for instances of {@link LiteralTree} representing
   521          * a character literal expression of type {@code char}.
   522          */
   523         CHAR_LITERAL(LiteralTree.class),
   525         /**
   526          * Used for instances of {@link LiteralTree} representing
   527          * a string literal expression of type {@link String}.
   528          */
   529         STRING_LITERAL(LiteralTree.class),
   531         /**
   532          * Used for instances of {@link LiteralTree} representing
   533          * the use of {@code null}.
   534          */
   535         NULL_LITERAL(LiteralTree.class),
   537         /**
   538          * Used for instances of {@link WildcardTree} representing
   539          * an unbounded wildcard type argument.
   540          */
   541         UNBOUNDED_WILDCARD(WildcardTree.class),
   543         /**
   544          * Used for instances of {@link WildcardTree} representing
   545          * an extends bounded wildcard type argument.
   546          */
   547         EXTENDS_WILDCARD(WildcardTree.class),
   549         /**
   550          * Used for instances of {@link WildcardTree} representing
   551          * a super bounded wildcard type argument.
   552          */
   553         SUPER_WILDCARD(WildcardTree.class),
   555         /**
   556          * Used for instances of {@link ErroneousTree}.
   557          */
   558         ERRONEOUS(ErroneousTree.class),
   560         /**
   561          * Used for instances of {@link ClassTree} representing interfaces.
   562          */
   563         INTERFACE(ClassTree.class),
   565         /**
   566          * Used for instances of {@link ClassTree} representing enums.
   567          */
   568         ENUM(ClassTree.class),
   570         /**
   571          * Used for instances of {@link ClassTree} representing annotation types.
   572          */
   573         ANNOTATION_TYPE(ClassTree.class),
   575         /**
   576          * An implementation-reserved node. This is the not the node
   577          * you are looking for.
   578          */
   579         OTHER(null);
   582         Kind(Class<? extends Tree> intf) {
   583             associatedInterface = intf;
   584         }
   586         public Class<? extends Tree> asInterface() {
   587             return associatedInterface;
   588         }
   590         private final Class<? extends Tree> associatedInterface;
   591     }
   593     /**
   594      * Gets the kind of this tree.
   595      *
   596      * @return the kind of this tree.
   597      */
   598     Kind getKind();
   600     /**
   601      * Accept method used to implement the visitor pattern.  The
   602      * visitor pattern is used to implement operations on trees.
   603      *
   604      * @param <R> result type of this operation.
   605      * @param <D> type of additonal data.
   606      */
   607     <R,D> R accept(TreeVisitor<R,D> visitor, D data);
   608 }

mercurial