langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
changeset 22163 3651128c74eb
parent 22159 682da512ec17
child 22165 ec53c8946fc2
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
   543      *
   543      *
   544      * @return An array of ClassDocImpl representing the interfaces.
   544      * @return An array of ClassDocImpl representing the interfaces.
   545      * Return an empty array if there are no interfaces.
   545      * Return an empty array if there are no interfaces.
   546      */
   546      */
   547     public ClassDoc[] interfaces() {
   547     public ClassDoc[] interfaces() {
   548         ListBuffer<ClassDocImpl> ta = new ListBuffer<ClassDocImpl>();
   548         ListBuffer<ClassDocImpl> ta = new ListBuffer<>();
   549         for (Type t : env.types.interfaces(type)) {
   549         for (Type t : env.types.interfaces(type)) {
   550             ta.append(env.getClassDoc((ClassSymbol)t.tsym));
   550             ta.append(env.getClassDoc((ClassSymbol)t.tsym));
   551         }
   551         }
   552         //### Cache ta here?
   552         //### Cache ta here?
   553         return ta.toArray(new ClassDocImpl[ta.length()]);
   553         return ta.toArray(new ClassDocImpl[ta.length()]);
   714      * @return an array of ClassDocImpl for representing the visible
   714      * @return an array of ClassDocImpl for representing the visible
   715      * classes defined in this class. Anonymous and local classes
   715      * classes defined in this class. Anonymous and local classes
   716      * are not included.
   716      * are not included.
   717      */
   717      */
   718     public ClassDoc[] innerClasses(boolean filter) {
   718     public ClassDoc[] innerClasses(boolean filter) {
   719         ListBuffer<ClassDocImpl> innerClasses = new ListBuffer<ClassDocImpl>();
   719         ListBuffer<ClassDocImpl> innerClasses = new ListBuffer<>();
   720         for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
   720         for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
   721             if (e.sym != null && e.sym.kind == Kinds.TYP) {
   721             if (e.sym != null && e.sym.kind == Kinds.TYP) {
   722                 ClassSymbol s = (ClassSymbol)e.sym;
   722                 ClassSymbol s = (ClassSymbol)e.sym;
   723                 if ((s.flags_field & Flags.SYNTHETIC) != 0) continue;
   723                 if ((s.flags_field & Flags.SYNTHETIC) != 0) continue;
   724                 if (!filter || env.isVisible(s)) {
   724                 if (!filter || env.isVisible(s)) {
   881      * @return the first MethodDocImpl which matches, null if not found.
   881      * @return the first MethodDocImpl which matches, null if not found.
   882      */
   882      */
   883     public MethodDocImpl findMethod(String methodName, String[] paramTypes) {
   883     public MethodDocImpl findMethod(String methodName, String[] paramTypes) {
   884         // Use hash table 'searched' to avoid searching same class twice.
   884         // Use hash table 'searched' to avoid searching same class twice.
   885         //### It is not clear how this could happen.
   885         //### It is not clear how this could happen.
   886         return searchMethod(methodName, paramTypes, new HashSet<ClassDocImpl>());
   886         return searchMethod(methodName, paramTypes, new HashSet<>());
   887     }
   887     }
   888 
   888 
   889     private MethodDocImpl searchMethod(String methodName,
   889     private MethodDocImpl searchMethod(String methodName,
   890                                        String[] paramTypes, Set<ClassDocImpl> searched) {
   890                                        String[] paramTypes, Set<ClassDocImpl> searched) {
   891         //### Note that this search is not necessarily what the compiler would do!
   891         //### Note that this search is not necessarily what the compiler would do!
  1039      *
  1039      *
  1040      * @param fieldName the unqualified name to search for.
  1040      * @param fieldName the unqualified name to search for.
  1041      * @return the first FieldDocImpl which matches, null if not found.
  1041      * @return the first FieldDocImpl which matches, null if not found.
  1042      */
  1042      */
  1043     public FieldDoc findField(String fieldName) {
  1043     public FieldDoc findField(String fieldName) {
  1044         return searchField(fieldName, new HashSet<ClassDocImpl>());
  1044         return searchField(fieldName, new HashSet<>());
  1045     }
  1045     }
  1046 
  1046 
  1047     private FieldDocImpl searchField(String fieldName, Set<ClassDocImpl> searched) {
  1047     private FieldDocImpl searchField(String fieldName, Set<ClassDocImpl> searched) {
  1048         Names names = tsym.name.table.names;
  1048         Names names = tsym.name.table.names;
  1049         if (searched.contains(this)) {
  1049         if (searched.contains(this)) {
  1104     @Deprecated
  1104     @Deprecated
  1105     public ClassDoc[] importedClasses() {
  1105     public ClassDoc[] importedClasses() {
  1106         // information is not available for binary classfiles
  1106         // information is not available for binary classfiles
  1107         if (tsym.sourcefile == null) return new ClassDoc[0];
  1107         if (tsym.sourcefile == null) return new ClassDoc[0];
  1108 
  1108 
  1109         ListBuffer<ClassDocImpl> importedClasses = new ListBuffer<ClassDocImpl>();
  1109         ListBuffer<ClassDocImpl> importedClasses = new ListBuffer<>();
  1110 
  1110 
  1111         Env<AttrContext> compenv = env.enter.getEnv(tsym);
  1111         Env<AttrContext> compenv = env.enter.getEnv(tsym);
  1112         if (compenv == null) return new ClassDocImpl[0];
  1112         if (compenv == null) return new ClassDocImpl[0];
  1113 
  1113 
  1114         Name asterisk = tsym.name.table.names.asterisk;
  1114         Name asterisk = tsym.name.table.names.asterisk;
  1142     @Deprecated
  1142     @Deprecated
  1143     public PackageDoc[] importedPackages() {
  1143     public PackageDoc[] importedPackages() {
  1144         // information is not available for binary classfiles
  1144         // information is not available for binary classfiles
  1145         if (tsym.sourcefile == null) return new PackageDoc[0];
  1145         if (tsym.sourcefile == null) return new PackageDoc[0];
  1146 
  1146 
  1147         ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<PackageDocImpl>();
  1147         ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<>();
  1148 
  1148 
  1149         //### Add the implicit "import java.lang.*" to the result
  1149         //### Add the implicit "import java.lang.*" to the result
  1150         Names names = tsym.name.table.names;
  1150         Names names = tsym.name.table.names;
  1151         importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
  1151         importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
  1152 
  1152