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 } |
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 |