8220217: Javadoc missing link to member method

Reviewed-by: jjg
This commit is contained in:
Hannes Wallnöfer 2019-10-07 15:58:04 +02:00
parent c1474ca64b
commit bb09c0c1d8
7 changed files with 98 additions and 15 deletions

View File

@ -25,7 +25,7 @@
/**
* 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>
*

View File

@ -320,7 +320,7 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
//necessary.
DocFinder.Output inheritedDoc =
DocFinder.search(configuration,
new DocFinder.Input(utils, (ExecutableElement) member));
new DocFinder.Input(utils, member));
if (inheritedDoc.holder != null
&& !utils.getFirstSentenceTrees(inheritedDoc.holder).isEmpty()) {
// 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,
Content linksTree, MemberSummaryWriter writer) {
for (Element member : inheritedMembers) {
TypeElement t = (utils.isPackagePrivate(inheritedClass) && !utils.isLinkable(inheritedClass))
TypeElement t = utils.isUndocumentedEnclosure(inheritedClass)
? typeElement : inheritedClass;
writer.addInheritedMemberSummary(t, member, inheritedMembers.first() == member,
inheritedMembers.last() == member, linksTree);

View File

@ -529,6 +529,10 @@ public class Utils {
return true;
}
public boolean isUndocumentedEnclosure(TypeElement enclosingTypeElement) {
return isPackagePrivate(enclosingTypeElement) && !isLinkable(enclosingTypeElement);
}
public boolean isError(TypeElement te) {
if (isEnum(te) || isInterface(te) || isAnnotationType(te)) {
return false;
@ -1064,8 +1068,7 @@ public class Utils {
// Allow for the behavior that members of undocumented supertypes
// may be included in documented types
TypeElement enclElem = getEnclosingTypeElement(elem);
if (typeElem != enclElem && isSubclassOf(typeElem, enclElem)) {
if (isUndocumentedEnclosure(getEnclosingTypeElement(elem))) {
return true;
}

View File

@ -209,7 +209,7 @@ public class VisibleMemberTable {
public List<? extends Element> getVisibleMembers(Kind kind) {
Predicate<Element> declaredAndLeafMembers = e -> {
TypeElement encl = utils.getEnclosingTypeElement(e);
return encl == te || isUndocumentedEnclosure(encl);
return encl == te || utils.isUndocumentedEnclosure(encl);
};
return getVisibleMembers(kind, declaredAndLeafMembers);
}
@ -238,7 +238,8 @@ public class VisibleMemberTable {
ensureInitialized();
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 null;
@ -347,10 +348,6 @@ public class VisibleMemberTable {
return pm == null ? null : pm.setter;
}
boolean isUndocumentedEnclosure(TypeElement encl) {
return utils.isPackagePrivate(encl) && !utils.isLinkable(encl);
}
private void computeParents() {
for (TypeMirror intfType : te.getInterfaces()) {
TypeElement intfc = utils.asTypeElement(intfType);
@ -388,7 +385,7 @@ public class VisibleMemberTable {
private void computeLeafMembers(LocalMemberTable lmt, Kind kind) {
List<Element> list = new ArrayList<>();
if (isUndocumentedEnclosure(te)) {
if (utils.isUndocumentedEnclosure(te)) {
list.addAll(lmt.getOrderedMembers(kind));
}
parents.forEach(pvmt -> {
@ -617,7 +614,7 @@ public class VisibleMemberTable {
// Disallow package-private super methods to leak in
TypeElement encl = utils.getEnclosingTypeElement(inheritedMethod);
if (isUndocumentedEnclosure(encl)) {
if (utils.isUndocumentedEnclosure(encl)) {
overriddenMethodTable.computeIfAbsent(lMethod,
l -> new OverridingMethodInfo(inheritedMethod, false));
return false;

View File

@ -24,7 +24,7 @@
/*
* @test
* @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.
* Verify that inheritance labels are correct.
* @author jamieh
@ -47,7 +47,7 @@ public class TestMemberInheritance extends JavadocTester {
public void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg", "diamond", "inheritDist", "pkg1");
"pkg", "diamond", "inheritDist", "pkg1", "pkg2");
checkExit(Exit.OK);
checkOutput("pkg/SubClass.html", true,
@ -104,5 +104,27 @@ public class TestMemberInheritance extends JavadocTester {
+ "<code><a href=\"Interface.html#between(java.time.chrono.ChronoLocalDate"
+ ",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>"
+ "&nbsp;<span class=\"returnType\">java.lang.String</span>&nbsp;"
+ "<span class=\"memberName\">parentMethod</span>()</div>");
}
}

View File

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

View File

@ -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();
}