48 import com.sun.tools.javac.code.Type;
49 import com.sun.tools.javac.code.Type.ClassType;
50 import com.sun.tools.javac.code.TypeTags;
51
52 import com.sun.tools.javac.comp.AttrContext;
53 import com.sun.tools.javac.comp.Env;
54
55 import com.sun.tools.javac.tree.JCTree;
56 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
57 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
58 import com.sun.tools.javac.tree.JCTree.JCImport;
59 import com.sun.tools.javac.tree.TreeInfo;
60
61 import com.sun.tools.javac.util.List;
62 import com.sun.tools.javac.util.ListBuffer;
63 import com.sun.tools.javac.util.Name;
64 import com.sun.tools.javac.util.Names;
65 import com.sun.tools.javac.util.Position;
66
67 import static com.sun.tools.javac.code.Kinds.*;
68
69 /**
70 * Represents a java class and provides access to information
71 * about the class, the class' comment and tags, and the
72 * members of the class. A ClassDocImpl only exists if it was
73 * processed in this run of javadoc. References to classes
74 * which may or may not have been processed in this run are
75 * referred to using Type (which can be converted to ClassDocImpl,
76 * if possible).
77 *
78 * @see Type
79 *
80 * @since 1.2
81 * @author Robert Field
82 * @author Neal Gafter (rewrite)
83 * @author Scott Seligman (generics, enums, annotations)
84 */
85
86 public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
87
1066 * This method is deprecated in the ClassDoc interface.
1067 *
1068 * @return an array of ClassDocImpl representing the imported classes.
1069 *
1070 * @deprecated Import declarations are implementation details that
1071 * should not be exposed here. In addition, not all imported
1072 * classes are imported through single-type-import declarations.
1073 */
1074 @Deprecated
1075 public ClassDoc[] importedClasses() {
1076 // information is not available for binary classfiles
1077 if (tsym.sourcefile == null) return new ClassDoc[0];
1078
1079 ListBuffer<ClassDocImpl> importedClasses = new ListBuffer<ClassDocImpl>();
1080
1081 Env<AttrContext> compenv = env.enter.getEnv(tsym);
1082 if (compenv == null) return new ClassDocImpl[0];
1083
1084 Name asterisk = tsym.name.table.names.asterisk;
1085 for (JCTree t : compenv.toplevel.defs) {
1086 if (t.getTag() == JCTree.IMPORT) {
1087 JCTree imp = ((JCImport) t).qualid;
1088 if ((TreeInfo.name(imp) != asterisk) &&
1089 (imp.type.tsym.kind & Kinds.TYP) != 0) {
1090 importedClasses.append(
1091 env.getClassDoc((ClassSymbol)imp.type.tsym));
1092 }
1093 }
1094 }
1095
1096 return importedClasses.toArray(new ClassDocImpl[importedClasses.length()]);
1097 }
1098
1099 /**
1100 * Get the list of packages declared as imported.
1101 * These are called "type-import-on-demand declarations" in the JLS.
1102 * This method is deprecated in the ClassDoc interface.
1103 *
1104 * @return an array of PackageDocImpl representing the imported packages.
1105 *
1106 * ###NOTE: the syntax supports importing all inner classes from a class as well.
1107 * @deprecated Import declarations are implementation details that
1108 * should not be exposed here. In addition, this method's
1109 * return type does not allow for all type-import-on-demand
1110 * declarations to be returned.
1111 */
1112 @Deprecated
1113 public PackageDoc[] importedPackages() {
1114 // information is not available for binary classfiles
1115 if (tsym.sourcefile == null) return new PackageDoc[0];
1116
1117 ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<PackageDocImpl>();
1118
1119 //### Add the implicit "import java.lang.*" to the result
1120 Names names = tsym.name.table.names;
1121 importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
1122
1123 Env<AttrContext> compenv = env.enter.getEnv(tsym);
1124 if (compenv == null) return new PackageDocImpl[0];
1125
1126 for (JCTree t : compenv.toplevel.defs) {
1127 if (t.getTag() == JCTree.IMPORT) {
1128 JCTree imp = ((JCImport) t).qualid;
1129 if (TreeInfo.name(imp) == names.asterisk) {
1130 JCFieldAccess sel = (JCFieldAccess)imp;
1131 Symbol s = sel.selected.type.tsym;
1132 PackageDocImpl pdoc = env.getPackageDoc(s.packge());
1133 if (!importedPackages.contains(pdoc))
1134 importedPackages.append(pdoc);
1135 }
1136 }
1137 }
1138
1139 return importedPackages.toArray(new PackageDocImpl[importedPackages.length()]);
1140 }
1141
1142 /**
1143 * Return the type's dimension information.
1144 * Always return "", as this is not an array type.
1145 */
1146 public String dimension() {
1147 return "";
|
48 import com.sun.tools.javac.code.Type;
49 import com.sun.tools.javac.code.Type.ClassType;
50 import com.sun.tools.javac.code.TypeTags;
51
52 import com.sun.tools.javac.comp.AttrContext;
53 import com.sun.tools.javac.comp.Env;
54
55 import com.sun.tools.javac.tree.JCTree;
56 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
57 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
58 import com.sun.tools.javac.tree.JCTree.JCImport;
59 import com.sun.tools.javac.tree.TreeInfo;
60
61 import com.sun.tools.javac.util.List;
62 import com.sun.tools.javac.util.ListBuffer;
63 import com.sun.tools.javac.util.Name;
64 import com.sun.tools.javac.util.Names;
65 import com.sun.tools.javac.util.Position;
66
67 import static com.sun.tools.javac.code.Kinds.*;
68 import static com.sun.tools.javac.tree.JCTree.Tag.*;
69
70 /**
71 * Represents a java class and provides access to information
72 * about the class, the class' comment and tags, and the
73 * members of the class. A ClassDocImpl only exists if it was
74 * processed in this run of javadoc. References to classes
75 * which may or may not have been processed in this run are
76 * referred to using Type (which can be converted to ClassDocImpl,
77 * if possible).
78 *
79 * @see Type
80 *
81 * @since 1.2
82 * @author Robert Field
83 * @author Neal Gafter (rewrite)
84 * @author Scott Seligman (generics, enums, annotations)
85 */
86
87 public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
88
1067 * This method is deprecated in the ClassDoc interface.
1068 *
1069 * @return an array of ClassDocImpl representing the imported classes.
1070 *
1071 * @deprecated Import declarations are implementation details that
1072 * should not be exposed here. In addition, not all imported
1073 * classes are imported through single-type-import declarations.
1074 */
1075 @Deprecated
1076 public ClassDoc[] importedClasses() {
1077 // information is not available for binary classfiles
1078 if (tsym.sourcefile == null) return new ClassDoc[0];
1079
1080 ListBuffer<ClassDocImpl> importedClasses = new ListBuffer<ClassDocImpl>();
1081
1082 Env<AttrContext> compenv = env.enter.getEnv(tsym);
1083 if (compenv == null) return new ClassDocImpl[0];
1084
1085 Name asterisk = tsym.name.table.names.asterisk;
1086 for (JCTree t : compenv.toplevel.defs) {
1087 if (t.hasTag(IMPORT)) {
1088 JCTree imp = ((JCImport) t).qualid;
1089 if ((TreeInfo.name(imp) != asterisk) &&
1090 (imp.type.tsym.kind & Kinds.TYP) != 0) {
1091 importedClasses.append(
1092 env.getClassDoc((ClassSymbol)imp.type.tsym));
1093 }
1094 }
1095 }
1096
1097 return importedClasses.toArray(new ClassDocImpl[importedClasses.length()]);
1098 }
1099
1100 /**
1101 * Get the list of packages declared as imported.
1102 * These are called "type-import-on-demand declarations" in the JLS.
1103 * This method is deprecated in the ClassDoc interface.
1104 *
1105 * @return an array of PackageDocImpl representing the imported packages.
1106 *
1107 * ###NOTE: the syntax supports importing all inner classes from a class as well.
1108 * @deprecated Import declarations are implementation details that
1109 * should not be exposed here. In addition, this method's
1110 * return type does not allow for all type-import-on-demand
1111 * declarations to be returned.
1112 */
1113 @Deprecated
1114 public PackageDoc[] importedPackages() {
1115 // information is not available for binary classfiles
1116 if (tsym.sourcefile == null) return new PackageDoc[0];
1117
1118 ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<PackageDocImpl>();
1119
1120 //### Add the implicit "import java.lang.*" to the result
1121 Names names = tsym.name.table.names;
1122 importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
1123
1124 Env<AttrContext> compenv = env.enter.getEnv(tsym);
1125 if (compenv == null) return new PackageDocImpl[0];
1126
1127 for (JCTree t : compenv.toplevel.defs) {
1128 if (t.hasTag(IMPORT)) {
1129 JCTree imp = ((JCImport) t).qualid;
1130 if (TreeInfo.name(imp) == names.asterisk) {
1131 JCFieldAccess sel = (JCFieldAccess)imp;
1132 Symbol s = sel.selected.type.tsym;
1133 PackageDocImpl pdoc = env.getPackageDoc(s.packge());
1134 if (!importedPackages.contains(pdoc))
1135 importedPackages.append(pdoc);
1136 }
1137 }
1138 }
1139
1140 return importedPackages.toArray(new PackageDocImpl[importedPackages.length()]);
1141 }
1142
1143 /**
1144 * Return the type's dimension information.
1145 * Always return "", as this is not an array type.
1146 */
1147 public String dimension() {
1148 return "";
|