src/share/classes/com/sun/tools/javac/tree/JCTree.java

changeset 1358
fc123bdeddb8
parent 1352
d4b3cb1ece84
child 1374
c002fdee76fd
equal deleted inserted replaced
1357:c75be5bc5283 1358:fc123bdeddb8
462 public int getEndPosition(EndPosTable endPosTable) { 462 public int getEndPosition(EndPosTable endPosTable) {
463 return TreeInfo.getEndPos(this, endPosTable); 463 return TreeInfo.getEndPos(this, endPosTable);
464 } 464 }
465 465
466 /** 466 /**
467 * Everything in one source file is kept in a TopLevel structure. 467 * Everything in one source file is kept in a {@linkplain JCCompilationUnit} structure.
468 * @param pid The tree representing the package clause.
469 * @param sourcefile The source file name.
470 * @param defs All definitions in this file (ClassDef, Import, and Skip)
471 * @param packge The package it belongs to.
472 * @param namedImportScope A scope for all named imports.
473 * @param starImportScope A scope for all import-on-demands.
474 * @param lineMap Line starting positions, defined only
475 * if option -g is set.
476 * @param docComments A hashtable that stores all documentation comments
477 * indexed by the tree nodes they refer to.
478 * defined only if option -s is set.
479 * @param endPositions An object encapsulating ending positions of source
480 * ranges indexed by the tree nodes they belong to.
481 * Defined only if option -Xjcov is set.
482 */ 468 */
483 public static class JCCompilationUnit extends JCTree implements CompilationUnitTree { 469 public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
484 public List<JCAnnotation> packageAnnotations; 470 public List<JCAnnotation> packageAnnotations;
471 /** The tree representing the package clause. */
485 public JCExpression pid; 472 public JCExpression pid;
473 /** All definitions in this file (ClassDef, Import, and Skip) */
486 public List<JCTree> defs; 474 public List<JCTree> defs;
475 /* The source file name. */
487 public JavaFileObject sourcefile; 476 public JavaFileObject sourcefile;
477 /** The package to which this compilation unit belongs. */
488 public PackageSymbol packge; 478 public PackageSymbol packge;
479 /** A scope for all named imports. */
489 public ImportScope namedImportScope; 480 public ImportScope namedImportScope;
481 /** A scope for all import-on-demands. */
490 public StarImportScope starImportScope; 482 public StarImportScope starImportScope;
483 /** Line starting positions, defined only if option -g is set. */
491 public Position.LineMap lineMap = null; 484 public Position.LineMap lineMap = null;
485 /** A table that stores all documentation comments indexed by the tree
486 * nodes they refer to. defined only if option -s is set. */
492 public DocCommentTable docComments = null; 487 public DocCommentTable docComments = null;
488 /* An object encapsulating ending positions of source ranges indexed by
489 * the tree nodes they belong to. Defined only if option -Xjcov is set. */
493 public EndPosTable endPositions = null; 490 public EndPosTable endPositions = null;
494 protected JCCompilationUnit(List<JCAnnotation> packageAnnotations, 491 protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
495 JCExpression pid, 492 JCExpression pid,
496 List<JCTree> defs, 493 List<JCTree> defs,
497 JavaFileObject sourcefile, 494 JavaFileObject sourcefile,
548 } 545 }
549 } 546 }
550 547
551 /** 548 /**
552 * An import clause. 549 * An import clause.
553 * @param qualid The imported class(es).
554 */ 550 */
555 public static class JCImport extends JCTree implements ImportTree { 551 public static class JCImport extends JCTree implements ImportTree {
556 public boolean staticImport; 552 public boolean staticImport;
553 /** The imported class(es). */
557 public JCTree qualid; 554 public JCTree qualid;
558 protected JCImport(JCTree qualid, boolean importStatic) { 555 protected JCImport(JCTree qualid, boolean importStatic) {
559 this.qualid = qualid; 556 this.qualid = qualid;
560 this.staticImport = importStatic; 557 this.staticImport = importStatic;
561 } 558 }
603 } 600 }
604 } 601 }
605 602
606 /** 603 /**
607 * A class definition. 604 * A class definition.
608 * @param modifiers the modifiers
609 * @param name the name of the class
610 * @param typarams formal class parameters
611 * @param extending the classes this class extends
612 * @param implementing the interfaces implemented by this class
613 * @param defs all variables and methods defined in this class
614 * @param sym the symbol
615 */ 605 */
616 public static class JCClassDecl extends JCStatement implements ClassTree { 606 public static class JCClassDecl extends JCStatement implements ClassTree {
607 /** the modifiers */
617 public JCModifiers mods; 608 public JCModifiers mods;
609 /** the name of the class */
618 public Name name; 610 public Name name;
611 /** formal class parameters */
619 public List<JCTypeParameter> typarams; 612 public List<JCTypeParameter> typarams;
613 /** the classes this class extends */
620 public JCExpression extending; 614 public JCExpression extending;
615 /** the interfaces implemented by this class */
621 public List<JCExpression> implementing; 616 public List<JCExpression> implementing;
617 /** all variables and methods defined in this class */
622 public List<JCTree> defs; 618 public List<JCTree> defs;
619 /** the symbol */
623 public ClassSymbol sym; 620 public ClassSymbol sym;
624 protected JCClassDecl(JCModifiers mods, 621 protected JCClassDecl(JCModifiers mods,
625 Name name, 622 Name name,
626 List<JCTypeParameter> typarams, 623 List<JCTypeParameter> typarams,
627 JCExpression extending, 624 JCExpression extending,
674 } 671 }
675 } 672 }
676 673
677 /** 674 /**
678 * A method definition. 675 * A method definition.
679 * @param modifiers method modifiers
680 * @param name method name
681 * @param restype type of method return value
682 * @param typarams type parameters
683 * @param params value parameters
684 * @param thrown exceptions thrown by this method
685 * @param stats statements in the method
686 * @param sym method symbol
687 */ 676 */
688 public static class JCMethodDecl extends JCTree implements MethodTree { 677 public static class JCMethodDecl extends JCTree implements MethodTree {
678 /** method modifiers */
689 public JCModifiers mods; 679 public JCModifiers mods;
680 /** method name */
690 public Name name; 681 public Name name;
682 /** type of method return value */
691 public JCExpression restype; 683 public JCExpression restype;
684 /** type parameters */
692 public List<JCTypeParameter> typarams; 685 public List<JCTypeParameter> typarams;
686 /** value parameters */
693 public List<JCVariableDecl> params; 687 public List<JCVariableDecl> params;
688 /** exceptions thrown by this method */
694 public List<JCExpression> thrown; 689 public List<JCExpression> thrown;
690 /** statements in the method */
695 public JCBlock body; 691 public JCBlock body;
696 public JCExpression defaultValue; // for annotation types 692 /** default value, for annotation types */
693 public JCExpression defaultValue;
694 /** method symbol */
697 public MethodSymbol sym; 695 public MethodSymbol sym;
698 protected JCMethodDecl(JCModifiers mods, 696 protected JCMethodDecl(JCModifiers mods,
699 Name name, 697 Name name,
700 JCExpression restype, 698 JCExpression restype,
701 List<JCTypeParameter> typarams, 699 List<JCTypeParameter> typarams,
746 } 744 }
747 } 745 }
748 746
749 /** 747 /**
750 * A variable definition. 748 * A variable definition.
751 * @param modifiers variable modifiers
752 * @param name variable name
753 * @param vartype type of the variable
754 * @param init variables initial value
755 * @param sym symbol
756 */ 749 */
757 public static class JCVariableDecl extends JCStatement implements VariableTree { 750 public static class JCVariableDecl extends JCStatement implements VariableTree {
751 /** variable modifiers */
758 public JCModifiers mods; 752 public JCModifiers mods;
753 /** variable name */
759 public Name name; 754 public Name name;
755 /** type of the variable */
760 public JCExpression vartype; 756 public JCExpression vartype;
757 /** variable's initial value */
761 public JCExpression init; 758 public JCExpression init;
759 /** symbol */
762 public VarSymbol sym; 760 public VarSymbol sym;
763 protected JCVariableDecl(JCModifiers mods, 761 protected JCVariableDecl(JCModifiers mods,
764 Name name, 762 Name name,
765 JCExpression vartype, 763 JCExpression vartype,
766 JCExpression init, 764 JCExpression init,
813 } 811 }
814 } 812 }
815 813
816 /** 814 /**
817 * A statement block. 815 * A statement block.
818 * @param stats statements
819 * @param flags flags
820 */ 816 */
821 public static class JCBlock extends JCStatement implements BlockTree { 817 public static class JCBlock extends JCStatement implements BlockTree {
818 /** flags */
822 public long flags; 819 public long flags;
820 /** statements */
823 public List<JCStatement> stats; 821 public List<JCStatement> stats;
824 /** Position of closing brace, optional. */ 822 /** Position of closing brace, optional. */
825 public int endpos = Position.NOPOS; 823 public int endpos = Position.NOPOS;
826 protected JCBlock(long flags, List<JCStatement> stats) { 824 protected JCBlock(long flags, List<JCStatement> stats) {
827 this.stats = stats; 825 this.stats = stats;
1204 } 1202 }
1205 } 1203 }
1206 1204
1207 /** 1205 /**
1208 * an expression statement 1206 * an expression statement
1209 * @param expr expression structure
1210 */ 1207 */
1211 public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree { 1208 public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1209 /** expression structure */
1212 public JCExpression expr; 1210 public JCExpression expr;
1213 protected JCExpressionStatement(JCExpression expr) 1211 protected JCExpressionStatement(JCExpression expr)
1214 { 1212 {
1215 this.expr = expr; 1213 this.expr = expr;
1216 } 1214 }
1774 } 1772 }
1775 } 1773 }
1776 1774
1777 /** 1775 /**
1778 * Selects through packages and classes 1776 * Selects through packages and classes
1779 * @param selected selected Tree hierarchie
1780 * @param selector name of field to select thru
1781 * @param sym symbol of the selected class
1782 */ 1777 */
1783 public static class JCFieldAccess extends JCExpression implements MemberSelectTree { 1778 public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
1779 /** selected Tree hierarchy */
1784 public JCExpression selected; 1780 public JCExpression selected;
1781 /** name of field to select thru */
1785 public Name name; 1782 public Name name;
1783 /** symbol of the selected class */
1786 public Symbol sym; 1784 public Symbol sym;
1787 protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) { 1785 protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
1788 this.selected = selected; 1786 this.selected = selected;
1789 this.name = name; 1787 this.name = name;
1790 this.sym = sym; 1788 this.sym = sym;
1883 } 1881 }
1884 } 1882 }
1885 1883
1886 /** 1884 /**
1887 * An identifier 1885 * An identifier
1888 * @param idname the name
1889 * @param sym the symbol
1890 */ 1886 */
1891 public static class JCIdent extends JCExpression implements IdentifierTree { 1887 public static class JCIdent extends JCExpression implements IdentifierTree {
1888 /** the name */
1892 public Name name; 1889 public Name name;
1890 /** the symbol */
1893 public Symbol sym; 1891 public Symbol sym;
1894 protected JCIdent(Name name, Symbol sym) { 1892 protected JCIdent(Name name, Symbol sym) {
1895 this.name = name; 1893 this.name = name;
1896 this.sym = sym; 1894 this.sym = sym;
1897 } 1895 }
1910 } 1908 }
1911 } 1909 }
1912 1910
1913 /** 1911 /**
1914 * A constant value given literally. 1912 * A constant value given literally.
1915 * @param value value representation
1916 */ 1913 */
1917 public static class JCLiteral extends JCExpression implements LiteralTree { 1914 public static class JCLiteral extends JCExpression implements LiteralTree {
1918 public int typetag; 1915 public int typetag;
1916 /** value representation */
1919 public Object value; 1917 public Object value;
1920 protected JCLiteral(int typetag, Object value) { 1918 protected JCLiteral(int typetag, Object value) {
1921 this.typetag = typetag; 1919 this.typetag = typetag;
1922 this.value = value; 1920 this.value = value;
1923 } 1921 }
1976 } 1974 }
1977 } 1975 }
1978 1976
1979 /** 1977 /**
1980 * Identifies a basic type. 1978 * Identifies a basic type.
1981 * @param tag the basic type id
1982 * @see TypeTags 1979 * @see TypeTags
1983 */ 1980 */
1984 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree { 1981 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
1982 /** the basic type id */
1985 public int typetag; 1983 public int typetag;
1986 protected JCPrimitiveTypeTree(int typetag) { 1984 protected JCPrimitiveTypeTree(int typetag) {
1987 this.typetag = typetag; 1985 this.typetag = typetag;
1988 } 1986 }
1989 @Override 1987 @Override
2103 } 2101 }
2104 } 2102 }
2105 2103
2106 /** 2104 /**
2107 * A formal class parameter. 2105 * A formal class parameter.
2108 * @param name name
2109 * @param bounds bounds
2110 */ 2106 */
2111 public static class JCTypeParameter extends JCTree implements TypeParameterTree { 2107 public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2108 /** name */
2112 public Name name; 2109 public Name name;
2110 /** bounds */
2113 public List<JCExpression> bounds; 2111 public List<JCExpression> bounds;
2114 protected JCTypeParameter(Name name, List<JCExpression> bounds) { 2112 protected JCTypeParameter(Name name, List<JCExpression> bounds) {
2115 this.name = name; 2113 this.name = name;
2116 this.bounds = bounds; 2114 this.bounds = bounds;
2117 } 2115 }

mercurial