/**
   * 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);
        }
      }
    }
  }
 /** Generate the class use list. */
 protected void generateClassUseFile() throws IOException {
   Content body = getClassUseHeader();
   HtmlTree div = new HtmlTree(HtmlTag.DIV);
   div.addStyle(HtmlStyle.classUseContainer);
   if (pkgSet.size() > 0) {
     addClassUse(div);
   } else {
     div.addContent(getResource("doclet.ClassUse_No.usage.of.0", classdoc.qualifiedName()));
   }
   body.addContent(div);
   addNavLinks(false, body);
   addBottom(body);
   printHtmlDocument(null, true, body);
 }
 /**
  * Build the field information.
  *
  * @param node the XML element that specifies which components to document
  * @param fieldsContentTree content tree to which the documentation will be added
  */
 public void buildFieldInfo(XMLNode node, Content fieldsContentTree) {
   if (configuration.nocomment) {
     return;
   }
   FieldDoc field = (FieldDoc) currentMember;
   ClassDoc cd = field.containingClass();
   // Process default Serializable field.
   if ((field.tags("serial").length == 0) && !field.isSynthetic() && configuration.serialwarn) {
     configuration.message.warning(
         field.position(), "doclet.MissingSerialTag", cd.qualifiedName(), field.name());
   }
   fieldWriter.addMemberDescription(field, fieldsContentTree);
   fieldWriter.addMemberTags(field, fieldsContentTree);
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
 /**
  * Get the header for the class use Listing.
  *
  * @return a content tree representing the class use header
  */
 protected Content getClassUseHeader() {
   String cltype =
       configuration.getText(classdoc.isInterface() ? "doclet.Interface" : "doclet.Class");
   String clname = classdoc.qualifiedName();
   String title = configuration.getText("doclet.Window_ClassUse_Header", cltype, clname);
   Content bodyTree = getBody(true, getWindowTitle(title));
   addTop(bodyTree);
   addNavLinks(true, bodyTree);
   ContentBuilder headContent = new ContentBuilder();
   headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
   headContent.addContent(new HtmlTree(HtmlTag.BR));
   headContent.addContent(clname);
   Content heading =
       HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headContent);
   Content div = HtmlTree.DIV(HtmlStyle.header, heading);
   bodyTree.addContent(div);
   return bodyTree;
 }
 private Map<String, List<ProgramElementDoc>> pkgDivide(
     Map<String, ? extends List<? extends ProgramElementDoc>> classMap) {
   Map<String, List<ProgramElementDoc>> map = new HashMap<>();
   List<? extends ProgramElementDoc> list = classMap.get(classdoc.qualifiedName());
   if (list != null) {
     Collections.sort(list);
     for (ProgramElementDoc doc : list) {
       PackageDoc pkg = doc.containingPackage();
       pkgSet.add(pkg);
       List<ProgramElementDoc> inPkg = map.get(pkg.name());
       if (inPkg == null) {
         inPkg = new ArrayList<>();
         map.put(pkg.name(), inPkg);
       }
       inPkg.add(doc);
     }
   }
   return map;
 }
 /**
  * Constructor.
  *
  * @param filename the file to be generated.
  * @throws IOException
  * @throws DocletAbortException
  */
 public ClassUseWriter(
     ConfigurationImpl configuration, ClassUseMapper mapper, DocPath filename, ClassDoc classdoc)
     throws IOException {
   super(configuration, filename);
   this.classdoc = classdoc;
   if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName()))
     pkgToPackageAnnotations =
         new TreeSet<>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName()));
   configuration.currentcd = classdoc;
   this.pkgSet = new TreeSet<>();
   this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
   this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
   this.pkgToMethodTypeParameter = pkgDivide(mapper.classToExecMemberDocTypeParam);
   this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToExecMemberDocArgTypeParam);
   this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldDocTypeParam);
   this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToFieldDoc);
   this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToExecMemberDocReturnTypeParam);
   this.pkgToMethodAnnotations = pkgDivide(mapper.classToExecMemberDocAnnotations);
   this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToExecMemberDocParamAnnotation);
   this.pkgToSubclass = pkgDivide(mapper.classToSubclass);
   this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface);
   this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass);
   this.pkgToField = pkgDivide(mapper.classToField);
   this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn);
   this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs);
   this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows);
   this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations);
   this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation);
   this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs);
   this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorDocArgTypeParam);
   this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows);
   // tmp test
   if (pkgSet.size() > 0
       && mapper.classToPackage.containsKey(classdoc.qualifiedName())
       && !pkgSet.equals(mapper.classToPackage.get(classdoc.qualifiedName()))) {
     configuration.root.printWarning(
         "Internal error: package sets don't match: "
             + pkgSet
             + " with: "
             + mapper.classToPackage.get(classdoc.qualifiedName()));
   }
   methodSubWriter = new MethodWriterImpl(this);
   constrSubWriter = new ConstructorWriterImpl(this);
   fieldSubWriter = new FieldWriterImpl(this);
   classSubWriter = new NestedClassWriterImpl(this);
   classUseTableSummary =
       configuration.getText("doclet.Use_Table_Summary", configuration.getText("doclet.classes"));
   subclassUseTableSummary =
       configuration.getText(
           "doclet.Use_Table_Summary", configuration.getText("doclet.subclasses"));
   subinterfaceUseTableSummary =
       configuration.getText(
           "doclet.Use_Table_Summary", configuration.getText("doclet.subinterfaces"));
   fieldUseTableSummary =
       configuration.getText("doclet.Use_Table_Summary", configuration.getText("doclet.fields"));
   methodUseTableSummary =
       configuration.getText("doclet.Use_Table_Summary", configuration.getText("doclet.methods"));
   constructorUseTableSummary =
       configuration.getText(
           "doclet.Use_Table_Summary", configuration.getText("doclet.constructors"));
 }