/**
  * Construct a new ConstructorWriterImpl.
  *
  * @param writer The writer for the class that the constructors belong to.
  * @param classDoc the class being documented.
  */
 public ConstructorWriterImpl(SubWriterHolderWriter writer, ClassDoc classDoc) {
   super(writer, classDoc);
   VisibleMemberMap visibleMemberMap =
       new VisibleMemberMap(classDoc, VisibleMemberMap.CONSTRUCTORS, configuration);
   List<ProgramElementDoc> constructors =
       new ArrayList<>(visibleMemberMap.getMembersFor(classDoc));
   for (ProgramElementDoc constructor : constructors) {
     if (constructor.isProtected() || constructor.isPrivate()) {
       setFoundNonPubConstructor(true);
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * Add qualifiers for the program element as attributes.
   *
   * @param ped The given program element.
   */
  public void addCommonModifiers(ProgramElementDoc ped, int indent) {
    addSourcePosition(ped, indent);
    // Static and final and visibility on one line
    for (int i = 0; i < indent; i++) outputFile.print(" ");
    outputFile.print("static=\"" + ped.isStatic() + "\"");
    outputFile.print(" final=\"" + ped.isFinal() + "\"");
    // Visibility
    String visibility = null;
    if (ped.isPublic()) visibility = "public";
    else if (ped.isProtected()) visibility = "protected";
    else if (ped.isPackagePrivate()) visibility = "package";
    else if (ped.isPrivate()) visibility = "private";
    outputFile.println(" visibility=\"" + visibility + "\"");

    // Deprecation on its own line
    for (int i = 0; i < indent; i++) outputFile.print(" ");
    boolean isDeprecated = false;
    Tag[] ta = ((Doc) ped).tags("deprecated");
    if (ta.length != 0) {
      isDeprecated = true;
    }
    if (ta.length > 1) {
      System.out.println(
          "JDiff: warning: multiple @deprecated tags found in comments for "
              + ped.name()
              + ". Using the first one only.");
      System.out.println("Text is: " + ((Doc) ped).getRawCommentText());
    }
    if (isDeprecated) {
      String text = ta[0].text(); // Use only one @deprecated tag
      if (text != null && text.compareTo("") != 0) {
        int idx = endOfFirstSentence(text);
        if (idx == 0) {
          // No useful comment
          outputFile.print("deprecated=\"deprecated, no comment\"");
        } else {
          String fs = null;
          if (idx == -1) fs = text;
          else fs = text.substring(0, idx + 1);
          String st = API.hideHTMLTags(fs);
          outputFile.print("deprecated=\"" + st + "\"");
        }
      } else {
        outputFile.print("deprecated=\"deprecated, no comment\"");
      }
    } else {
      outputFile.print("deprecated=\"not deprecated\"");
    }
  } // addQualifiers()
 /** {@inheritDoc} */
 protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   if (foundNonPubConstructor) {
     Content code = new HtmlTree(HtmlTag.CODE);
     if (member.isProtected()) {
       code.addContent("protected ");
     } else if (member.isPrivate()) {
       code.addContent("private ");
     } else if (member.isPublic()) {
       code.addContent(writer.getSpace());
     } else {
       code.addContent(configuration.getText("doclet.Package_private"));
     }
     tdSummaryType.addContent(code);
   }
 }