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, |
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; |