8281533: Odd "preview" label in link/linkplain
Reviewed-by: jjg
This commit is contained in:
parent
c7690c34c2
commit
55851a312b
@ -52,6 +52,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.Utils.ElementFlag;
|
|||||||
import jdk.javadoc.internal.html.Content;
|
import jdk.javadoc.internal.html.Content;
|
||||||
import jdk.javadoc.internal.html.ContentBuilder;
|
import jdk.javadoc.internal.html.ContentBuilder;
|
||||||
import jdk.javadoc.internal.html.Entity;
|
import jdk.javadoc.internal.html.Entity;
|
||||||
|
import jdk.javadoc.internal.html.HtmlId;
|
||||||
import jdk.javadoc.internal.html.HtmlTag;
|
import jdk.javadoc.internal.html.HtmlTag;
|
||||||
import jdk.javadoc.internal.html.HtmlTree;
|
import jdk.javadoc.internal.html.HtmlTree;
|
||||||
import jdk.javadoc.internal.html.Text;
|
import jdk.javadoc.internal.html.Text;
|
||||||
@ -296,26 +297,12 @@ public class HtmlLinkFactory {
|
|||||||
Content link = new ContentBuilder();
|
Content link = new ContentBuilder();
|
||||||
if (utils.isIncluded(typeElement)) {
|
if (utils.isIncluded(typeElement)) {
|
||||||
if (configuration.isGeneratedDoc(typeElement) && !utils.hasHiddenTag(typeElement)) {
|
if (configuration.isGeneratedDoc(typeElement) && !utils.hasHiddenTag(typeElement)) {
|
||||||
DocPath filename = getPath(linkInfo);
|
DocPath fileName = getPath(linkInfo);
|
||||||
if (linkInfo.linkToSelf() || typeElement != m_writer.getCurrentPageElement()) {
|
if (linkInfo.linkToSelf() || typeElement != m_writer.getCurrentPageElement()) {
|
||||||
link.add(m_writer.links.createLink(
|
link.add(m_writer.links.createLink(
|
||||||
filename.fragment(linkInfo.getFragment()),
|
fileName.fragment(linkInfo.getFragment()),
|
||||||
label,
|
label, linkInfo.getStyle(), title));
|
||||||
linkInfo.getStyle(),
|
addSuperscript(link, flags, fileName, null, previewTarget, restrictedTarget);
|
||||||
title));
|
|
||||||
Content spacer = Text.EMPTY;
|
|
||||||
if (flags.contains(ElementFlag.PREVIEW)) {
|
|
||||||
link.add(HtmlTree.SUP(m_writer.links.createLink(
|
|
||||||
filename.fragment(m_writer.htmlIds.forPreviewSection(previewTarget).name()),
|
|
||||||
m_writer.contents.previewMark)));
|
|
||||||
spacer = Entity.NO_BREAK_SPACE;
|
|
||||||
}
|
|
||||||
if (flags.contains(ElementFlag.RESTRICTED)) {
|
|
||||||
link.add(spacer);
|
|
||||||
link.add(HtmlTree.SUP(m_writer.links.createLink(
|
|
||||||
filename.fragment(m_writer.htmlIds.forRestrictedSection(restrictedTarget).name()),
|
|
||||||
m_writer.contents.restrictedMark)));
|
|
||||||
}
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,38 +312,61 @@ public class HtmlLinkFactory {
|
|||||||
label, linkInfo.getStyle(), true);
|
label, linkInfo.getStyle(), true);
|
||||||
if (crossLink != null) {
|
if (crossLink != null) {
|
||||||
link.add(crossLink);
|
link.add(crossLink);
|
||||||
Content spacer = Text.EMPTY;
|
addSuperscript(link, flags, null, typeElement, previewTarget, restrictedTarget);
|
||||||
if (flags.contains(ElementFlag.PREVIEW)) {
|
|
||||||
link.add(HtmlTree.SUP(m_writer.getCrossClassLink(
|
|
||||||
typeElement,
|
|
||||||
m_writer.htmlIds.forPreviewSection(previewTarget).name(),
|
|
||||||
m_writer.contents.previewMark,
|
|
||||||
null, false)));
|
|
||||||
spacer = Entity.NO_BREAK_SPACE;
|
|
||||||
}
|
|
||||||
if (flags.contains(ElementFlag.RESTRICTED)) {
|
|
||||||
link.add(spacer);
|
|
||||||
link.add(HtmlTree.SUP(m_writer.getCrossClassLink(
|
|
||||||
typeElement,
|
|
||||||
m_writer.htmlIds.forRestrictedSection(restrictedTarget).name(),
|
|
||||||
m_writer.contents.restrictedMark,
|
|
||||||
null, false)));
|
|
||||||
}
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Can't link so just write label.
|
// Can't link so just write label.
|
||||||
link.add(label);
|
link.add(label);
|
||||||
|
addSuperscript(link, flags, null, null, previewTarget, restrictedTarget);
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds PREVIEW and RESTRICTED superscript labels. Depending on the parameter values,
|
||||||
|
* labels will be formatted as local or external links or plain text.
|
||||||
|
*
|
||||||
|
* @param content the content to add to
|
||||||
|
* @param flags the flags
|
||||||
|
* @param fileName file name to link to, or null if no local link target
|
||||||
|
* @param typeElement external type to link to, or null if no external link
|
||||||
|
* @param previewTarget preview link target element
|
||||||
|
* @param restrictedTarget restricted link target element
|
||||||
|
*/
|
||||||
|
private void addSuperscript(Content content, Set<ElementFlag> flags, DocPath fileName, TypeElement typeElement,
|
||||||
|
Element previewTarget, ExecutableElement restrictedTarget) {
|
||||||
Content spacer = Text.EMPTY;
|
Content spacer = Text.EMPTY;
|
||||||
if (flags.contains(ElementFlag.PREVIEW)) {
|
if (flags.contains(ElementFlag.PREVIEW)) {
|
||||||
link.add(HtmlTree.SUP(m_writer.contents.previewMark));
|
content.add(HtmlTree.SUP(getSuperscript(fileName, typeElement,
|
||||||
|
m_writer.htmlIds.forPreviewSection(previewTarget),
|
||||||
|
m_writer.contents.previewMark)));
|
||||||
spacer = Entity.NO_BREAK_SPACE;
|
spacer = Entity.NO_BREAK_SPACE;
|
||||||
}
|
}
|
||||||
if (flags.contains(ElementFlag.RESTRICTED)) {
|
if (flags.contains(ElementFlag.RESTRICTED)) {
|
||||||
link.add(spacer);
|
content.add(spacer);
|
||||||
link.add(HtmlTree.SUP(m_writer.contents.restrictedMark));
|
content.add(HtmlTree.SUP(getSuperscript(fileName, typeElement,
|
||||||
|
m_writer.htmlIds.forRestrictedSection(restrictedTarget),
|
||||||
|
m_writer.contents.restrictedMark)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns PREVIEW or RESTRICTED superscript as either local or external link or as plain text.
|
||||||
|
*
|
||||||
|
* @param fileName local file name to link to, or null if no local link target
|
||||||
|
* @param typeElement external type to link to, or null if no external link
|
||||||
|
* @param id the id fragment to link to
|
||||||
|
* @param label the label content
|
||||||
|
* @return superscript content
|
||||||
|
*/
|
||||||
|
private Content getSuperscript(DocPath fileName, TypeElement typeElement, HtmlId id, Content label) {
|
||||||
|
if (fileName != null) {
|
||||||
|
return m_writer.links.createLink(fileName.fragment(id.name()), label);
|
||||||
|
} else if (typeElement != null) {
|
||||||
|
return (m_writer.getCrossClassLink(typeElement, id.name(), label, null, false));
|
||||||
|
} else {
|
||||||
|
return label;
|
||||||
}
|
}
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,6 +224,7 @@ public class LinkTaglet extends BaseTaglet {
|
|||||||
labelContent = plainOrCode(isPlain, Text.of(utils.getSimpleName(refClass)));
|
labelContent = plainOrCode(isPlain, Text.of(utils.getSimpleName(refClass)));
|
||||||
}
|
}
|
||||||
return htmlWriter.getLink(new HtmlLinkInfo(config, HtmlLinkInfo.Kind.PLAIN, refClass)
|
return htmlWriter.getLink(new HtmlLinkInfo(config, HtmlLinkInfo.Kind.PLAIN, refClass)
|
||||||
|
.skipPreview(isPlain)
|
||||||
.label(labelContent));
|
.label(labelContent));
|
||||||
} else if (refMem == null) {
|
} else if (refMem == null) {
|
||||||
// This is a fragment reference since refClass and refFragment are not null but refMem is null.
|
// This is a fragment reference since refClass and refFragment are not null but refMem is null.
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8250768 8261976 8277300 8282452 8287597 8325325 8325874 8297879
|
* @bug 8250768 8261976 8277300 8282452 8287597 8325325 8325874 8297879
|
||||||
* 8331947
|
* 8331947 8281533
|
||||||
* @summary test generated docs for items declared using preview
|
* @summary test generated docs for items declared using preview
|
||||||
* @library ../../lib
|
* @library ../../lib
|
||||||
* @modules jdk.javadoc/jdk.javadoc.internal.tool
|
* @modules jdk.javadoc/jdk.javadoc.internal.tool
|
||||||
@ -156,7 +156,20 @@ public class TestPreview extends JavadocTester {
|
|||||||
<li><a href="../module-summary.html">java.base</a></li>
|
<li><a href="../module-summary.html">java.base</a></li>
|
||||||
<li><a href="package-summary.html">preview</a></li>
|
<li><a href="package-summary.html">preview</a></li>
|
||||||
<li><a href="Core.html" class="current-selection">Core</a></li>
|
<li><a href="Core.html" class="current-selection">Core</a></li>
|
||||||
</ol>""");
|
</ol>""",
|
||||||
|
"""
|
||||||
|
<div class="block">Preview feature. Links: <a href="CoreRecord.html" title="cla\
|
||||||
|
ss in preview"><code>CoreRecord</code></a><sup><a href="CoreRecord.html#preview\
|
||||||
|
-preview.CoreRecord">PREVIEW</a></sup>, <a href="CoreRecord.html" title="class \
|
||||||
|
in preview"><code>core record</code></a><sup><a href="CoreRecord.html#preview-p\
|
||||||
|
review.CoreRecord">PREVIEW</a></sup>,
|
||||||
|
<a href="CoreRecord.html" title="class in preview">CoreRecord</a>, <a href="Co\
|
||||||
|
reRecord.html" title="class in preview">core record</a>.</div>""",
|
||||||
|
"""
|
||||||
|
<li><a href="CoreRecord.html" title="class in preview"><code>CoreRecord</code><\
|
||||||
|
/a><sup><a href="CoreRecord.html#preview-preview.CoreRecord">PREVIEW</a></sup><\
|
||||||
|
/li>
|
||||||
|
<li><a href="CoreRecord.html" title="class in preview">core record</a></li>""");
|
||||||
|
|
||||||
// 8331947: Support preview features without JEP should not be included in Preview API page
|
// 8331947: Support preview features without JEP should not be included in Preview API page
|
||||||
checkOutput("preview-list.html", false, "supportMethod");
|
checkOutput("preview-list.html", false, "supportMethod");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,6 +25,13 @@ package preview;
|
|||||||
import jdk.internal.javac.PreviewFeature;
|
import jdk.internal.javac.PreviewFeature;
|
||||||
import jdk.internal.javac.PreviewFeature.Feature;
|
import jdk.internal.javac.PreviewFeature.Feature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preview feature. Links: {@link CoreRecord}, {@link CoreRecord core record},
|
||||||
|
* {@linkplain CoreRecord}, {@linkplain CoreRecord core record}.
|
||||||
|
*
|
||||||
|
* @see CoreRecord
|
||||||
|
* @see CoreRecord core record
|
||||||
|
*/
|
||||||
@PreviewFeature(feature=Feature.TEST)
|
@PreviewFeature(feature=Feature.TEST)
|
||||||
public class Core {
|
public class Core {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user