1644 * that relative link will no longer work. We should redirect those links
1645 * so that they will work again.
1646 * <p>
1647 * Here is the algorithm used to fix the link:
1648 * <p>
1649 * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
1650 * <p>
1651 * For example, suppose DocletEnvironment has this link:
1652 * {@literal <a href="package-summary.html">The package Page</a> }
1653 * <p>
1654 * If this link appeared in the index, we would redirect
1655 * the link like this:
1656 *
1657 * {@literal <a href="./jdk/javadoc/doclet/package-summary.html">The package Page</a>}
1658 *
1659 * @param element the Element object whose documentation is being written.
1660 * @param tt the text being written.
1661 *
1662 * @return the text, with all the relative links redirected to work.
1663 */
1664 @SuppressWarnings("removal")
1665 private String redirectRelativeLinks(Element element, TextTree tt) {
1666 String text = tt.getBody();
1667 if (element == null || utils.isOverviewElement(element) || shouldNotRedirectRelativeLinks()) {
1668 return text;
1669 }
1670
1671 DocPath redirectPathFromRoot = new SimpleElementVisitor14<DocPath, Void>() {
1672 @Override
1673 public DocPath visitType(TypeElement e, Void p) {
1674 return docPaths.forPackage(utils.containingPackage(e));
1675 }
1676
1677 @Override
1678 public DocPath visitPackage(PackageElement e, Void p) {
1679 return docPaths.forPackage(e);
1680 }
1681
1682 @Override
1683 public DocPath visitVariable(VariableElement e, Void p) {
1684 return docPaths.forPackage(utils.containingPackage(e));
|
1644 * that relative link will no longer work. We should redirect those links
1645 * so that they will work again.
1646 * <p>
1647 * Here is the algorithm used to fix the link:
1648 * <p>
1649 * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
1650 * <p>
1651 * For example, suppose DocletEnvironment has this link:
1652 * {@literal <a href="package-summary.html">The package Page</a> }
1653 * <p>
1654 * If this link appeared in the index, we would redirect
1655 * the link like this:
1656 *
1657 * {@literal <a href="./jdk/javadoc/doclet/package-summary.html">The package Page</a>}
1658 *
1659 * @param element the Element object whose documentation is being written.
1660 * @param tt the text being written.
1661 *
1662 * @return the text, with all the relative links redirected to work.
1663 */
1664 @SuppressWarnings("preview")
1665 private String redirectRelativeLinks(Element element, TextTree tt) {
1666 String text = tt.getBody();
1667 if (element == null || utils.isOverviewElement(element) || shouldNotRedirectRelativeLinks()) {
1668 return text;
1669 }
1670
1671 DocPath redirectPathFromRoot = new SimpleElementVisitor14<DocPath, Void>() {
1672 @Override
1673 public DocPath visitType(TypeElement e, Void p) {
1674 return docPaths.forPackage(utils.containingPackage(e));
1675 }
1676
1677 @Override
1678 public DocPath visitPackage(PackageElement e, Void p) {
1679 return docPaths.forPackage(e);
1680 }
1681
1682 @Override
1683 public DocPath visitVariable(VariableElement e, Void p) {
1684 return docPaths.forPackage(utils.containingPackage(e));
|