Thu, 24 Nov 2011 13:38:40 +0000
7115049: Add AST node for method references
Summary: Add tree nodes for representing method/constructor references and update relevant visitors interfaces
Reviewed-by: jjg
1 /*
2 * Copyright (c) 1999, 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.tools.javac.tree;
28 import java.util.*;
30 import java.io.IOException;
31 import java.io.StringWriter;
32 import javax.lang.model.element.Modifier;
33 import javax.lang.model.type.TypeKind;
34 import javax.tools.JavaFileObject;
36 import com.sun.tools.javac.util.*;
37 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
38 import com.sun.tools.javac.util.List;
39 import com.sun.tools.javac.code.*;
40 import com.sun.tools.javac.code.Scope.*;
41 import com.sun.tools.javac.code.Symbol.*;
42 import com.sun.tools.javac.parser.EndPosTable;
43 import com.sun.source.tree.*;
44 import com.sun.source.tree.LambdaExpressionTree.BodyKind;
45 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
47 import static com.sun.tools.javac.code.BoundKind.*;
48 import static com.sun.tools.javac.tree.JCTree.Tag.*;
50 /**
51 * Root class for abstract syntax tree nodes. It provides definitions
52 * for specific tree nodes as subclasses nested inside.
53 *
54 * <p>Each subclass is highly standardized. It generally contains
55 * only tree fields for the syntactic subcomponents of the node. Some
56 * classes that represent identifier uses or definitions also define a
57 * Symbol field that denotes the represented identifier. Classes for
58 * non-local jumps also carry the jump target as a field. The root
59 * class Tree itself defines fields for the tree's type and position.
60 * No other fields are kept in a tree node; instead parameters are
61 * passed to methods accessing the node.
62 *
63 * <p>Except for the methods defined by com.sun.source, the only
64 * method defined in subclasses is `visit' which applies a given
65 * visitor to the tree. The actual tree processing is done by visitor
66 * classes in other packages. The abstract class Visitor, as well as
67 * an Factory interface for trees, are defined as inner classes in
68 * Tree.
69 *
70 * <p>To avoid ambiguities with the Tree API in com.sun.source all sub
71 * classes should, by convention, start with JC (javac).
72 *
73 * <p><b>This is NOT part of any supported API.
74 * If you write code that depends on this, you do so at your own risk.
75 * This code and its internal interfaces are subject to change or
76 * deletion without notice.</b>
77 *
78 * @see TreeMaker
79 * @see TreeInfo
80 * @see TreeTranslator
81 * @see Pretty
82 */
83 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
85 /* Tree tag values, identifying kinds of trees */
86 public enum Tag{
87 /** For methods that return an invalid tag if a given condition is not met
88 */
89 NO_TAG,
91 /** Toplevel nodes, of type TopLevel, representing entire source files.
92 */
93 TOPLEVEL,
95 /** Import clauses, of type Import.
96 */
97 IMPORT,
99 /** Class definitions, of type ClassDef.
100 */
101 CLASSDEF,
103 /** Method definitions, of type MethodDef.
104 */
105 METHODDEF,
107 /** Variable definitions, of type VarDef.
108 */
109 VARDEF,
111 /** The no-op statement ";", of type Skip
112 */
113 SKIP,
115 /** Blocks, of type Block.
116 */
117 BLOCK,
119 /** Do-while loops, of type DoLoop.
120 */
121 DOLOOP,
123 /** While-loops, of type WhileLoop.
124 */
125 WHILELOOP,
127 /** For-loops, of type ForLoop.
128 */
129 FORLOOP,
131 /** Foreach-loops, of type ForeachLoop.
132 */
133 FOREACHLOOP,
135 /** Labelled statements, of type Labelled.
136 */
137 LABELLED,
139 /** Switch statements, of type Switch.
140 */
141 SWITCH,
143 /** Case parts in switch statements, of type Case.
144 */
145 CASE,
147 /** Synchronized statements, of type Synchonized.
148 */
149 SYNCHRONIZED,
151 /** Try statements, of type Try.
152 */
153 TRY,
155 /** Catch clauses in try statements, of type Catch.
156 */
157 CATCH,
159 /** Conditional expressions, of type Conditional.
160 */
161 CONDEXPR,
163 /** Conditional statements, of type If.
164 */
165 IF,
167 /** Expression statements, of type Exec.
168 */
169 EXEC,
171 /** Break statements, of type Break.
172 */
173 BREAK,
175 /** Continue statements, of type Continue.
176 */
177 CONTINUE,
179 /** Return statements, of type Return.
180 */
181 RETURN,
183 /** Throw statements, of type Throw.
184 */
185 THROW,
187 /** Assert statements, of type Assert.
188 */
189 ASSERT,
191 /** Method invocation expressions, of type Apply.
192 */
193 APPLY,
195 /** Class instance creation expressions, of type NewClass.
196 */
197 NEWCLASS,
199 /** Array creation expressions, of type NewArray.
200 */
201 NEWARRAY,
203 /** Lambda expression, of type Lambda.
204 */
205 LAMBDA,
207 /** Parenthesized subexpressions, of type Parens.
208 */
209 PARENS,
211 /** Assignment expressions, of type Assign.
212 */
213 ASSIGN,
215 /** Type cast expressions, of type TypeCast.
216 */
217 TYPECAST,
219 /** Type test expressions, of type TypeTest.
220 */
221 TYPETEST,
223 /** Indexed array expressions, of type Indexed.
224 */
225 INDEXED,
227 /** Selections, of type Select.
228 */
229 SELECT,
231 /** Member references, of type Reference.
232 */
233 REFERENCE,
235 /** Simple identifiers, of type Ident.
236 */
237 IDENT,
239 /** Literals, of type Literal.
240 */
241 LITERAL,
243 /** Basic type identifiers, of type TypeIdent.
244 */
245 TYPEIDENT,
247 /** Array types, of type TypeArray.
248 */
249 TYPEARRAY,
251 /** Parameterized types, of type TypeApply.
252 */
253 TYPEAPPLY,
255 /** Union types, of type TypeUnion
256 */
257 TYPEUNION,
259 /** Formal type parameters, of type TypeParameter.
260 */
261 TYPEPARAMETER,
263 /** Type argument.
264 */
265 WILDCARD,
267 /** Bound kind: extends, super, exact, or unbound
268 */
269 TYPEBOUNDKIND,
271 /** metadata: Annotation.
272 */
273 ANNOTATION,
275 /** metadata: Modifiers
276 */
277 MODIFIERS,
279 ANNOTATED_TYPE,
281 /** Error trees, of type Erroneous.
282 */
283 ERRONEOUS,
285 /** Unary operators, of type Unary.
286 */
287 POS, // +
288 NEG, // -
289 NOT, // !
290 COMPL, // ~
291 PREINC, // ++ _
292 PREDEC, // -- _
293 POSTINC, // _ ++
294 POSTDEC, // _ --
296 /** unary operator for null reference checks, only used internally.
297 */
298 NULLCHK,
300 /** Binary operators, of type Binary.
301 */
302 OR, // ||
303 AND, // &&
304 BITOR, // |
305 BITXOR, // ^
306 BITAND, // &
307 EQ, // ==
308 NE, // !=
309 LT, // <
310 GT, // >
311 LE, // <=
312 GE, // >=
313 SL, // <<
314 SR, // >>
315 USR, // >>>
316 PLUS, // +
317 MINUS, // -
318 MUL, // *
319 DIV, // /
320 MOD, // %
322 /** Assignment operators, of type Assignop.
323 */
324 BITOR_ASG(BITOR), // |=
325 BITXOR_ASG(BITXOR), // ^=
326 BITAND_ASG(BITAND), // &=
328 SL_ASG(SL), // <<=
329 SR_ASG(SR), // >>=
330 USR_ASG(USR), // >>>=
331 PLUS_ASG(PLUS), // +=
332 MINUS_ASG(MINUS), // -=
333 MUL_ASG(MUL), // *=
334 DIV_ASG(DIV), // /=
335 MOD_ASG(MOD), // %=
337 /** A synthetic let expression, of type LetExpr.
338 */
339 LETEXPR; // ala scheme
341 private Tag noAssignTag;
343 private static int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
345 private Tag(Tag noAssignTag) {
346 this.noAssignTag = noAssignTag;
347 }
349 private Tag() { }
351 public static int getNumberOfOperators() {
352 return numberOfOperators;
353 }
355 public Tag noAssignOp() {
356 if (noAssignTag != null)
357 return noAssignTag;
358 throw new AssertionError("noAssignOp() method is not available for non assignment tags");
359 }
361 public boolean isPostUnaryOp() {
362 return (this == POSTINC || this == POSTDEC);
363 }
365 public boolean isIncOrDecUnaryOp() {
366 return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC);
367 }
369 public boolean isAssignop() {
370 return noAssignTag != null;
371 }
373 public int operatorIndex() {
374 return (this.ordinal() - POS.ordinal());
375 }
376 }
378 /* The (encoded) position in the source file. @see util.Position.
379 */
380 public int pos;
382 /* The type of this node.
383 */
384 public Type type;
386 /* The tag of this node -- one of the constants declared above.
387 */
388 public abstract Tag getTag();
390 /* Returns true if the tag of this node is equals to tag.
391 */
392 public boolean hasTag(Tag tag) {
393 return tag == getTag();
394 }
396 /** Convert a tree to a pretty-printed string. */
397 @Override
398 public String toString() {
399 StringWriter s = new StringWriter();
400 try {
401 new Pretty(s, false).printExpr(this);
402 }
403 catch (IOException e) {
404 // should never happen, because StringWriter is defined
405 // never to throw any IOExceptions
406 throw new AssertionError(e);
407 }
408 return s.toString();
409 }
411 /** Set position field and return this tree.
412 */
413 public JCTree setPos(int pos) {
414 this.pos = pos;
415 return this;
416 }
418 /** Set type field and return this tree.
419 */
420 public JCTree setType(Type type) {
421 this.type = type;
422 return this;
423 }
425 /** Visit this tree with a given visitor.
426 */
427 public abstract void accept(Visitor v);
429 public abstract <R,D> R accept(TreeVisitor<R,D> v, D d);
431 /** Return a shallow copy of this tree.
432 */
433 @Override
434 public Object clone() {
435 try {
436 return super.clone();
437 } catch(CloneNotSupportedException e) {
438 throw new RuntimeException(e);
439 }
440 }
442 /** Get a default position for this tree node.
443 */
444 public DiagnosticPosition pos() {
445 return this;
446 }
448 // for default DiagnosticPosition
449 public JCTree getTree() {
450 return this;
451 }
453 // for default DiagnosticPosition
454 public int getStartPosition() {
455 return TreeInfo.getStartPos(this);
456 }
458 // for default DiagnosticPosition
459 public int getPreferredPosition() {
460 return pos;
461 }
463 // for default DiagnosticPosition
464 public int getEndPosition(EndPosTable endPosTable) {
465 return TreeInfo.getEndPos(this, endPosTable);
466 }
468 /**
469 * Everything in one source file is kept in a TopLevel structure.
470 * @param pid The tree representing the package clause.
471 * @param sourcefile The source file name.
472 * @param defs All definitions in this file (ClassDef, Import, and Skip)
473 * @param packge The package it belongs to.
474 * @param namedImportScope A scope for all named imports.
475 * @param starImportScope A scope for all import-on-demands.
476 * @param lineMap Line starting positions, defined only
477 * if option -g is set.
478 * @param docComments A hashtable that stores all documentation comments
479 * indexed by the tree nodes they refer to.
480 * defined only if option -s is set.
481 * @param endPositions An object encapsulating ending positions of source
482 * ranges indexed by the tree nodes they belong to.
483 * Defined only if option -Xjcov is set.
484 */
485 public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
486 public List<JCAnnotation> packageAnnotations;
487 public JCExpression pid;
488 public List<JCTree> defs;
489 public JavaFileObject sourcefile;
490 public PackageSymbol packge;
491 public ImportScope namedImportScope;
492 public StarImportScope starImportScope;
493 public Position.LineMap lineMap = null;
494 public Map<JCTree, String> docComments = null;
495 public EndPosTable endPositions = null;
496 protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
497 JCExpression pid,
498 List<JCTree> defs,
499 JavaFileObject sourcefile,
500 PackageSymbol packge,
501 ImportScope namedImportScope,
502 StarImportScope starImportScope) {
503 this.packageAnnotations = packageAnnotations;
504 this.pid = pid;
505 this.defs = defs;
506 this.sourcefile = sourcefile;
507 this.packge = packge;
508 this.namedImportScope = namedImportScope;
509 this.starImportScope = starImportScope;
510 }
511 @Override
512 public void accept(Visitor v) { v.visitTopLevel(this); }
514 public Kind getKind() { return Kind.COMPILATION_UNIT; }
515 public List<JCAnnotation> getPackageAnnotations() {
516 return packageAnnotations;
517 }
518 public List<JCImport> getImports() {
519 ListBuffer<JCImport> imports = new ListBuffer<JCImport>();
520 for (JCTree tree : defs) {
521 if (tree.hasTag(IMPORT))
522 imports.append((JCImport)tree);
523 else if (!tree.hasTag(SKIP))
524 break;
525 }
526 return imports.toList();
527 }
528 public JCExpression getPackageName() { return pid; }
529 public JavaFileObject getSourceFile() {
530 return sourcefile;
531 }
532 public Position.LineMap getLineMap() {
533 return lineMap;
534 }
535 public List<JCTree> getTypeDecls() {
536 List<JCTree> typeDefs;
537 for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail)
538 if (!typeDefs.head.hasTag(IMPORT))
539 break;
540 return typeDefs;
541 }
542 @Override
543 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
544 return v.visitCompilationUnit(this, d);
545 }
547 @Override
548 public Tag getTag() {
549 return TOPLEVEL;
550 }
551 }
553 /**
554 * An import clause.
555 * @param qualid The imported class(es).
556 */
557 public static class JCImport extends JCTree implements ImportTree {
558 public boolean staticImport;
559 public JCTree qualid;
560 protected JCImport(JCTree qualid, boolean importStatic) {
561 this.qualid = qualid;
562 this.staticImport = importStatic;
563 }
564 @Override
565 public void accept(Visitor v) { v.visitImport(this); }
567 public boolean isStatic() { return staticImport; }
568 public JCTree getQualifiedIdentifier() { return qualid; }
570 public Kind getKind() { return Kind.IMPORT; }
571 @Override
572 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
573 return v.visitImport(this, d);
574 }
576 @Override
577 public Tag getTag() {
578 return IMPORT;
579 }
580 }
582 public static abstract class JCStatement extends JCTree implements StatementTree {
583 @Override
584 public JCStatement setType(Type type) {
585 super.setType(type);
586 return this;
587 }
588 @Override
589 public JCStatement setPos(int pos) {
590 super.setPos(pos);
591 return this;
592 }
593 }
595 public static abstract class JCExpression extends JCTree implements ExpressionTree {
596 @Override
597 public JCExpression setType(Type type) {
598 super.setType(type);
599 return this;
600 }
601 @Override
602 public JCExpression setPos(int pos) {
603 super.setPos(pos);
604 return this;
605 }
606 }
608 /**
609 * A class definition.
610 * @param modifiers the modifiers
611 * @param name the name of the class
612 * @param typarams formal class parameters
613 * @param extending the classes this class extends
614 * @param implementing the interfaces implemented by this class
615 * @param defs all variables and methods defined in this class
616 * @param sym the symbol
617 */
618 public static class JCClassDecl extends JCStatement implements ClassTree {
619 public JCModifiers mods;
620 public Name name;
621 public List<JCTypeParameter> typarams;
622 public JCExpression extending;
623 public List<JCExpression> implementing;
624 public List<JCTree> defs;
625 public ClassSymbol sym;
626 protected JCClassDecl(JCModifiers mods,
627 Name name,
628 List<JCTypeParameter> typarams,
629 JCExpression extending,
630 List<JCExpression> implementing,
631 List<JCTree> defs,
632 ClassSymbol sym)
633 {
634 this.mods = mods;
635 this.name = name;
636 this.typarams = typarams;
637 this.extending = extending;
638 this.implementing = implementing;
639 this.defs = defs;
640 this.sym = sym;
641 }
642 @Override
643 public void accept(Visitor v) { v.visitClassDef(this); }
645 public Kind getKind() {
646 if ((mods.flags & Flags.ANNOTATION) != 0)
647 return Kind.ANNOTATION_TYPE;
648 else if ((mods.flags & Flags.INTERFACE) != 0)
649 return Kind.INTERFACE;
650 else if ((mods.flags & Flags.ENUM) != 0)
651 return Kind.ENUM;
652 else
653 return Kind.CLASS;
654 }
656 public JCModifiers getModifiers() { return mods; }
657 public Name getSimpleName() { return name; }
658 public List<JCTypeParameter> getTypeParameters() {
659 return typarams;
660 }
661 public JCTree getExtendsClause() { return extending; }
662 public List<JCExpression> getImplementsClause() {
663 return implementing;
664 }
665 public List<JCTree> getMembers() {
666 return defs;
667 }
668 @Override
669 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
670 return v.visitClass(this, d);
671 }
673 @Override
674 public Tag getTag() {
675 return CLASSDEF;
676 }
677 }
679 /**
680 * A method definition.
681 * @param modifiers method modifiers
682 * @param name method name
683 * @param restype type of method return value
684 * @param typarams type parameters
685 * @param params value parameters
686 * @param thrown exceptions thrown by this method
687 * @param stats statements in the method
688 * @param sym method symbol
689 */
690 public static class JCMethodDecl extends JCTree implements MethodTree {
691 public JCModifiers mods;
692 public Name name;
693 public JCExpression restype;
694 public List<JCTypeParameter> typarams;
695 public List<JCVariableDecl> params;
696 public List<JCExpression> thrown;
697 public JCBlock body;
698 public JCExpression defaultValue; // for annotation types
699 public MethodSymbol sym;
700 protected JCMethodDecl(JCModifiers mods,
701 Name name,
702 JCExpression restype,
703 List<JCTypeParameter> typarams,
704 List<JCVariableDecl> params,
705 List<JCExpression> thrown,
706 JCBlock body,
707 JCExpression defaultValue,
708 MethodSymbol sym)
709 {
710 this.mods = mods;
711 this.name = name;
712 this.restype = restype;
713 this.typarams = typarams;
714 this.params = params;
715 this.thrown = thrown;
716 this.body = body;
717 this.defaultValue = defaultValue;
718 this.sym = sym;
719 }
720 @Override
721 public void accept(Visitor v) { v.visitMethodDef(this); }
723 public Kind getKind() { return Kind.METHOD; }
724 public JCModifiers getModifiers() { return mods; }
725 public Name getName() { return name; }
726 public JCTree getReturnType() { return restype; }
727 public List<JCTypeParameter> getTypeParameters() {
728 return typarams;
729 }
730 public List<JCVariableDecl> getParameters() {
731 return params;
732 }
733 public List<JCExpression> getThrows() {
734 return thrown;
735 }
736 public JCBlock getBody() { return body; }
737 public JCTree getDefaultValue() { // for annotation types
738 return defaultValue;
739 }
740 @Override
741 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
742 return v.visitMethod(this, d);
743 }
745 @Override
746 public Tag getTag() {
747 return METHODDEF;
748 }
749 }
751 /**
752 * A variable definition.
753 * @param modifiers variable modifiers
754 * @param name variable name
755 * @param vartype type of the variable
756 * @param init variables initial value
757 * @param sym symbol
758 */
759 public static class JCVariableDecl extends JCStatement implements VariableTree {
760 public JCModifiers mods;
761 public Name name;
762 public JCExpression vartype;
763 public JCExpression init;
764 public VarSymbol sym;
765 protected JCVariableDecl(JCModifiers mods,
766 Name name,
767 JCExpression vartype,
768 JCExpression init,
769 VarSymbol sym) {
770 this.mods = mods;
771 this.name = name;
772 this.vartype = vartype;
773 this.init = init;
774 this.sym = sym;
775 }
776 @Override
777 public void accept(Visitor v) { v.visitVarDef(this); }
779 public Kind getKind() { return Kind.VARIABLE; }
780 public JCModifiers getModifiers() { return mods; }
781 public Name getName() { return name; }
782 public JCTree getType() { return vartype; }
783 public JCExpression getInitializer() {
784 return init;
785 }
786 @Override
787 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
788 return v.visitVariable(this, d);
789 }
791 @Override
792 public Tag getTag() {
793 return VARDEF;
794 }
795 }
797 /**
798 * A no-op statement ";".
799 */
800 public static class JCSkip extends JCStatement implements EmptyStatementTree {
801 protected JCSkip() {
802 }
803 @Override
804 public void accept(Visitor v) { v.visitSkip(this); }
806 public Kind getKind() { return Kind.EMPTY_STATEMENT; }
807 @Override
808 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
809 return v.visitEmptyStatement(this, d);
810 }
812 @Override
813 public Tag getTag() {
814 return SKIP;
815 }
816 }
818 /**
819 * A statement block.
820 * @param stats statements
821 * @param flags flags
822 */
823 public static class JCBlock extends JCStatement implements BlockTree {
824 public long flags;
825 public List<JCStatement> stats;
826 /** Position of closing brace, optional. */
827 public int endpos = Position.NOPOS;
828 protected JCBlock(long flags, List<JCStatement> stats) {
829 this.stats = stats;
830 this.flags = flags;
831 }
832 @Override
833 public void accept(Visitor v) { v.visitBlock(this); }
835 public Kind getKind() { return Kind.BLOCK; }
836 public List<JCStatement> getStatements() {
837 return stats;
838 }
839 public boolean isStatic() { return (flags & Flags.STATIC) != 0; }
840 @Override
841 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
842 return v.visitBlock(this, d);
843 }
845 @Override
846 public Tag getTag() {
847 return BLOCK;
848 }
849 }
851 /**
852 * A do loop
853 */
854 public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree {
855 public JCStatement body;
856 public JCExpression cond;
857 protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
858 this.body = body;
859 this.cond = cond;
860 }
861 @Override
862 public void accept(Visitor v) { v.visitDoLoop(this); }
864 public Kind getKind() { return Kind.DO_WHILE_LOOP; }
865 public JCExpression getCondition() { return cond; }
866 public JCStatement getStatement() { return body; }
867 @Override
868 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
869 return v.visitDoWhileLoop(this, d);
870 }
872 @Override
873 public Tag getTag() {
874 return DOLOOP;
875 }
876 }
878 /**
879 * A while loop
880 */
881 public static class JCWhileLoop extends JCStatement implements WhileLoopTree {
882 public JCExpression cond;
883 public JCStatement body;
884 protected JCWhileLoop(JCExpression cond, JCStatement body) {
885 this.cond = cond;
886 this.body = body;
887 }
888 @Override
889 public void accept(Visitor v) { v.visitWhileLoop(this); }
891 public Kind getKind() { return Kind.WHILE_LOOP; }
892 public JCExpression getCondition() { return cond; }
893 public JCStatement getStatement() { return body; }
894 @Override
895 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
896 return v.visitWhileLoop(this, d);
897 }
899 @Override
900 public Tag getTag() {
901 return WHILELOOP;
902 }
903 }
905 /**
906 * A for loop.
907 */
908 public static class JCForLoop extends JCStatement implements ForLoopTree {
909 public List<JCStatement> init;
910 public JCExpression cond;
911 public List<JCExpressionStatement> step;
912 public JCStatement body;
913 protected JCForLoop(List<JCStatement> init,
914 JCExpression cond,
915 List<JCExpressionStatement> update,
916 JCStatement body)
917 {
918 this.init = init;
919 this.cond = cond;
920 this.step = update;
921 this.body = body;
922 }
923 @Override
924 public void accept(Visitor v) { v.visitForLoop(this); }
926 public Kind getKind() { return Kind.FOR_LOOP; }
927 public JCExpression getCondition() { return cond; }
928 public JCStatement getStatement() { return body; }
929 public List<JCStatement> getInitializer() {
930 return init;
931 }
932 public List<JCExpressionStatement> getUpdate() {
933 return step;
934 }
935 @Override
936 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
937 return v.visitForLoop(this, d);
938 }
940 @Override
941 public Tag getTag() {
942 return FORLOOP;
943 }
944 }
946 /**
947 * The enhanced for loop.
948 */
949 public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree {
950 public JCVariableDecl var;
951 public JCExpression expr;
952 public JCStatement body;
953 protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
954 this.var = var;
955 this.expr = expr;
956 this.body = body;
957 }
958 @Override
959 public void accept(Visitor v) { v.visitForeachLoop(this); }
961 public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; }
962 public JCVariableDecl getVariable() { return var; }
963 public JCExpression getExpression() { return expr; }
964 public JCStatement getStatement() { return body; }
965 @Override
966 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
967 return v.visitEnhancedForLoop(this, d);
968 }
969 @Override
970 public Tag getTag() {
971 return FOREACHLOOP;
972 }
973 }
975 /**
976 * A labelled expression or statement.
977 */
978 public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree {
979 public Name label;
980 public JCStatement body;
981 protected JCLabeledStatement(Name label, JCStatement body) {
982 this.label = label;
983 this.body = body;
984 }
985 @Override
986 public void accept(Visitor v) { v.visitLabelled(this); }
987 public Kind getKind() { return Kind.LABELED_STATEMENT; }
988 public Name getLabel() { return label; }
989 public JCStatement getStatement() { return body; }
990 @Override
991 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
992 return v.visitLabeledStatement(this, d);
993 }
994 @Override
995 public Tag getTag() {
996 return LABELLED;
997 }
998 }
1000 /**
1001 * A "switch ( ) { }" construction.
1002 */
1003 public static class JCSwitch extends JCStatement implements SwitchTree {
1004 public JCExpression selector;
1005 public List<JCCase> cases;
1006 protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1007 this.selector = selector;
1008 this.cases = cases;
1009 }
1010 @Override
1011 public void accept(Visitor v) { v.visitSwitch(this); }
1013 public Kind getKind() { return Kind.SWITCH; }
1014 public JCExpression getExpression() { return selector; }
1015 public List<JCCase> getCases() { return cases; }
1016 @Override
1017 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1018 return v.visitSwitch(this, d);
1019 }
1020 @Override
1021 public Tag getTag() {
1022 return SWITCH;
1023 }
1024 }
1026 /**
1027 * A "case :" of a switch.
1028 */
1029 public static class JCCase extends JCStatement implements CaseTree {
1030 public JCExpression pat;
1031 public List<JCStatement> stats;
1032 protected JCCase(JCExpression pat, List<JCStatement> stats) {
1033 this.pat = pat;
1034 this.stats = stats;
1035 }
1036 @Override
1037 public void accept(Visitor v) { v.visitCase(this); }
1039 public Kind getKind() { return Kind.CASE; }
1040 public JCExpression getExpression() { return pat; }
1041 public List<JCStatement> getStatements() { return stats; }
1042 @Override
1043 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1044 return v.visitCase(this, d);
1045 }
1046 @Override
1047 public Tag getTag() {
1048 return CASE;
1049 }
1050 }
1052 /**
1053 * A synchronized block.
1054 */
1055 public static class JCSynchronized extends JCStatement implements SynchronizedTree {
1056 public JCExpression lock;
1057 public JCBlock body;
1058 protected JCSynchronized(JCExpression lock, JCBlock body) {
1059 this.lock = lock;
1060 this.body = body;
1061 }
1062 @Override
1063 public void accept(Visitor v) { v.visitSynchronized(this); }
1065 public Kind getKind() { return Kind.SYNCHRONIZED; }
1066 public JCExpression getExpression() { return lock; }
1067 public JCBlock getBlock() { return body; }
1068 @Override
1069 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1070 return v.visitSynchronized(this, d);
1071 }
1072 @Override
1073 public Tag getTag() {
1074 return SYNCHRONIZED;
1075 }
1076 }
1078 /**
1079 * A "try { } catch ( ) { } finally { }" block.
1080 */
1081 public static class JCTry extends JCStatement implements TryTree {
1082 public JCBlock body;
1083 public List<JCCatch> catchers;
1084 public JCBlock finalizer;
1085 public List<JCTree> resources;
1086 protected JCTry(List<JCTree> resources,
1087 JCBlock body,
1088 List<JCCatch> catchers,
1089 JCBlock finalizer) {
1090 this.body = body;
1091 this.catchers = catchers;
1092 this.finalizer = finalizer;
1093 this.resources = resources;
1094 }
1095 @Override
1096 public void accept(Visitor v) { v.visitTry(this); }
1098 public Kind getKind() { return Kind.TRY; }
1099 public JCBlock getBlock() { return body; }
1100 public List<JCCatch> getCatches() {
1101 return catchers;
1102 }
1103 public JCBlock getFinallyBlock() { return finalizer; }
1104 @Override
1105 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1106 return v.visitTry(this, d);
1107 }
1108 @Override
1109 public List<? extends JCTree> getResources() {
1110 return resources;
1111 }
1112 @Override
1113 public Tag getTag() {
1114 return TRY;
1115 }
1116 }
1118 /**
1119 * A catch block.
1120 */
1121 public static class JCCatch extends JCTree implements CatchTree {
1122 public JCVariableDecl param;
1123 public JCBlock body;
1124 protected JCCatch(JCVariableDecl param, JCBlock body) {
1125 this.param = param;
1126 this.body = body;
1127 }
1128 @Override
1129 public void accept(Visitor v) { v.visitCatch(this); }
1131 public Kind getKind() { return Kind.CATCH; }
1132 public JCVariableDecl getParameter() { return param; }
1133 public JCBlock getBlock() { return body; }
1134 @Override
1135 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1136 return v.visitCatch(this, d);
1137 }
1138 @Override
1139 public Tag getTag() {
1140 return CATCH;
1141 }
1142 }
1144 /**
1145 * A ( ) ? ( ) : ( ) conditional expression
1146 */
1147 public static class JCConditional extends JCExpression implements ConditionalExpressionTree {
1148 public JCExpression cond;
1149 public JCExpression truepart;
1150 public JCExpression falsepart;
1151 protected JCConditional(JCExpression cond,
1152 JCExpression truepart,
1153 JCExpression falsepart)
1154 {
1155 this.cond = cond;
1156 this.truepart = truepart;
1157 this.falsepart = falsepart;
1158 }
1159 @Override
1160 public void accept(Visitor v) { v.visitConditional(this); }
1162 public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
1163 public JCExpression getCondition() { return cond; }
1164 public JCExpression getTrueExpression() { return truepart; }
1165 public JCExpression getFalseExpression() { return falsepart; }
1166 @Override
1167 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1168 return v.visitConditionalExpression(this, d);
1169 }
1170 @Override
1171 public Tag getTag() {
1172 return CONDEXPR;
1173 }
1174 }
1176 /**
1177 * An "if ( ) { } else { }" block
1178 */
1179 public static class JCIf extends JCStatement implements IfTree {
1180 public JCExpression cond;
1181 public JCStatement thenpart;
1182 public JCStatement elsepart;
1183 protected JCIf(JCExpression cond,
1184 JCStatement thenpart,
1185 JCStatement elsepart)
1186 {
1187 this.cond = cond;
1188 this.thenpart = thenpart;
1189 this.elsepart = elsepart;
1190 }
1191 @Override
1192 public void accept(Visitor v) { v.visitIf(this); }
1194 public Kind getKind() { return Kind.IF; }
1195 public JCExpression getCondition() { return cond; }
1196 public JCStatement getThenStatement() { return thenpart; }
1197 public JCStatement getElseStatement() { return elsepart; }
1198 @Override
1199 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1200 return v.visitIf(this, d);
1201 }
1202 @Override
1203 public Tag getTag() {
1204 return IF;
1205 }
1206 }
1208 /**
1209 * an expression statement
1210 * @param expr expression structure
1211 */
1212 public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1213 public JCExpression expr;
1214 protected JCExpressionStatement(JCExpression expr)
1215 {
1216 this.expr = expr;
1217 }
1218 @Override
1219 public void accept(Visitor v) { v.visitExec(this); }
1221 public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
1222 public JCExpression getExpression() { return expr; }
1223 @Override
1224 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1225 return v.visitExpressionStatement(this, d);
1226 }
1227 @Override
1228 public Tag getTag() {
1229 return EXEC;
1230 }
1232 /** Convert a expression-statement tree to a pretty-printed string. */
1233 @Override
1234 public String toString() {
1235 StringWriter s = new StringWriter();
1236 try {
1237 new Pretty(s, false).printStat(this);
1238 }
1239 catch (IOException e) {
1240 // should never happen, because StringWriter is defined
1241 // never to throw any IOExceptions
1242 throw new AssertionError(e);
1243 }
1244 return s.toString();
1245 }
1246 }
1248 /**
1249 * A break from a loop or switch.
1250 */
1251 public static class JCBreak extends JCStatement implements BreakTree {
1252 public Name label;
1253 public JCTree target;
1254 protected JCBreak(Name label, JCTree target) {
1255 this.label = label;
1256 this.target = target;
1257 }
1258 @Override
1259 public void accept(Visitor v) { v.visitBreak(this); }
1261 public Kind getKind() { return Kind.BREAK; }
1262 public Name getLabel() { return label; }
1263 @Override
1264 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1265 return v.visitBreak(this, d);
1266 }
1267 @Override
1268 public Tag getTag() {
1269 return BREAK;
1270 }
1271 }
1273 /**
1274 * A continue of a loop.
1275 */
1276 public static class JCContinue extends JCStatement implements ContinueTree {
1277 public Name label;
1278 public JCTree target;
1279 protected JCContinue(Name label, JCTree target) {
1280 this.label = label;
1281 this.target = target;
1282 }
1283 @Override
1284 public void accept(Visitor v) { v.visitContinue(this); }
1286 public Kind getKind() { return Kind.CONTINUE; }
1287 public Name getLabel() { return label; }
1288 @Override
1289 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1290 return v.visitContinue(this, d);
1291 }
1292 @Override
1293 public Tag getTag() {
1294 return CONTINUE;
1295 }
1296 }
1298 /**
1299 * A return statement.
1300 */
1301 public static class JCReturn extends JCStatement implements ReturnTree {
1302 public JCExpression expr;
1303 protected JCReturn(JCExpression expr) {
1304 this.expr = expr;
1305 }
1306 @Override
1307 public void accept(Visitor v) { v.visitReturn(this); }
1309 public Kind getKind() { return Kind.RETURN; }
1310 public JCExpression getExpression() { return expr; }
1311 @Override
1312 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1313 return v.visitReturn(this, d);
1314 }
1315 @Override
1316 public Tag getTag() {
1317 return RETURN;
1318 }
1319 }
1321 /**
1322 * A throw statement.
1323 */
1324 public static class JCThrow extends JCStatement implements ThrowTree {
1325 public JCExpression expr;
1326 protected JCThrow(JCTree expr) {
1327 this.expr = (JCExpression)expr;
1328 }
1329 @Override
1330 public void accept(Visitor v) { v.visitThrow(this); }
1332 public Kind getKind() { return Kind.THROW; }
1333 public JCExpression getExpression() { return expr; }
1334 @Override
1335 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1336 return v.visitThrow(this, d);
1337 }
1338 @Override
1339 public Tag getTag() {
1340 return THROW;
1341 }
1342 }
1344 /**
1345 * An assert statement.
1346 */
1347 public static class JCAssert extends JCStatement implements AssertTree {
1348 public JCExpression cond;
1349 public JCExpression detail;
1350 protected JCAssert(JCExpression cond, JCExpression detail) {
1351 this.cond = cond;
1352 this.detail = detail;
1353 }
1354 @Override
1355 public void accept(Visitor v) { v.visitAssert(this); }
1357 public Kind getKind() { return Kind.ASSERT; }
1358 public JCExpression getCondition() { return cond; }
1359 public JCExpression getDetail() { return detail; }
1360 @Override
1361 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1362 return v.visitAssert(this, d);
1363 }
1364 @Override
1365 public Tag getTag() {
1366 return ASSERT;
1367 }
1368 }
1370 /**
1371 * A method invocation
1372 */
1373 public static class JCMethodInvocation extends JCExpression implements MethodInvocationTree {
1374 public List<JCExpression> typeargs;
1375 public JCExpression meth;
1376 public List<JCExpression> args;
1377 public Type varargsElement;
1378 protected JCMethodInvocation(List<JCExpression> typeargs,
1379 JCExpression meth,
1380 List<JCExpression> args)
1381 {
1382 this.typeargs = (typeargs == null) ? List.<JCExpression>nil()
1383 : typeargs;
1384 this.meth = meth;
1385 this.args = args;
1386 }
1387 @Override
1388 public void accept(Visitor v) { v.visitApply(this); }
1390 public Kind getKind() { return Kind.METHOD_INVOCATION; }
1391 public List<JCExpression> getTypeArguments() {
1392 return typeargs;
1393 }
1394 public JCExpression getMethodSelect() { return meth; }
1395 public List<JCExpression> getArguments() {
1396 return args;
1397 }
1398 @Override
1399 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1400 return v.visitMethodInvocation(this, d);
1401 }
1402 @Override
1403 public JCMethodInvocation setType(Type type) {
1404 super.setType(type);
1405 return this;
1406 }
1407 @Override
1408 public Tag getTag() {
1409 return(APPLY);
1410 }
1411 }
1413 /**
1414 * A new(...) operation.
1415 */
1416 public static class JCNewClass extends JCExpression implements NewClassTree {
1417 public JCExpression encl;
1418 public List<JCExpression> typeargs;
1419 public JCExpression clazz;
1420 public List<JCExpression> args;
1421 public JCClassDecl def;
1422 public Symbol constructor;
1423 public Type varargsElement;
1424 public Type constructorType;
1425 protected JCNewClass(JCExpression encl,
1426 List<JCExpression> typeargs,
1427 JCExpression clazz,
1428 List<JCExpression> args,
1429 JCClassDecl def)
1430 {
1431 this.encl = encl;
1432 this.typeargs = (typeargs == null) ? List.<JCExpression>nil()
1433 : typeargs;
1434 this.clazz = clazz;
1435 this.args = args;
1436 this.def = def;
1437 }
1438 @Override
1439 public void accept(Visitor v) { v.visitNewClass(this); }
1441 public Kind getKind() { return Kind.NEW_CLASS; }
1442 public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1443 return encl;
1444 }
1445 public List<JCExpression> getTypeArguments() {
1446 return typeargs;
1447 }
1448 public JCExpression getIdentifier() { return clazz; }
1449 public List<JCExpression> getArguments() {
1450 return args;
1451 }
1452 public JCClassDecl getClassBody() { return def; }
1453 @Override
1454 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1455 return v.visitNewClass(this, d);
1456 }
1457 @Override
1458 public Tag getTag() {
1459 return NEWCLASS;
1460 }
1461 }
1463 /**
1464 * A new[...] operation.
1465 */
1466 public static class JCNewArray extends JCExpression implements NewArrayTree {
1467 public JCExpression elemtype;
1468 public List<JCExpression> dims;
1469 public List<JCExpression> elems;
1470 protected JCNewArray(JCExpression elemtype,
1471 List<JCExpression> dims,
1472 List<JCExpression> elems)
1473 {
1474 this.elemtype = elemtype;
1475 this.dims = dims;
1476 this.elems = elems;
1477 }
1478 @Override
1479 public void accept(Visitor v) { v.visitNewArray(this); }
1481 public Kind getKind() { return Kind.NEW_ARRAY; }
1482 public JCExpression getType() { return elemtype; }
1483 public List<JCExpression> getDimensions() {
1484 return dims;
1485 }
1486 public List<JCExpression> getInitializers() {
1487 return elems;
1488 }
1489 @Override
1490 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1491 return v.visitNewArray(this, d);
1492 }
1493 @Override
1494 public Tag getTag() {
1495 return NEWARRAY;
1496 }
1497 }
1499 /**
1500 * A lambda expression.
1501 */
1502 public static class JCLambda extends JCExpression implements LambdaExpressionTree {
1504 public List<JCVariableDecl> params;
1505 public JCTree body;
1506 public Type targetType;
1507 public boolean canCompleteNormally = true;
1508 public List<Type> inferredThrownTypes;
1510 public JCLambda(List<JCVariableDecl> params,
1511 JCTree body) {
1512 this.params = params;
1513 this.body = body;
1514 }
1515 @Override
1516 public Tag getTag() {
1517 return LAMBDA;
1518 }
1519 @Override
1520 public void accept(Visitor v) {
1521 v.visitLambda(this);
1522 }
1523 @Override
1524 public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1525 return v.visitLambdaExpression(this, d);
1526 }
1527 public Kind getKind() {
1528 return Kind.LAMBDA_EXPRESSION;
1529 }
1530 public JCTree getBody() {
1531 return body;
1532 }
1533 public java.util.List<? extends VariableTree> getParameters() {
1534 return params;
1535 }
1536 @Override
1537 public JCLambda setType(Type type) {
1538 super.setType(type);
1539 return this;
1540 }
1541 @Override
1542 public BodyKind getBodyKind() {
1543 return body.hasTag(BLOCK) ?
1544 BodyKind.STATEMENT :
1545 BodyKind.EXPRESSION;
1546 }
1547 }
1549 /**
1550 * A parenthesized subexpression ( ... )
1551 */
1552 public static class JCParens extends JCExpression implements ParenthesizedTree {
1553 public JCExpression expr;
1554 protected JCParens(JCExpression expr) {
1555 this.expr = expr;
1556 }
1557 @Override
1558 public void accept(Visitor v) { v.visitParens(this); }
1560 public Kind getKind() { return Kind.PARENTHESIZED; }
1561 public JCExpression getExpression() { return expr; }
1562 @Override
1563 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1564 return v.visitParenthesized(this, d);
1565 }
1566 @Override
1567 public Tag getTag() {
1568 return PARENS;
1569 }
1570 }
1572 /**
1573 * A assignment with "=".
1574 */
1575 public static class JCAssign extends JCExpression implements AssignmentTree {
1576 public JCExpression lhs;
1577 public JCExpression rhs;
1578 protected JCAssign(JCExpression lhs, JCExpression rhs) {
1579 this.lhs = lhs;
1580 this.rhs = rhs;
1581 }
1582 @Override
1583 public void accept(Visitor v) { v.visitAssign(this); }
1585 public Kind getKind() { return Kind.ASSIGNMENT; }
1586 public JCExpression getVariable() { return lhs; }
1587 public JCExpression getExpression() { return rhs; }
1588 @Override
1589 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1590 return v.visitAssignment(this, d);
1591 }
1592 @Override
1593 public Tag getTag() {
1594 return ASSIGN;
1595 }
1596 }
1598 /**
1599 * An assignment with "+=", "|=" ...
1600 */
1601 public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree {
1602 private Tag opcode;
1603 public JCExpression lhs;
1604 public JCExpression rhs;
1605 public Symbol operator;
1606 protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) {
1607 this.opcode = opcode;
1608 this.lhs = (JCExpression)lhs;
1609 this.rhs = (JCExpression)rhs;
1610 this.operator = operator;
1611 }
1612 @Override
1613 public void accept(Visitor v) { v.visitAssignop(this); }
1615 public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
1616 public JCExpression getVariable() { return lhs; }
1617 public JCExpression getExpression() { return rhs; }
1618 public Symbol getOperator() {
1619 return operator;
1620 }
1621 @Override
1622 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1623 return v.visitCompoundAssignment(this, d);
1624 }
1625 @Override
1626 public Tag getTag() {
1627 return opcode;
1628 }
1629 }
1631 /**
1632 * A unary operation.
1633 */
1634 public static class JCUnary extends JCExpression implements UnaryTree {
1635 private Tag opcode;
1636 public JCExpression arg;
1637 public Symbol operator;
1638 protected JCUnary(Tag opcode, JCExpression arg) {
1639 this.opcode = opcode;
1640 this.arg = arg;
1641 }
1642 @Override
1643 public void accept(Visitor v) { v.visitUnary(this); }
1645 public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
1646 public JCExpression getExpression() { return arg; }
1647 public Symbol getOperator() {
1648 return operator;
1649 }
1650 @Override
1651 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1652 return v.visitUnary(this, d);
1653 }
1654 @Override
1655 public Tag getTag() {
1656 return opcode;
1657 }
1659 public void setTag(Tag tag) {
1660 opcode = tag;
1661 }
1662 }
1664 /**
1665 * A binary operation.
1666 */
1667 public static class JCBinary extends JCExpression implements BinaryTree {
1668 private Tag opcode;
1669 public JCExpression lhs;
1670 public JCExpression rhs;
1671 public Symbol operator;
1672 protected JCBinary(Tag opcode,
1673 JCExpression lhs,
1674 JCExpression rhs,
1675 Symbol operator) {
1676 this.opcode = opcode;
1677 this.lhs = lhs;
1678 this.rhs = rhs;
1679 this.operator = operator;
1680 }
1681 @Override
1682 public void accept(Visitor v) { v.visitBinary(this); }
1684 public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
1685 public JCExpression getLeftOperand() { return lhs; }
1686 public JCExpression getRightOperand() { return rhs; }
1687 public Symbol getOperator() {
1688 return operator;
1689 }
1690 @Override
1691 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1692 return v.visitBinary(this, d);
1693 }
1694 @Override
1695 public Tag getTag() {
1696 return opcode;
1697 }
1698 }
1700 /**
1701 * A type cast.
1702 */
1703 public static class JCTypeCast extends JCExpression implements TypeCastTree {
1704 public JCTree clazz;
1705 public JCExpression expr;
1706 protected JCTypeCast(JCTree clazz, JCExpression expr) {
1707 this.clazz = clazz;
1708 this.expr = expr;
1709 }
1710 @Override
1711 public void accept(Visitor v) { v.visitTypeCast(this); }
1713 public Kind getKind() { return Kind.TYPE_CAST; }
1714 public JCTree getType() { return clazz; }
1715 public JCExpression getExpression() { return expr; }
1716 @Override
1717 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1718 return v.visitTypeCast(this, d);
1719 }
1720 @Override
1721 public Tag getTag() {
1722 return TYPECAST;
1723 }
1724 }
1726 /**
1727 * A type test.
1728 */
1729 public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
1730 public JCExpression expr;
1731 public JCTree clazz;
1732 protected JCInstanceOf(JCExpression expr, JCTree clazz) {
1733 this.expr = expr;
1734 this.clazz = clazz;
1735 }
1736 @Override
1737 public void accept(Visitor v) { v.visitTypeTest(this); }
1739 public Kind getKind() { return Kind.INSTANCE_OF; }
1740 public JCTree getType() { return clazz; }
1741 public JCExpression getExpression() { return expr; }
1742 @Override
1743 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1744 return v.visitInstanceOf(this, d);
1745 }
1746 @Override
1747 public Tag getTag() {
1748 return TYPETEST;
1749 }
1750 }
1752 /**
1753 * An array selection
1754 */
1755 public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
1756 public JCExpression indexed;
1757 public JCExpression index;
1758 protected JCArrayAccess(JCExpression indexed, JCExpression index) {
1759 this.indexed = indexed;
1760 this.index = index;
1761 }
1762 @Override
1763 public void accept(Visitor v) { v.visitIndexed(this); }
1765 public Kind getKind() { return Kind.ARRAY_ACCESS; }
1766 public JCExpression getExpression() { return indexed; }
1767 public JCExpression getIndex() { return index; }
1768 @Override
1769 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1770 return v.visitArrayAccess(this, d);
1771 }
1772 @Override
1773 public Tag getTag() {
1774 return INDEXED;
1775 }
1776 }
1778 /**
1779 * Selects through packages and classes
1780 * @param selected selected Tree hierarchie
1781 * @param selector name of field to select thru
1782 * @param sym symbol of the selected class
1783 */
1784 public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
1785 public JCExpression selected;
1786 public Name name;
1787 public Symbol sym;
1788 protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
1789 this.selected = selected;
1790 this.name = name;
1791 this.sym = sym;
1792 }
1793 @Override
1794 public void accept(Visitor v) { v.visitSelect(this); }
1796 public Kind getKind() { return Kind.MEMBER_SELECT; }
1797 public JCExpression getExpression() { return selected; }
1798 @Override
1799 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1800 return v.visitMemberSelect(this, d);
1801 }
1802 public Name getIdentifier() { return name; }
1803 @Override
1804 public Tag getTag() {
1805 return SELECT;
1806 }
1807 }
1809 /**
1810 * Selects a member expression.
1811 */
1812 public static class JCMemberReference extends JCExpression implements MemberReferenceTree {
1813 public ReferenceMode mode;
1814 public Name name;
1815 public JCExpression expr;
1816 public List<JCExpression> typeargs;
1817 public Type targetType;
1818 public Symbol sym;
1820 protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
1821 this.mode = mode;
1822 this.name = name;
1823 this.expr = expr;
1824 this.typeargs = typeargs;
1825 }
1826 @Override
1827 public void accept(Visitor v) { v.visitReference(this); }
1829 public Kind getKind() { return Kind.MEMBER_REFERENCE; }
1830 @Override
1831 public ReferenceMode getMode() { return mode; }
1832 @Override
1833 public JCExpression getQualifierExpression() { return expr; }
1834 @Override
1835 public Name getName() { return name; }
1836 @Override
1837 public List<JCExpression> getTypeArguments() { return typeargs; }
1839 @Override
1840 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1841 return v.visitMemberReference(this, d);
1842 }
1843 @Override
1844 public Tag getTag() {
1845 return REFERENCE;
1846 }
1847 }
1849 /**
1850 * An identifier
1851 * @param idname the name
1852 * @param sym the symbol
1853 */
1854 public static class JCIdent extends JCExpression implements IdentifierTree {
1855 public Name name;
1856 public Symbol sym;
1857 protected JCIdent(Name name, Symbol sym) {
1858 this.name = name;
1859 this.sym = sym;
1860 }
1861 @Override
1862 public void accept(Visitor v) { v.visitIdent(this); }
1864 public Kind getKind() { return Kind.IDENTIFIER; }
1865 public Name getName() { return name; }
1866 @Override
1867 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1868 return v.visitIdentifier(this, d);
1869 }
1870 @Override
1871 public Tag getTag() {
1872 return IDENT;
1873 }
1874 }
1876 /**
1877 * A constant value given literally.
1878 * @param value value representation
1879 */
1880 public static class JCLiteral extends JCExpression implements LiteralTree {
1881 public int typetag;
1882 public Object value;
1883 protected JCLiteral(int typetag, Object value) {
1884 this.typetag = typetag;
1885 this.value = value;
1886 }
1887 @Override
1888 public void accept(Visitor v) { v.visitLiteral(this); }
1890 public Kind getKind() {
1891 switch (typetag) {
1892 case TypeTags.INT:
1893 return Kind.INT_LITERAL;
1894 case TypeTags.LONG:
1895 return Kind.LONG_LITERAL;
1896 case TypeTags.FLOAT:
1897 return Kind.FLOAT_LITERAL;
1898 case TypeTags.DOUBLE:
1899 return Kind.DOUBLE_LITERAL;
1900 case TypeTags.BOOLEAN:
1901 return Kind.BOOLEAN_LITERAL;
1902 case TypeTags.CHAR:
1903 return Kind.CHAR_LITERAL;
1904 case TypeTags.CLASS:
1905 return Kind.STRING_LITERAL;
1906 case TypeTags.BOT:
1907 return Kind.NULL_LITERAL;
1908 default:
1909 throw new AssertionError("unknown literal kind " + this);
1910 }
1911 }
1912 public Object getValue() {
1913 switch (typetag) {
1914 case TypeTags.BOOLEAN:
1915 int bi = (Integer) value;
1916 return (bi != 0);
1917 case TypeTags.CHAR:
1918 int ci = (Integer) value;
1919 char c = (char) ci;
1920 if (c != ci)
1921 throw new AssertionError("bad value for char literal");
1922 return c;
1923 default:
1924 return value;
1925 }
1926 }
1927 @Override
1928 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1929 return v.visitLiteral(this, d);
1930 }
1931 @Override
1932 public JCLiteral setType(Type type) {
1933 super.setType(type);
1934 return this;
1935 }
1936 @Override
1937 public Tag getTag() {
1938 return LITERAL;
1939 }
1940 }
1942 /**
1943 * Identifies a basic type.
1944 * @param tag the basic type id
1945 * @see TypeTags
1946 */
1947 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
1948 public int typetag;
1949 protected JCPrimitiveTypeTree(int typetag) {
1950 this.typetag = typetag;
1951 }
1952 @Override
1953 public void accept(Visitor v) { v.visitTypeIdent(this); }
1955 public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
1956 public TypeKind getPrimitiveTypeKind() {
1957 switch (typetag) {
1958 case TypeTags.BOOLEAN:
1959 return TypeKind.BOOLEAN;
1960 case TypeTags.BYTE:
1961 return TypeKind.BYTE;
1962 case TypeTags.SHORT:
1963 return TypeKind.SHORT;
1964 case TypeTags.INT:
1965 return TypeKind.INT;
1966 case TypeTags.LONG:
1967 return TypeKind.LONG;
1968 case TypeTags.CHAR:
1969 return TypeKind.CHAR;
1970 case TypeTags.FLOAT:
1971 return TypeKind.FLOAT;
1972 case TypeTags.DOUBLE:
1973 return TypeKind.DOUBLE;
1974 case TypeTags.VOID:
1975 return TypeKind.VOID;
1976 default:
1977 throw new AssertionError("unknown primitive type " + this);
1978 }
1979 }
1980 @Override
1981 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1982 return v.visitPrimitiveType(this, d);
1983 }
1984 @Override
1985 public Tag getTag() {
1986 return TYPEIDENT;
1987 }
1988 }
1990 /**
1991 * An array type, A[]
1992 */
1993 public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
1994 public JCExpression elemtype;
1995 protected JCArrayTypeTree(JCExpression elemtype) {
1996 this.elemtype = elemtype;
1997 }
1998 @Override
1999 public void accept(Visitor v) { v.visitTypeArray(this); }
2001 public Kind getKind() { return Kind.ARRAY_TYPE; }
2002 public JCTree getType() { return elemtype; }
2003 @Override
2004 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2005 return v.visitArrayType(this, d);
2006 }
2007 @Override
2008 public Tag getTag() {
2009 return TYPEARRAY;
2010 }
2011 }
2013 /**
2014 * A parameterized type, T<...>
2015 */
2016 public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
2017 public JCExpression clazz;
2018 public List<JCExpression> arguments;
2019 protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
2020 this.clazz = clazz;
2021 this.arguments = arguments;
2022 }
2023 @Override
2024 public void accept(Visitor v) { v.visitTypeApply(this); }
2026 public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
2027 public JCTree getType() { return clazz; }
2028 public List<JCExpression> getTypeArguments() {
2029 return arguments;
2030 }
2031 @Override
2032 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2033 return v.visitParameterizedType(this, d);
2034 }
2035 @Override
2036 public Tag getTag() {
2037 return TYPEAPPLY;
2038 }
2039 }
2041 /**
2042 * A union type, T1 | T2 | ... Tn (used in multicatch statements)
2043 */
2044 public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
2046 public List<JCExpression> alternatives;
2048 protected JCTypeUnion(List<JCExpression> components) {
2049 this.alternatives = components;
2050 }
2051 @Override
2052 public void accept(Visitor v) { v.visitTypeUnion(this); }
2054 public Kind getKind() { return Kind.UNION_TYPE; }
2056 public List<JCExpression> getTypeAlternatives() {
2057 return alternatives;
2058 }
2059 @Override
2060 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2061 return v.visitUnionType(this, d);
2062 }
2063 @Override
2064 public Tag getTag() {
2065 return TYPEUNION;
2066 }
2067 }
2069 /**
2070 * A formal class parameter.
2071 * @param name name
2072 * @param bounds bounds
2073 */
2074 public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2075 public Name name;
2076 public List<JCExpression> bounds;
2077 protected JCTypeParameter(Name name, List<JCExpression> bounds) {
2078 this.name = name;
2079 this.bounds = bounds;
2080 }
2081 @Override
2082 public void accept(Visitor v) { v.visitTypeParameter(this); }
2084 public Kind getKind() { return Kind.TYPE_PARAMETER; }
2085 public Name getName() { return name; }
2086 public List<JCExpression> getBounds() {
2087 return bounds;
2088 }
2089 @Override
2090 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2091 return v.visitTypeParameter(this, d);
2092 }
2093 @Override
2094 public Tag getTag() {
2095 return TYPEPARAMETER;
2096 }
2097 }
2099 public static class JCWildcard extends JCExpression implements WildcardTree {
2100 public TypeBoundKind kind;
2101 public JCTree inner;
2102 protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2103 kind.getClass(); // null-check
2104 this.kind = kind;
2105 this.inner = inner;
2106 }
2107 @Override
2108 public void accept(Visitor v) { v.visitWildcard(this); }
2110 public Kind getKind() {
2111 switch (kind.kind) {
2112 case UNBOUND:
2113 return Kind.UNBOUNDED_WILDCARD;
2114 case EXTENDS:
2115 return Kind.EXTENDS_WILDCARD;
2116 case SUPER:
2117 return Kind.SUPER_WILDCARD;
2118 default:
2119 throw new AssertionError("Unknown wildcard bound " + kind);
2120 }
2121 }
2122 public JCTree getBound() { return inner; }
2123 @Override
2124 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2125 return v.visitWildcard(this, d);
2126 }
2127 @Override
2128 public Tag getTag() {
2129 return WILDCARD;
2130 }
2131 }
2133 public static class TypeBoundKind extends JCTree {
2134 public BoundKind kind;
2135 protected TypeBoundKind(BoundKind kind) {
2136 this.kind = kind;
2137 }
2138 @Override
2139 public void accept(Visitor v) { v.visitTypeBoundKind(this); }
2141 public Kind getKind() {
2142 throw new AssertionError("TypeBoundKind is not part of a public API");
2143 }
2144 @Override
2145 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2146 throw new AssertionError("TypeBoundKind is not part of a public API");
2147 }
2148 @Override
2149 public Tag getTag() {
2150 return TYPEBOUNDKIND;
2151 }
2152 }
2154 public static class JCAnnotation extends JCExpression implements AnnotationTree {
2155 public JCTree annotationType;
2156 public List<JCExpression> args;
2157 protected JCAnnotation(JCTree annotationType, List<JCExpression> args) {
2158 this.annotationType = annotationType;
2159 this.args = args;
2160 }
2161 @Override
2162 public void accept(Visitor v) { v.visitAnnotation(this); }
2164 public Kind getKind() { return Kind.ANNOTATION; }
2165 public JCTree getAnnotationType() { return annotationType; }
2166 public List<JCExpression> getArguments() {
2167 return args;
2168 }
2169 @Override
2170 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2171 return v.visitAnnotation(this, d);
2172 }
2173 @Override
2174 public Tag getTag() {
2175 return ANNOTATION;
2176 }
2177 }
2179 public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
2180 public long flags;
2181 public List<JCAnnotation> annotations;
2182 protected JCModifiers(long flags, List<JCAnnotation> annotations) {
2183 this.flags = flags;
2184 this.annotations = annotations;
2185 }
2186 @Override
2187 public void accept(Visitor v) { v.visitModifiers(this); }
2189 public Kind getKind() { return Kind.MODIFIERS; }
2190 public Set<Modifier> getFlags() {
2191 return Flags.asModifierSet(flags);
2192 }
2193 public List<JCAnnotation> getAnnotations() {
2194 return annotations;
2195 }
2196 @Override
2197 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2198 return v.visitModifiers(this, d);
2199 }
2200 @Override
2201 public Tag getTag() {
2202 return MODIFIERS;
2203 }
2204 }
2206 public static class JCErroneous extends JCExpression
2207 implements com.sun.source.tree.ErroneousTree {
2208 public List<? extends JCTree> errs;
2209 protected JCErroneous(List<? extends JCTree> errs) {
2210 this.errs = errs;
2211 }
2212 @Override
2213 public void accept(Visitor v) { v.visitErroneous(this); }
2215 public Kind getKind() { return Kind.ERRONEOUS; }
2217 public List<? extends JCTree> getErrorTrees() {
2218 return errs;
2219 }
2221 @Override
2222 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2223 return v.visitErroneous(this, d);
2224 }
2225 @Override
2226 public Tag getTag() {
2227 return ERRONEOUS;
2228 }
2229 }
2231 /** (let int x = 3; in x+2) */
2232 public static class LetExpr extends JCExpression {
2233 public List<JCVariableDecl> defs;
2234 public JCTree expr;
2235 protected LetExpr(List<JCVariableDecl> defs, JCTree expr) {
2236 this.defs = defs;
2237 this.expr = expr;
2238 }
2239 @Override
2240 public void accept(Visitor v) { v.visitLetExpr(this); }
2242 public Kind getKind() {
2243 throw new AssertionError("LetExpr is not part of a public API");
2244 }
2245 @Override
2246 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2247 throw new AssertionError("LetExpr is not part of a public API");
2248 }
2249 @Override
2250 public Tag getTag() {
2251 return LETEXPR;
2252 }
2253 }
2255 /** An interface for tree factories
2256 */
2257 public interface Factory {
2258 JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations,
2259 JCExpression pid,
2260 List<JCTree> defs);
2261 JCImport Import(JCTree qualid, boolean staticImport);
2262 JCClassDecl ClassDef(JCModifiers mods,
2263 Name name,
2264 List<JCTypeParameter> typarams,
2265 JCExpression extending,
2266 List<JCExpression> implementing,
2267 List<JCTree> defs);
2268 JCMethodDecl MethodDef(JCModifiers mods,
2269 Name name,
2270 JCExpression restype,
2271 List<JCTypeParameter> typarams,
2272 List<JCVariableDecl> params,
2273 List<JCExpression> thrown,
2274 JCBlock body,
2275 JCExpression defaultValue);
2276 JCVariableDecl VarDef(JCModifiers mods,
2277 Name name,
2278 JCExpression vartype,
2279 JCExpression init);
2280 JCSkip Skip();
2281 JCBlock Block(long flags, List<JCStatement> stats);
2282 JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
2283 JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
2284 JCForLoop ForLoop(List<JCStatement> init,
2285 JCExpression cond,
2286 List<JCExpressionStatement> step,
2287 JCStatement body);
2288 JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
2289 JCLabeledStatement Labelled(Name label, JCStatement body);
2290 JCSwitch Switch(JCExpression selector, List<JCCase> cases);
2291 JCCase Case(JCExpression pat, List<JCStatement> stats);
2292 JCSynchronized Synchronized(JCExpression lock, JCBlock body);
2293 JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
2294 JCTry Try(List<JCTree> resources,
2295 JCBlock body,
2296 List<JCCatch> catchers,
2297 JCBlock finalizer);
2298 JCCatch Catch(JCVariableDecl param, JCBlock body);
2299 JCConditional Conditional(JCExpression cond,
2300 JCExpression thenpart,
2301 JCExpression elsepart);
2302 JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
2303 JCExpressionStatement Exec(JCExpression expr);
2304 JCBreak Break(Name label);
2305 JCContinue Continue(Name label);
2306 JCReturn Return(JCExpression expr);
2307 JCThrow Throw(JCTree expr);
2308 JCAssert Assert(JCExpression cond, JCExpression detail);
2309 JCMethodInvocation Apply(List<JCExpression> typeargs,
2310 JCExpression fn,
2311 List<JCExpression> args);
2312 JCNewClass NewClass(JCExpression encl,
2313 List<JCExpression> typeargs,
2314 JCExpression clazz,
2315 List<JCExpression> args,
2316 JCClassDecl def);
2317 JCNewArray NewArray(JCExpression elemtype,
2318 List<JCExpression> dims,
2319 List<JCExpression> elems);
2320 JCParens Parens(JCExpression expr);
2321 JCAssign Assign(JCExpression lhs, JCExpression rhs);
2322 JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
2323 JCUnary Unary(Tag opcode, JCExpression arg);
2324 JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
2325 JCTypeCast TypeCast(JCTree expr, JCExpression type);
2326 JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
2327 JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
2328 JCFieldAccess Select(JCExpression selected, Name selector);
2329 JCIdent Ident(Name idname);
2330 JCLiteral Literal(int tag, Object value);
2331 JCPrimitiveTypeTree TypeIdent(int typetag);
2332 JCArrayTypeTree TypeArray(JCExpression elemtype);
2333 JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
2334 JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
2335 JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
2336 TypeBoundKind TypeBoundKind(BoundKind kind);
2337 JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
2338 JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
2339 JCErroneous Erroneous(List<? extends JCTree> errs);
2340 LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr);
2341 }
2343 /** A generic visitor class for trees.
2344 */
2345 public static abstract class Visitor {
2346 public void visitTopLevel(JCCompilationUnit that) { visitTree(that); }
2347 public void visitImport(JCImport that) { visitTree(that); }
2348 public void visitClassDef(JCClassDecl that) { visitTree(that); }
2349 public void visitMethodDef(JCMethodDecl that) { visitTree(that); }
2350 public void visitVarDef(JCVariableDecl that) { visitTree(that); }
2351 public void visitSkip(JCSkip that) { visitTree(that); }
2352 public void visitBlock(JCBlock that) { visitTree(that); }
2353 public void visitDoLoop(JCDoWhileLoop that) { visitTree(that); }
2354 public void visitWhileLoop(JCWhileLoop that) { visitTree(that); }
2355 public void visitForLoop(JCForLoop that) { visitTree(that); }
2356 public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
2357 public void visitLabelled(JCLabeledStatement that) { visitTree(that); }
2358 public void visitSwitch(JCSwitch that) { visitTree(that); }
2359 public void visitCase(JCCase that) { visitTree(that); }
2360 public void visitSynchronized(JCSynchronized that) { visitTree(that); }
2361 public void visitTry(JCTry that) { visitTree(that); }
2362 public void visitCatch(JCCatch that) { visitTree(that); }
2363 public void visitConditional(JCConditional that) { visitTree(that); }
2364 public void visitIf(JCIf that) { visitTree(that); }
2365 public void visitExec(JCExpressionStatement that) { visitTree(that); }
2366 public void visitBreak(JCBreak that) { visitTree(that); }
2367 public void visitContinue(JCContinue that) { visitTree(that); }
2368 public void visitReturn(JCReturn that) { visitTree(that); }
2369 public void visitThrow(JCThrow that) { visitTree(that); }
2370 public void visitAssert(JCAssert that) { visitTree(that); }
2371 public void visitApply(JCMethodInvocation that) { visitTree(that); }
2372 public void visitNewClass(JCNewClass that) { visitTree(that); }
2373 public void visitNewArray(JCNewArray that) { visitTree(that); }
2374 public void visitLambda(JCLambda that) { visitTree(that); }
2375 public void visitParens(JCParens that) { visitTree(that); }
2376 public void visitAssign(JCAssign that) { visitTree(that); }
2377 public void visitAssignop(JCAssignOp that) { visitTree(that); }
2378 public void visitUnary(JCUnary that) { visitTree(that); }
2379 public void visitBinary(JCBinary that) { visitTree(that); }
2380 public void visitTypeCast(JCTypeCast that) { visitTree(that); }
2381 public void visitTypeTest(JCInstanceOf that) { visitTree(that); }
2382 public void visitIndexed(JCArrayAccess that) { visitTree(that); }
2383 public void visitSelect(JCFieldAccess that) { visitTree(that); }
2384 public void visitReference(JCMemberReference that) { visitTree(that); }
2385 public void visitIdent(JCIdent that) { visitTree(that); }
2386 public void visitLiteral(JCLiteral that) { visitTree(that); }
2387 public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
2388 public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); }
2389 public void visitTypeApply(JCTypeApply that) { visitTree(that); }
2390 public void visitTypeUnion(JCTypeUnion that) { visitTree(that); }
2391 public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
2392 public void visitWildcard(JCWildcard that) { visitTree(that); }
2393 public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); }
2394 public void visitAnnotation(JCAnnotation that) { visitTree(that); }
2395 public void visitModifiers(JCModifiers that) { visitTree(that); }
2396 public void visitErroneous(JCErroneous that) { visitTree(that); }
2397 public void visitLetExpr(LetExpr that) { visitTree(that); }
2399 public void visitTree(JCTree that) { Assert.error(); }
2400 }
2402 }