src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java

changeset 1745
937aa020c667
parent 1744
76a691e3e961
child 1746
bd51ca92c013
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue May 14 10:14:54 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue May 14 10:14:55 2013 -0700
     1.3 @@ -1390,17 +1390,17 @@
     1.4          return emd.name() + signatureParsed.toString();
     1.5      }
     1.6  
     1.7 -    public String seeTagToString(SeeTag see) {
     1.8 +    public Content seeTagToContent(SeeTag see) {
     1.9          String tagName = see.name();
    1.10          if (! (tagName.startsWith("@link") || tagName.equals("@see"))) {
    1.11 -            return "";
    1.12 +            return new ContentBuilder();
    1.13          }
    1.14  
    1.15          String seetext = replaceDocRootDir(see.text());
    1.16  
    1.17          //Check if @see is an href or "string"
    1.18          if (seetext.startsWith("<") || seetext.startsWith("\"")) {
    1.19 -            return seetext;
    1.20 +            return new RawHtml(seetext);
    1.21          }
    1.22  
    1.23          boolean plain = tagName.equalsIgnoreCase("@linkplain");
    1.24 @@ -1421,7 +1421,7 @@
    1.25                  //@see is referencing an included package
    1.26                  if (label.isEmpty())
    1.27                      label = plainOrCode(plain, new StringContent(refPackage.name()));
    1.28 -                return getPackageLink(refPackage, label).toString();
    1.29 +                return getPackageLink(refPackage, label);
    1.30              } else {
    1.31                  //@see is not referencing an included class or package.  Check for cross links.
    1.32                  Content classCrossLink;
    1.33 @@ -1429,16 +1429,16 @@
    1.34                  if (packageCrossLink != null) {
    1.35                      //Package cross link found
    1.36                      return getHyperLink(packageCrossLink,
    1.37 -                        (label.isEmpty() ? text : label)).toString();
    1.38 +                        (label.isEmpty() ? text : label));
    1.39                  } else if ((classCrossLink = getCrossClassLink(refClassName,
    1.40                          refMemName, label, false, "", !plain)) != null) {
    1.41                      //Class cross link found (possibly to a member in the class)
    1.42 -                    return classCrossLink.toString();
    1.43 +                    return classCrossLink;
    1.44                  } else {
    1.45                      //No cross link found so print warning
    1.46                      configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found",
    1.47                              tagName, seetext);
    1.48 -                    return (label.isEmpty() ? text: label).toString();
    1.49 +                    return (label.isEmpty() ? text: label);
    1.50                  }
    1.51              }
    1.52          } else if (refMemName == null) {
    1.53 @@ -1447,11 +1447,11 @@
    1.54                  label = plainOrCode(plain, new StringContent(refClass.name()));
    1.55              }
    1.56              return getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, refClass)
    1.57 -                    .label(label)).toString();
    1.58 +                    .label(label));
    1.59          } else if (refMem == null) {
    1.60              // Must be a member reference since refClass is not null and refMemName is not null.
    1.61              // However, refMem is null, so this referenced member does not exist.
    1.62 -            return (label.isEmpty() ? text: label).toString();
    1.63 +            return (label.isEmpty() ? text: label);
    1.64          } else {
    1.65              // Must be a member reference since refClass is not null and refMemName is not null.
    1.66              // refMem is not null, so this @see tag must be referencing a valid member.
    1.67 @@ -1487,14 +1487,10 @@
    1.68              text = plainOrCode(plain, new StringContent(refMemName));
    1.69  
    1.70              return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
    1.71 -                refMem, (label.isEmpty() ? text: label).toString(), false).toString();
    1.72 +                refMem, (label.isEmpty() ? text: label).toString(), false);
    1.73          }
    1.74      }
    1.75  
    1.76 -    private String plainOrCodeText(boolean plain, String text) {
    1.77 -        return (plain || text.isEmpty()) ? text : codeText(text);
    1.78 -    }
    1.79 -
    1.80      private Content plainOrCode(boolean plain, Content body) {
    1.81          return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
    1.82      }
    1.83 @@ -1586,7 +1582,7 @@
    1.84              return;
    1.85          }
    1.86          Content div;
    1.87 -        Content result = new RawHtml(commentTagsToString(holderTag, doc, tags, first));
    1.88 +        Content result = commentTagsToContent(null, doc, tags, first);
    1.89          if (depr) {
    1.90              Content italic = HtmlTree.I(result);
    1.91              div = HtmlTree.DIV(HtmlStyle.block, italic);
    1.92 @@ -1613,9 +1609,9 @@
    1.93       *               present in the text of interest for this doc
    1.94       * @param isFirstSentence  true if text is first sentence
    1.95       */
    1.96 -    public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
    1.97 +    public Content commentTagsToContent(Tag holderTag, Doc doc, Tag[] tags,
    1.98              boolean isFirstSentence) {
    1.99 -        StringBuilder result = new StringBuilder();
   1.100 +        ContentBuilder result = new ContentBuilder();
   1.101          boolean textTagChange = false;
   1.102          // Array of all possible inline tags for this javadoc run
   1.103          configuration.tagletManager.checkTags(doc, tags, true);
   1.104 @@ -1623,14 +1619,15 @@
   1.105              Tag tagelem = tags[i];
   1.106              String tagName = tagelem.name();
   1.107              if (tagelem instanceof SeeTag) {
   1.108 -                result.append(seeTagToString((SeeTag)tagelem));
   1.109 +                result.addContent(seeTagToContent((SeeTag) tagelem));
   1.110              } else if (! tagName.equals("Text")) {
   1.111 -                int originalLength = result.length();
   1.112 +                boolean wasEmpty = result.isEmpty();
   1.113                  TagletOutput output = TagletWriter.getInlineTagOuput(
   1.114                      configuration.tagletManager, holderTag,
   1.115                      tagelem, getTagletWriterInstance(isFirstSentence));
   1.116 -                result.append(output == null ? "" : output.toString());
   1.117 -                if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) {
   1.118 +                if (output != null)
   1.119 +                    result.addContent(((TagletOutputImpl) output).getContent());
   1.120 +                if (wasEmpty && isFirstSentence && tagelem.name().equals("@inheritDoc") && !result.isEmpty()) {
   1.121                      break;
   1.122                  } else if (configuration.docrootparent.length() > 0 &&
   1.123                          tagelem.name().equals("@docRoot") &&
   1.124 @@ -1669,10 +1666,10 @@
   1.125                      Util.replaceTabs(configuration, line);
   1.126                      textBuff.append(line.toString());
   1.127                  }
   1.128 -                result.append(textBuff);
   1.129 +                result.addContent(new RawHtml(textBuff.toString()));
   1.130              }
   1.131          }
   1.132 -        return result.toString();
   1.133 +        return result;
   1.134      }
   1.135  
   1.136      /**

mercurial