/** * Generate the method types set and return true if the method summary table needs to show tabs. * * @return true if the table should show tabs */ public boolean showTabs() { int value; for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) { value = type.value(); if ((value & methodTypesOr) == value) { methodTypes.add(type); } } boolean showTabs = methodTypes.size() > 1; if (showTabs) { methodTypes.add(MethodTypes.ALL); } return showTabs; }
/** * Constructor. * * @param filename the file to be generated. * @throws IOException * @throws DocletAbortException */ public PackageUseWriter( ConfigurationImpl configuration, ClassUseMapper mapper, DocPath filename, PackageDoc pkgdoc) throws IOException { super(configuration, DocPath.forPackage(pkgdoc).resolve(filename)); this.pkgdoc = pkgdoc; // by examining all classes in this package, find what packages // use these classes - produce a map between using package and // used classes. ClassDoc[] content = pkgdoc.allClasses(); for (int i = 0; i < content.length; ++i) { ClassDoc usedClass = content[i]; Set<ClassDoc> usingClasses = mapper.classToClass.get(usedClass.qualifiedName()); if (usingClasses != null) { for (Iterator<ClassDoc> it = usingClasses.iterator(); it.hasNext(); ) { ClassDoc usingClass = it.next(); PackageDoc usingPackage = usingClass.containingPackage(); Set<ClassDoc> usedClasses = usingPackageToUsedClasses.get(usingPackage.name()); if (usedClasses == null) { usedClasses = new TreeSet<ClassDoc>(); usingPackageToUsedClasses.put(Util.getPackageName(usingPackage), usedClasses); } usedClasses.add(usedClass); } } } }
/** * Loop through each indivitual parameter. It it does not have a corresponding param tag, try to * inherit it. */ private TagletOutput getInheritedTagletOutput( boolean isNonTypeParams, Doc holder, TagletWriter writer, Object[] formalParameters, Set alreadyDocumented) { TagletOutput result = writer.getOutputInstance(); if ((!alreadyDocumented.contains(null)) && holder instanceof MethodDoc) { for (int i = 0; i < formalParameters.length; i++) { if (alreadyDocumented.contains(String.valueOf(i))) { continue; } // This parameter does not have any @param documentation. // Try to inherit it. DocFinder.Output inheritedDoc = DocFinder.search( new DocFinder.Input((MethodDoc) holder, this, String.valueOf(i), !isNonTypeParams)); if (inheritedDoc.inlineTags != null && inheritedDoc.inlineTags.length > 0) { result.appendOutput( processParamTag( isNonTypeParams, writer, (ParamTag) inheritedDoc.holderTag, isNonTypeParams ? ((Parameter) formalParameters[i]).name() : ((TypeVariable) formalParameters[i]).typeName(), alreadyDocumented.size() == 0)); } alreadyDocumented.add(String.valueOf(i)); } } return result; }
/** Add links for exceptions that are declared but not documented. */ private TagletOutput linkToUndocumentedDeclaredExceptions( Type[] declaredExceptionTypes, Set<String> alreadyDocumented, TagletWriter writer) { TagletOutput result = writer.getOutputInstance(); // Add links to the exceptions declared but not documented. for (int i = 0; i < declaredExceptionTypes.length; i++) { if (declaredExceptionTypes[i].asClassDoc() != null && !alreadyDocumented.contains(declaredExceptionTypes[i].asClassDoc().name()) && !alreadyDocumented.contains(declaredExceptionTypes[i].asClassDoc().qualifiedName())) { if (alreadyDocumented.size() == 0) { result.appendOutput(writer.getThrowsHeader()); } result.appendOutput(writer.throwsTagOutput(declaredExceptionTypes[i])); alreadyDocumented.add(declaredExceptionTypes[i].asClassDoc().name()); } } return result; }
/** * Given an array of <code>Tag</code>s representing this custom tag, return its string * representation. Print a warning for param tags that do not map to parameters. Print a warning * for param tags that are duplicated. * * @param paramTags the array of <code>ParamTag</code>s to convert. * @param writer the TagletWriter that will write this tag. * @param alreadyDocumented the set of exceptions that have already been documented. * @param rankMap a {@link java.util.Map} which holds ordering information about the parameters. * @param nameMap a {@link java.util.Map} which holds a mapping of a rank of a parameter to its * name. This is used to ensure that the right name is used when parameter documentation is * inherited. * @return the TagletOutput representation of this <code>Tag</code>. */ private TagletOutput processParamTags( boolean isNonTypeParams, ParamTag[] paramTags, Map rankMap, TagletWriter writer, Set alreadyDocumented) { TagletOutput result = writer.getOutputInstance(); if (paramTags.length > 0) { for (int i = 0; i < paramTags.length; ++i) { ParamTag pt = paramTags[i]; String paramName = isNonTypeParams ? pt.parameterName() : "<" + pt.parameterName() + ">"; if (!rankMap.containsKey(pt.parameterName())) { writer .getMsgRetriever() .warning( pt.position(), isNonTypeParams ? "doclet.Parameters_warn" : "doclet.Type_Parameters_warn", paramName); } String rank = (String) rankMap.get(pt.parameterName()); if (rank != null && alreadyDocumented.contains(rank)) { writer .getMsgRetriever() .warning( pt.position(), isNonTypeParams ? "doclet.Parameters_dup_warn" : "doclet.Type_Parameters_dup_warn", paramName); } result.appendOutput( processParamTag( isNonTypeParams, writer, pt, pt.parameterName(), alreadyDocumented.size() == 0)); alreadyDocumented.add(rank); } } return result; }
/** * Given an array of <code>Tag</code>s representing this custom tag, return its string * representation. * * @param throwTags the array of <code>ThrowsTag</code>s to convert. * @param writer the TagletWriter that will write this tag. * @param alreadyDocumented the set of exceptions that have already been documented. * @param allowDups True if we allow duplicate throws tags to be documented. * @return the TagletOutput representation of this <code>Tag</code>. */ protected TagletOutput throwsTagsOutput( ThrowsTag[] throwTags, TagletWriter writer, Set<String> alreadyDocumented, boolean allowDups) { TagletOutput result = writer.getOutputInstance(); if (throwTags.length > 0) { for (int i = 0; i < throwTags.length; ++i) { ThrowsTag tt = throwTags[i]; ClassDoc cd = tt.exception(); if ((!allowDups) && (alreadyDocumented.contains(tt.exceptionName()) || (cd != null && alreadyDocumented.contains(cd.qualifiedName())))) { continue; } if (alreadyDocumented.size() == 0) { result.appendOutput(writer.getThrowsHeader()); } result.appendOutput(writer.throwsTagOutput(tt)); alreadyDocumented.add(cd != null ? cd.qualifiedName() : tt.exceptionName()); } } return result; }