8307377: Remove use of tagName from TagletWriterImpl.linkSeeReferenceOutput

Reviewed-by: hannesw
This commit is contained in:
Jonathan Gibbons
2023-05-10 22:05:58 +00:00
parent cc9f7ad9ce
commit f250ab2c2a
8 changed files with 41 additions and 47 deletions

View File

@@ -297,14 +297,12 @@ public class TagletWriterImpl extends TagletWriter {
}
DocTree.Kind kind = tag.getKind();
String tagName = ch.getTagName(tag);
String refSignature = ch.getReferencedSignature(linkRef);
return linkSeeReferenceOutput(element,
tag,
refSignature,
ch.getReferencedElement(tag),
tagName,
(kind == LINK_PLAIN),
htmlWriter.commentTagsToContent(element, tag.getLabel(), context),
(key, args) -> messages.warning(ch.getDocTreePath(tag), key, args)
@@ -431,7 +429,6 @@ public class TagletWriterImpl extends TagletWriter {
case REFERENCE -> {
// @see reference label...
CommentHelper ch = utils.getCommentHelper(element);
String tagName = ch.getTagName(seeTag);
String refSignature = ch.getReferencedSignature(ref0);
List<? extends DocTree> label = ref.subList(1, ref.size());
@@ -439,7 +436,6 @@ public class TagletWriterImpl extends TagletWriter {
seeTag,
refSignature,
ch.getReferencedElement(seeTag),
tagName,
false,
htmlWriter.commentTagsToContent(element, label, context),
(key, args) -> messages.warning(ch.getDocTreePath(seeTag), key, args)
@@ -466,7 +462,6 @@ public class TagletWriterImpl extends TagletWriter {
* @param refTree the tree node containing the information, or {@code null} if not available
* @param refSignature the normalized signature of the target of the reference
* @param ref the target of the reference
* @param tagName the name of the tag in the source, to be used in diagnostics
* @param isLinkPlain {@code true} if the link should be presented in "plain" font,
* or {@code false} for "code" font
* @param label the label for the link,
@@ -479,7 +474,6 @@ public class TagletWriterImpl extends TagletWriter {
DocTree refTree,
String refSignature,
Element ref,
String tagName,
boolean isLinkPlain,
Content label,
BiConsumer<String, Object[]> reportWarning) {
@@ -535,10 +529,10 @@ public class TagletWriterImpl extends TagletWriter {
// No cross link found so print warning
if (!configuration.isDocLintReferenceGroupEnabled()) {
reportWarning.accept(
"doclet.see.class_or_package_not_found",
new Object[] { "@" + tagName, refSignature});
"doclet.link.see.reference_not_found",
new Object[] { refSignature});
}
return htmlWriter.invalidTagOutput(resources.getText("doclet.tag.invalid", tagName),
return htmlWriter.invalidTagOutput(resources.getText("doclet.link.see.reference_invalid"),
Optional.of(labelContent.isEmpty() ? text: labelContent));
}
}
@@ -586,12 +580,12 @@ public class TagletWriterImpl extends TagletWriter {
if (htmlWriter instanceof ClassWriterImpl writer) {
containing = writer.getTypeElement();
} else if (!utils.isPublic(containing)) {
reportWarning.accept("doclet.see.class_or_package_not_accessible",
new Object[] { tagName, utils.getFullyQualifiedName(containing)});
reportWarning.accept("doclet.link.see.reference_not_accessible",
new Object[] { utils.getFullyQualifiedName(containing)});
} else {
if (!configuration.isDocLintReferenceGroupEnabled()) {
reportWarning.accept("doclet.see.class_or_package_not_found",
new Object[] { tagName, refSignature });
reportWarning.accept("doclet.link.see.reference_not_found",
new Object[] { refSignature });
}
}
}
@@ -697,7 +691,6 @@ public class TagletWriterImpl extends TagletWriter {
null,
t,
e,
"link",
false, // TODO: for now
Text.of(sequence.toString()),
(key, args) -> { /* TODO: report diagnostic */ });

View File

@@ -104,8 +104,9 @@ doclet.URL_error=Error fetching URL: {0}
doclet.Resource_error=Error reading resource: {0}
doclet.link.no_reference=no reference given
doclet.link.see.no_label=missing reference label
doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1}
doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1}
doclet.link.see.reference_invalid=invalid reference
doclet.link.see.reference_not_found=reference not found: {0}
doclet.link.see.reference_not_accessible=reference not accessible: {0}
doclet.see.nested_link=Tag {0}: nested link
doclet.throws.reference_not_found=cannot find exception type by name
doclet.throws.reference_bad_type=not an exception type: {0}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
* @bug 8252717
* @bug 8252717 8307377
* @summary Integrate/merge legacy standard doclet diagnostics and doclint
* @library ../../lib /tools/lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -87,7 +87,7 @@ public class TestDocLintDocletMessages extends JavadocTester {
""");
var doclintResult = new Result(Exit.ERROR, "C.java:3: error: reference not found");
var docletResult = new Result(Exit.OK, "C.java:3: warning: Tag @see: reference not found: DoesNotExist");
var docletResult = new Result(Exit.OK, "C.java:3: warning: reference not found: DoesNotExist");
testSingle(base, "reference", doclintResult, docletResult);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
* @bug 8177280 8262992 8259499
* @bug 8177280 8262992 8259499 8307377
* @summary see and link tag syntax should allow generic types
* @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -168,19 +168,19 @@ public class TestGenericTypeLink extends JavadocTester {
"""
<div class="block">
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>java.util.Foo&lt;String&gt;</code></pre>
</details>
\s
<details class="invalid-tag">
<summary>invalid @linkplain</summary>
<summary>invalid reference</summary>
<pre>Baz&lt;Object&gt;</pre>
</details>
\s
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>#b(List&lt;Integer&gt;)</code></pre>
</details>
</div>""",
@@ -192,19 +192,19 @@ public class TestGenericTypeLink extends JavadocTester {
<ul class="tag-list-long">
<li>
<details class="invalid-tag">
<summary>invalid @see</summary>
<summary>invalid reference</summary>
<pre><code>java.util.List&lt;Bar&gt;</code></pre>
</details>
</li>
<li>
<details class="invalid-tag">
<summary>invalid @see</summary>
<summary>invalid reference</summary>
<pre><code>Baz&lt;Object, String&gt;</code></pre>
</details>
</li>
<li>
<details class="invalid-tag">
<summary>invalid @see</summary>
<summary>invalid reference</summary>
<pre><code>B#b(List&lt;Baz&gt;)</code></pre>
</details>
</li>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
* @bug 8269722 8270866
* @bug 8269722 8270866 8307377
* @summary NPE in HtmlDocletWriter, reporting errors on inherited tags
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -149,7 +149,7 @@ public class TestInherited extends JavadocTester {
checkOutput("BadReference.Intf.html", true, """
<div class="block">
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>NonExistingClass</code></pre>
</details>
</div>
@@ -157,7 +157,7 @@ public class TestInherited extends JavadocTester {
checkOutput("BadReference.Impl1.html", true, """
<div class="block">
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>NonExistingClass</code></pre>
</details>
</div>
@@ -165,7 +165,7 @@ public class TestInherited extends JavadocTester {
checkOutput("BadReference.Impl2.html", true, """
<div class="block">
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>NonExistingClass</code></pre>
</details>
</div>
@@ -173,7 +173,7 @@ public class TestInherited extends JavadocTester {
checkOutput("BadReference.Impl3.html", true, """
<div class="block">
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>NonExistingClass</code></pre>
</details>
</div>

View File

@@ -23,7 +23,7 @@
/*
* @test
* @bug 8284030
* @bug 8284030 8307377
* @summary LinkFactory should not attempt to link to primitive types
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -68,21 +68,21 @@ public class TestLinkTagletPrimitive extends JavadocTester {
checkExit(Exit.OK);
checkOutput(Output.OUT, true,
"C.java:3: warning: Tag @link: reference not found: byte",
"C.java:4: warning: Tag @link: reference not found: void");
"C.java:3: warning: reference not found: byte",
"C.java:4: warning: reference not found: void");
checkOutput("C.html", true,
"""
<div class="block">Comment.
Byte:\s
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>byte</code></pre>
</details>
Void:\s
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>void</code></pre>
</details>
</div>
@@ -109,14 +109,14 @@ public class TestLinkTagletPrimitive extends JavadocTester {
checkExit(Exit.OK);
checkOutput(Output.OUT, true,
"C.java:3: warning: Tag @link: reference not found: byte[]");
"C.java:3: warning: reference not found: byte[]");
checkOutput("C.html", true,
"""
<div class="block">Comment.
Byte[]:\s
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>byte[]</code></pre>
</details>
</div>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
* @bug 8200337
* @bug 8200337 8307377
* @summary Generalize see and link tags for user-defined anchors
* @library /tools/lib ../../lib
* @modules
@@ -180,7 +180,7 @@ public class TestSeeLinkAnchor extends JavadocTester {
checkOutput("inv/Class1.html", true, """
Invalid link to\s
<details class="invalid-tag">
<summary>invalid @link</summary>
<summary>invalid reference</summary>
<pre><code>main heading</code></pre>
</details>""");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
* @bug 8017191 8182765 8200432 8239804 8250766 8262992 8281944
* @bug 8017191 8182765 8200432 8239804 8250766 8262992 8281944 8307377
* @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -102,11 +102,11 @@ public class TestSeeTag extends JavadocTester {
<dl class="notes">
<dt>See Also:</dt>
<dd>
<ul class="tag-list">
<ul class="tag-list-long">
<li><code>Object</code></li>
<li>
<details class="invalid-tag">
<summary>invalid @see</summary>
<summary>invalid reference</summary>
<pre><code>Foo&lt;String&gt;</code></pre>
</details>
</li>