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

changeset 1745
937aa020c667
parent 1744
76a691e3e961
child 1746
bd51ca92c013
equal deleted inserted replaced
1744:76a691e3e961 1745:937aa020c667
1388 } 1388 }
1389 } 1389 }
1390 return emd.name() + signatureParsed.toString(); 1390 return emd.name() + signatureParsed.toString();
1391 } 1391 }
1392 1392
1393 public String seeTagToString(SeeTag see) { 1393 public Content seeTagToContent(SeeTag see) {
1394 String tagName = see.name(); 1394 String tagName = see.name();
1395 if (! (tagName.startsWith("@link") || tagName.equals("@see"))) { 1395 if (! (tagName.startsWith("@link") || tagName.equals("@see"))) {
1396 return ""; 1396 return new ContentBuilder();
1397 } 1397 }
1398 1398
1399 String seetext = replaceDocRootDir(see.text()); 1399 String seetext = replaceDocRootDir(see.text());
1400 1400
1401 //Check if @see is an href or "string" 1401 //Check if @see is an href or "string"
1402 if (seetext.startsWith("<") || seetext.startsWith("\"")) { 1402 if (seetext.startsWith("<") || seetext.startsWith("\"")) {
1403 return seetext; 1403 return new RawHtml(seetext);
1404 } 1404 }
1405 1405
1406 boolean plain = tagName.equalsIgnoreCase("@linkplain"); 1406 boolean plain = tagName.equalsIgnoreCase("@linkplain");
1407 Content label = plainOrCode(plain, new RawHtml(see.label())); 1407 Content label = plainOrCode(plain, new RawHtml(see.label()));
1408 1408
1419 PackageDoc refPackage = see.referencedPackage(); 1419 PackageDoc refPackage = see.referencedPackage();
1420 if (refPackage != null && refPackage.isIncluded()) { 1420 if (refPackage != null && refPackage.isIncluded()) {
1421 //@see is referencing an included package 1421 //@see is referencing an included package
1422 if (label.isEmpty()) 1422 if (label.isEmpty())
1423 label = plainOrCode(plain, new StringContent(refPackage.name())); 1423 label = plainOrCode(plain, new StringContent(refPackage.name()));
1424 return getPackageLink(refPackage, label).toString(); 1424 return getPackageLink(refPackage, label);
1425 } else { 1425 } else {
1426 //@see is not referencing an included class or package. Check for cross links. 1426 //@see is not referencing an included class or package. Check for cross links.
1427 Content classCrossLink; 1427 Content classCrossLink;
1428 DocLink packageCrossLink = getCrossPackageLink(refClassName); 1428 DocLink packageCrossLink = getCrossPackageLink(refClassName);
1429 if (packageCrossLink != null) { 1429 if (packageCrossLink != null) {
1430 //Package cross link found 1430 //Package cross link found
1431 return getHyperLink(packageCrossLink, 1431 return getHyperLink(packageCrossLink,
1432 (label.isEmpty() ? text : label)).toString(); 1432 (label.isEmpty() ? text : label));
1433 } else if ((classCrossLink = getCrossClassLink(refClassName, 1433 } else if ((classCrossLink = getCrossClassLink(refClassName,
1434 refMemName, label, false, "", !plain)) != null) { 1434 refMemName, label, false, "", !plain)) != null) {
1435 //Class cross link found (possibly to a member in the class) 1435 //Class cross link found (possibly to a member in the class)
1436 return classCrossLink.toString(); 1436 return classCrossLink;
1437 } else { 1437 } else {
1438 //No cross link found so print warning 1438 //No cross link found so print warning
1439 configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found", 1439 configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found",
1440 tagName, seetext); 1440 tagName, seetext);
1441 return (label.isEmpty() ? text: label).toString(); 1441 return (label.isEmpty() ? text: label);
1442 } 1442 }
1443 } 1443 }
1444 } else if (refMemName == null) { 1444 } else if (refMemName == null) {
1445 // Must be a class reference since refClass is not null and refMemName is null. 1445 // Must be a class reference since refClass is not null and refMemName is null.
1446 if (label.isEmpty()) { 1446 if (label.isEmpty()) {
1447 label = plainOrCode(plain, new StringContent(refClass.name())); 1447 label = plainOrCode(plain, new StringContent(refClass.name()));
1448 } 1448 }
1449 return getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, refClass) 1449 return getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, refClass)
1450 .label(label)).toString(); 1450 .label(label));
1451 } else if (refMem == null) { 1451 } else if (refMem == null) {
1452 // Must be a member reference since refClass is not null and refMemName is not null. 1452 // Must be a member reference since refClass is not null and refMemName is not null.
1453 // However, refMem is null, so this referenced member does not exist. 1453 // However, refMem is null, so this referenced member does not exist.
1454 return (label.isEmpty() ? text: label).toString(); 1454 return (label.isEmpty() ? text: label);
1455 } else { 1455 } else {
1456 // Must be a member reference since refClass is not null and refMemName is not null. 1456 // Must be a member reference since refClass is not null and refMemName is not null.
1457 // refMem is not null, so this @see tag must be referencing a valid member. 1457 // refMem is not null, so this @see tag must be referencing a valid member.
1458 ClassDoc containing = refMem.containingClass(); 1458 ClassDoc containing = refMem.containingClass();
1459 if (see.text().trim().startsWith("#") && 1459 if (see.text().trim().startsWith("#") &&
1485 } 1485 }
1486 1486
1487 text = plainOrCode(plain, new StringContent(refMemName)); 1487 text = plainOrCode(plain, new StringContent(refMemName));
1488 1488
1489 return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing, 1489 return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
1490 refMem, (label.isEmpty() ? text: label).toString(), false).toString(); 1490 refMem, (label.isEmpty() ? text: label).toString(), false);
1491 } 1491 }
1492 }
1493
1494 private String plainOrCodeText(boolean plain, String text) {
1495 return (plain || text.isEmpty()) ? text : codeText(text);
1496 } 1492 }
1497 1493
1498 private Content plainOrCode(boolean plain, Content body) { 1494 private Content plainOrCode(boolean plain, Content body) {
1499 return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body); 1495 return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
1500 } 1496 }
1584 boolean first, Content htmltree) { 1580 boolean first, Content htmltree) {
1585 if(configuration.nocomment){ 1581 if(configuration.nocomment){
1586 return; 1582 return;
1587 } 1583 }
1588 Content div; 1584 Content div;
1589 Content result = new RawHtml(commentTagsToString(holderTag, doc, tags, first)); 1585 Content result = commentTagsToContent(null, doc, tags, first);
1590 if (depr) { 1586 if (depr) {
1591 Content italic = HtmlTree.I(result); 1587 Content italic = HtmlTree.I(result);
1592 div = HtmlTree.DIV(HtmlStyle.block, italic); 1588 div = HtmlTree.DIV(HtmlStyle.block, italic);
1593 htmltree.addContent(div); 1589 htmltree.addContent(div);
1594 } 1590 }
1611 * @param doc specific doc where comment resides 1607 * @param doc specific doc where comment resides
1612 * @param tags array of text tags and inline tags (often alternating) 1608 * @param tags array of text tags and inline tags (often alternating)
1613 * present in the text of interest for this doc 1609 * present in the text of interest for this doc
1614 * @param isFirstSentence true if text is first sentence 1610 * @param isFirstSentence true if text is first sentence
1615 */ 1611 */
1616 public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags, 1612 public Content commentTagsToContent(Tag holderTag, Doc doc, Tag[] tags,
1617 boolean isFirstSentence) { 1613 boolean isFirstSentence) {
1618 StringBuilder result = new StringBuilder(); 1614 ContentBuilder result = new ContentBuilder();
1619 boolean textTagChange = false; 1615 boolean textTagChange = false;
1620 // Array of all possible inline tags for this javadoc run 1616 // Array of all possible inline tags for this javadoc run
1621 configuration.tagletManager.checkTags(doc, tags, true); 1617 configuration.tagletManager.checkTags(doc, tags, true);
1622 for (int i = 0; i < tags.length; i++) { 1618 for (int i = 0; i < tags.length; i++) {
1623 Tag tagelem = tags[i]; 1619 Tag tagelem = tags[i];
1624 String tagName = tagelem.name(); 1620 String tagName = tagelem.name();
1625 if (tagelem instanceof SeeTag) { 1621 if (tagelem instanceof SeeTag) {
1626 result.append(seeTagToString((SeeTag)tagelem)); 1622 result.addContent(seeTagToContent((SeeTag) tagelem));
1627 } else if (! tagName.equals("Text")) { 1623 } else if (! tagName.equals("Text")) {
1628 int originalLength = result.length(); 1624 boolean wasEmpty = result.isEmpty();
1629 TagletOutput output = TagletWriter.getInlineTagOuput( 1625 TagletOutput output = TagletWriter.getInlineTagOuput(
1630 configuration.tagletManager, holderTag, 1626 configuration.tagletManager, holderTag,
1631 tagelem, getTagletWriterInstance(isFirstSentence)); 1627 tagelem, getTagletWriterInstance(isFirstSentence));
1632 result.append(output == null ? "" : output.toString()); 1628 if (output != null)
1633 if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) { 1629 result.addContent(((TagletOutputImpl) output).getContent());
1630 if (wasEmpty && isFirstSentence && tagelem.name().equals("@inheritDoc") && !result.isEmpty()) {
1634 break; 1631 break;
1635 } else if (configuration.docrootparent.length() > 0 && 1632 } else if (configuration.docrootparent.length() > 0 &&
1636 tagelem.name().equals("@docRoot") && 1633 tagelem.name().equals("@docRoot") &&
1637 ((tags[i + 1]).text()).startsWith("/..")) { 1634 ((tags[i + 1]).text()).startsWith("/..")) {
1638 //If Xdocrootparent switch ON, set the flag to remove the /.. occurance after 1635 //If Xdocrootparent switch ON, set the flag to remove the /.. occurance after
1667 while (lines.hasMoreTokens()) { 1664 while (lines.hasMoreTokens()) {
1668 StringBuilder line = new StringBuilder(lines.nextToken()); 1665 StringBuilder line = new StringBuilder(lines.nextToken());
1669 Util.replaceTabs(configuration, line); 1666 Util.replaceTabs(configuration, line);
1670 textBuff.append(line.toString()); 1667 textBuff.append(line.toString());
1671 } 1668 }
1672 result.append(textBuff); 1669 result.addContent(new RawHtml(textBuff.toString()));
1673 } 1670 }
1674 } 1671 }
1675 return result.toString(); 1672 return result;
1676 } 1673 }
1677 1674
1678 /** 1675 /**
1679 * Return true if relative links should not be redirected. 1676 * Return true if relative links should not be redirected.
1680 * 1677 *

mercurial