8220217: Javadoc missing link to member method
Reviewed-by: jjg
This commit is contained in:
parent
c1474ca64b
commit
bb09c0c1d8
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Doclets provide the user-selectable backends for processing the
|
* Doclets provide the user-selectable backends for processing the
|
||||||
* documentation comnments in Java source code.
|
* documentation comments in Java source code.
|
||||||
*
|
*
|
||||||
* <p>Doclets are implementations of the {@link jdk.javadoc.doclet Doclet API}.</p>
|
* <p>Doclets are implementations of the {@link jdk.javadoc.doclet Doclet API}.</p>
|
||||||
*
|
*
|
||||||
|
@ -320,7 +320,7 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
|
|||||||
//necessary.
|
//necessary.
|
||||||
DocFinder.Output inheritedDoc =
|
DocFinder.Output inheritedDoc =
|
||||||
DocFinder.search(configuration,
|
DocFinder.search(configuration,
|
||||||
new DocFinder.Input(utils, (ExecutableElement) member));
|
new DocFinder.Input(utils, member));
|
||||||
if (inheritedDoc.holder != null
|
if (inheritedDoc.holder != null
|
||||||
&& !utils.getFirstSentenceTrees(inheritedDoc.holder).isEmpty()) {
|
&& !utils.getFirstSentenceTrees(inheritedDoc.holder).isEmpty()) {
|
||||||
// let the comment helper know of the overridden element
|
// let the comment helper know of the overridden element
|
||||||
@ -473,7 +473,7 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
|
|||||||
private void addSummaryFootNote(TypeElement inheritedClass, SortedSet<Element> inheritedMembers,
|
private void addSummaryFootNote(TypeElement inheritedClass, SortedSet<Element> inheritedMembers,
|
||||||
Content linksTree, MemberSummaryWriter writer) {
|
Content linksTree, MemberSummaryWriter writer) {
|
||||||
for (Element member : inheritedMembers) {
|
for (Element member : inheritedMembers) {
|
||||||
TypeElement t = (utils.isPackagePrivate(inheritedClass) && !utils.isLinkable(inheritedClass))
|
TypeElement t = utils.isUndocumentedEnclosure(inheritedClass)
|
||||||
? typeElement : inheritedClass;
|
? typeElement : inheritedClass;
|
||||||
writer.addInheritedMemberSummary(t, member, inheritedMembers.first() == member,
|
writer.addInheritedMemberSummary(t, member, inheritedMembers.first() == member,
|
||||||
inheritedMembers.last() == member, linksTree);
|
inheritedMembers.last() == member, linksTree);
|
||||||
|
@ -529,6 +529,10 @@ public class Utils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUndocumentedEnclosure(TypeElement enclosingTypeElement) {
|
||||||
|
return isPackagePrivate(enclosingTypeElement) && !isLinkable(enclosingTypeElement);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isError(TypeElement te) {
|
public boolean isError(TypeElement te) {
|
||||||
if (isEnum(te) || isInterface(te) || isAnnotationType(te)) {
|
if (isEnum(te) || isInterface(te) || isAnnotationType(te)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1064,8 +1068,7 @@ public class Utils {
|
|||||||
|
|
||||||
// Allow for the behavior that members of undocumented supertypes
|
// Allow for the behavior that members of undocumented supertypes
|
||||||
// may be included in documented types
|
// may be included in documented types
|
||||||
TypeElement enclElem = getEnclosingTypeElement(elem);
|
if (isUndocumentedEnclosure(getEnclosingTypeElement(elem))) {
|
||||||
if (typeElem != enclElem && isSubclassOf(typeElem, enclElem)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ public class VisibleMemberTable {
|
|||||||
public List<? extends Element> getVisibleMembers(Kind kind) {
|
public List<? extends Element> getVisibleMembers(Kind kind) {
|
||||||
Predicate<Element> declaredAndLeafMembers = e -> {
|
Predicate<Element> declaredAndLeafMembers = e -> {
|
||||||
TypeElement encl = utils.getEnclosingTypeElement(e);
|
TypeElement encl = utils.getEnclosingTypeElement(e);
|
||||||
return encl == te || isUndocumentedEnclosure(encl);
|
return encl == te || utils.isUndocumentedEnclosure(encl);
|
||||||
};
|
};
|
||||||
return getVisibleMembers(kind, declaredAndLeafMembers);
|
return getVisibleMembers(kind, declaredAndLeafMembers);
|
||||||
}
|
}
|
||||||
@ -238,7 +238,8 @@ public class VisibleMemberTable {
|
|||||||
ensureInitialized();
|
ensureInitialized();
|
||||||
|
|
||||||
OverridingMethodInfo found = overriddenMethodTable.get(e);
|
OverridingMethodInfo found = overriddenMethodTable.get(e);
|
||||||
if (found != null && (found.simpleOverride || isUndocumentedEnclosure(utils.getEnclosingTypeElement(e)))) {
|
if (found != null
|
||||||
|
&& (found.simpleOverride || utils.isUndocumentedEnclosure(utils.getEnclosingTypeElement(e)))) {
|
||||||
return found.overrider;
|
return found.overrider;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -347,10 +348,6 @@ public class VisibleMemberTable {
|
|||||||
return pm == null ? null : pm.setter;
|
return pm == null ? null : pm.setter;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isUndocumentedEnclosure(TypeElement encl) {
|
|
||||||
return utils.isPackagePrivate(encl) && !utils.isLinkable(encl);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void computeParents() {
|
private void computeParents() {
|
||||||
for (TypeMirror intfType : te.getInterfaces()) {
|
for (TypeMirror intfType : te.getInterfaces()) {
|
||||||
TypeElement intfc = utils.asTypeElement(intfType);
|
TypeElement intfc = utils.asTypeElement(intfType);
|
||||||
@ -388,7 +385,7 @@ public class VisibleMemberTable {
|
|||||||
|
|
||||||
private void computeLeafMembers(LocalMemberTable lmt, Kind kind) {
|
private void computeLeafMembers(LocalMemberTable lmt, Kind kind) {
|
||||||
List<Element> list = new ArrayList<>();
|
List<Element> list = new ArrayList<>();
|
||||||
if (isUndocumentedEnclosure(te)) {
|
if (utils.isUndocumentedEnclosure(te)) {
|
||||||
list.addAll(lmt.getOrderedMembers(kind));
|
list.addAll(lmt.getOrderedMembers(kind));
|
||||||
}
|
}
|
||||||
parents.forEach(pvmt -> {
|
parents.forEach(pvmt -> {
|
||||||
@ -617,7 +614,7 @@ public class VisibleMemberTable {
|
|||||||
|
|
||||||
// Disallow package-private super methods to leak in
|
// Disallow package-private super methods to leak in
|
||||||
TypeElement encl = utils.getEnclosingTypeElement(inheritedMethod);
|
TypeElement encl = utils.getEnclosingTypeElement(inheritedMethod);
|
||||||
if (isUndocumentedEnclosure(encl)) {
|
if (utils.isUndocumentedEnclosure(encl)) {
|
||||||
overriddenMethodTable.computeIfAbsent(lMethod,
|
overriddenMethodTable.computeIfAbsent(lMethod,
|
||||||
l -> new OverridingMethodInfo(inheritedMethod, false));
|
l -> new OverridingMethodInfo(inheritedMethod, false));
|
||||||
return false;
|
return false;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200
|
* @bug 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200
|
||||||
* 8192850 8182765
|
* 8192850 8182765 8220217
|
||||||
* @summary Test to make sure that members are inherited properly in the Javadoc.
|
* @summary Test to make sure that members are inherited properly in the Javadoc.
|
||||||
* Verify that inheritance labels are correct.
|
* Verify that inheritance labels are correct.
|
||||||
* @author jamieh
|
* @author jamieh
|
||||||
@ -47,7 +47,7 @@ public class TestMemberInheritance extends JavadocTester {
|
|||||||
public void test() {
|
public void test() {
|
||||||
javadoc("-d", "out",
|
javadoc("-d", "out",
|
||||||
"-sourcepath", testSrc,
|
"-sourcepath", testSrc,
|
||||||
"pkg", "diamond", "inheritDist", "pkg1");
|
"pkg", "diamond", "inheritDist", "pkg1", "pkg2");
|
||||||
checkExit(Exit.OK);
|
checkExit(Exit.OK);
|
||||||
|
|
||||||
checkOutput("pkg/SubClass.html", true,
|
checkOutput("pkg/SubClass.html", true,
|
||||||
@ -104,5 +104,27 @@ public class TestMemberInheritance extends JavadocTester {
|
|||||||
+ "<code><a href=\"Interface.html#between(java.time.chrono.ChronoLocalDate"
|
+ "<code><a href=\"Interface.html#between(java.time.chrono.ChronoLocalDate"
|
||||||
+ ",java.time.chrono.ChronoLocalDate)\">between</a></code>"
|
+ ",java.time.chrono.ChronoLocalDate)\">between</a></code>"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
checkOutput("pkg2/DocumentedNonGenericChild.html", true,
|
||||||
|
"<section class=\"description\">\n<hr>\n"
|
||||||
|
+ "<pre>public abstract class <span class=\"typeNameLabel\">"
|
||||||
|
+ "DocumentedNonGenericChild</span>\n"
|
||||||
|
+ "extends java.lang.Object</pre>\n"
|
||||||
|
+ "</section>");
|
||||||
|
|
||||||
|
checkOutput("pkg2/DocumentedNonGenericChild.html", true,
|
||||||
|
"<td class=\"colFirst\"><code>protected abstract java.lang.String</code></td>\n"
|
||||||
|
+ "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
|
||||||
|
+ "<a href=\"#parentMethod()\">parentMethod</a></span>()</code></th>\n"
|
||||||
|
+ "<td class=\"colLast\">\n"
|
||||||
|
+ "<div class=\"block\">Returns some value.</div>\n"
|
||||||
|
+ "</td>\n");
|
||||||
|
|
||||||
|
checkOutput("pkg2/DocumentedNonGenericChild.html", true,
|
||||||
|
"<h3><a id=\"parentMethod()\">parentMethod</a></h3>\n"
|
||||||
|
+ "<div class=\"memberSignature\"><span class=\"modifiers\">protected abstract</span>"
|
||||||
|
+ " <span class=\"returnType\">java.lang.String</span> "
|
||||||
|
+ "<span class=\"memberName\">parentMethod</span>()</div>");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pkg2;
|
||||||
|
|
||||||
|
public abstract class DocumentedNonGenericChild extends UndocumentedGenericParent<String> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pkg2;
|
||||||
|
|
||||||
|
abstract class UndocumentedGenericParent<T> {
|
||||||
|
/**
|
||||||
|
* Returns some value.
|
||||||
|
*
|
||||||
|
* @return some value
|
||||||
|
*/
|
||||||
|
protected abstract String parentMethod();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user