8187288: bad (no) wrapping for modifier and type column

Reviewed-by: jjg
This commit is contained in:
Priya Lakshmi Muthuswamy 2018-06-27 12:56:21 +05:30
parent aaf546777f
commit 6dca162699
7 changed files with 77 additions and 72 deletions

View File

@ -25,11 +25,13 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
@ -131,6 +133,52 @@ public class LinkFactoryImpl extends LinkFactory {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
protected Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel){
Content links = newContent();
List<TypeMirror> vars = new ArrayList<>();
TypeMirror ctype = linkInfo.type != null
? utils.getComponentType(linkInfo.type)
: null;
if (linkInfo.executableElement != null) {
linkInfo.executableElement.getTypeParameters().stream().forEach((t) -> {
vars.add(t.asType());
});
} else if (linkInfo.type != null && utils.isDeclaredType(linkInfo.type)) {
((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach(vars::add);
} else if (ctype != null && utils.isDeclaredType(ctype)) {
((DeclaredType)ctype).getTypeArguments().stream().forEach(vars::add);
} else if (linkInfo.typeElement != null) {
linkInfo.typeElement.getTypeParameters().stream().forEach((t) -> {
vars.add(t.asType());
});
} else {
// Nothing to document.
return links;
}
if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel)
|| (linkInfo.includeTypeAsSepLink && !isClassLabel)) && !vars.isEmpty()) {
links.addContent("<");
boolean many = false;
for (TypeMirror t : vars) {
if (many) {
links.addContent(",");
links.addContent(Contents.ZERO_WIDTH_SPACE);
}
links.addContent(getTypeParameterLink(linkInfo, t));
many = true;
}
links.addContent(">");
}
return links;
}
/**
* Returns a link to the given type parameter.
*
* @param linkInfo the information about the link to construct
* @param typeParam the type parameter to link to
* @return the link
*/
protected Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam) { protected Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam) {
LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration, LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
((LinkInfoImpl) linkInfo).getContext(), typeParam); ((LinkInfoImpl) linkInfo).getContext(), typeParam);

View File

@ -566,7 +566,6 @@ th.colFirst, th.colSecond, th.colLast, th.colConstructorName, th.colDeprecatedIt
padding:8px 3px 3px 7px; padding:8px 3px 3px 7px;
} }
td.colFirst, th.colFirst { td.colFirst, th.colFirst {
white-space:nowrap;
font-size:13px; font-size:13px;
} }
td.colSecond, th.colSecond, td.colLast, th.colConstructorName, th.colDeprecatedItemName, th.colLast { td.colSecond, th.colSecond, td.colLast, th.colConstructorName, th.colDeprecatedItemName, th.colLast {
@ -823,6 +822,9 @@ ul.ui-autocomplete li {
margin: -100px 0 0 100px; margin: -100px 0 0 100px;
z-index: 1; z-index: 1;
} }
.details pre {
white-space:normal;
}
/* /*
* Styles for user-provided tables. * Styles for user-provided tables.

View File

@ -25,7 +25,6 @@
package jdk.javadoc.internal.doclets.toolkit.util.links; package jdk.javadoc.internal.doclets.toolkit.util.links;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
@ -218,13 +217,14 @@ public abstract class LinkFactory {
protected abstract Content getClassLink(LinkInfo linkInfo); protected abstract Content getClassLink(LinkInfo linkInfo);
/** /**
* Returns a link to the given type parameter. * Returns links to the type parameters.
* *
* @param linkInfo the information about the link to construct * @param linkInfo the information about the link to construct
* @param typeParam the type parameter to link to * @param isClassLabel true if this is a class label, or false if it is
* @return the link * the type parameters portion of the link
* @return the links to the type parameters
*/ */
protected abstract Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam); protected abstract Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel);
/** /**
* Returns links to the type parameters. * Returns links to the type parameters.
@ -236,51 +236,5 @@ public abstract class LinkFactory {
return getTypeParameterLinks(linkInfo, true); return getTypeParameterLinks(linkInfo, true);
} }
/**
* Returns links to the type parameters.
*
* @param linkInfo the information about the link to construct
* @param isClassLabel true if this is a class label, or false if it is
* the type parameters portion of the link
* @return the links to the type parameters
*/
public Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
Content links = newContent();
List<TypeMirror> vars = new ArrayList<>();
TypeMirror ctype = linkInfo.type != null
? utils.getComponentType(linkInfo.type)
: null;
if (linkInfo.executableElement != null) {
linkInfo.executableElement.getTypeParameters().stream().forEach((t) -> {
vars.add(t.asType());
});
} else if (linkInfo.type != null && utils.isDeclaredType(linkInfo.type)) {
((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach(vars::add);
} else if (ctype != null && utils.isDeclaredType(ctype)) {
((DeclaredType)ctype).getTypeArguments().stream().forEach(vars::add);
} else if (linkInfo.typeElement != null) {
linkInfo.typeElement.getTypeParameters().stream().forEach((t) -> {
vars.add(t.asType());
});
} else {
// Nothing to document.
return links;
}
if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel)
|| (linkInfo.includeTypeAsSepLink && !isClassLabel)) && !vars.isEmpty()) {
links.addContent("<");
boolean many = false;
for (TypeMirror t : vars) {
if (many) {
links.addContent(",");
}
links.addContent(getTypeParameterLink(linkInfo, t));
many = true;
}
links.addContent(">");
}
return links;
}
public abstract Content getTypeAnnotationLinks(LinkInfo linkInfo); public abstract Content getTypeAnnotationLinks(LinkInfo linkInfo);
} }

View File

@ -24,7 +24,7 @@
/* /*
* @test * @test
* @bug 4682448 4947464 5029946 8025633 8026567 8035473 8139101 8175200 * @bug 4682448 4947464 5029946 8025633 8026567 8035473 8139101 8175200
8186332 8186703 8182765 8186332 8186703 8182765 8187288
* @summary Verify that the public modifier does not show up in the * @summary Verify that the public modifier does not show up in the
* documentation for public methods, as recommended by the JLS. * documentation for public methods, as recommended by the JLS.
* If A implements I and B extends A, B should be in the list of * If A implements I and B extends A, B should be in the list of
@ -249,14 +249,14 @@ public class TestInterface extends JavadocTester {
+ "<a href=\"Spliterator.OfInt.html\" title=\"type parameter in Spliterator.OfInt\">" + "<a href=\"Spliterator.OfInt.html\" title=\"type parameter in Spliterator.OfInt\">"
+ "Integer</a>&gt;, <a href=\"Spliterator.OfPrimitive.html\" title=\"interface in pkg2\">" + "Integer</a>&gt;, <a href=\"Spliterator.OfPrimitive.html\" title=\"interface in pkg2\">"
+ "Spliterator.OfPrimitive</a>&lt;<a href=\"Spliterator.OfPrimitive.html\" " + "Spliterator.OfPrimitive</a>&lt;<a href=\"Spliterator.OfPrimitive.html\" "
+ "title=\"type parameter in Spliterator.OfPrimitive\">T</a>,<a href=\"Spliterator.OfPrimitive.html\" " + "title=\"type parameter in Spliterator.OfPrimitive\">T</a>,&#8203;<a href=\"Spliterator.OfPrimitive.html\" "
+ "title=\"type parameter in Spliterator.OfPrimitive\">T_CONS</a>," + "title=\"type parameter in Spliterator.OfPrimitive\">T_CONS</a>,&#8203;"
+ "<a href=\"Spliterator.OfPrimitive.html\" title=\"type parameter in Spliterator.OfPrimitive\">" + "<a href=\"Spliterator.OfPrimitive.html\" title=\"type parameter in Spliterator.OfPrimitive\">"
+ "T_SPLITR</a> extends <a href=\"Spliterator.OfPrimitive.html\" title=\"interface in pkg2\">" + "T_SPLITR</a> extends <a href=\"Spliterator.OfPrimitive.html\" title=\"interface in pkg2\">"
+ "Spliterator.OfPrimitive</a>&lt;<a href=\"Spliterator.OfPrimitive.html\" " + "Spliterator.OfPrimitive</a>&lt;<a href=\"Spliterator.OfPrimitive.html\" "
+ "title=\"type parameter in Spliterator.OfPrimitive\">T</a>," + "title=\"type parameter in Spliterator.OfPrimitive\">T</a>,&#8203;"
+ "<a href=\"Spliterator.OfPrimitive.html\" title=\"type parameter in Spliterator.OfPrimitive\">" + "<a href=\"Spliterator.OfPrimitive.html\" title=\"type parameter in Spliterator.OfPrimitive\">"
+ "T_CONS</a>,<a href=\"Spliterator.OfPrimitive.html\" title=\"type parameter in Spliterator.OfPrimitive\">" + "T_CONS</a>,&#8203;<a href=\"Spliterator.OfPrimitive.html\" title=\"type parameter in Spliterator.OfPrimitive\">"
+ "T_SPLITR</a>&gt;&gt;</code>"); + "T_SPLITR</a>&gt;&gt;</code>");
} }
} }

View File

@ -24,7 +24,7 @@
/* /*
* @test * @test
* @bug 4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 8025633 8026567 8162363 * @bug 4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 8025633 8026567 8162363
* 8175200 8186332 8182765 8196202 * 8175200 8186332 8182765 8196202 8187288
* @summary Run Javadoc on a set of source files that demonstrate new * @summary Run Javadoc on a set of source files that demonstrate new
* language features. Check the output to ensure that the new * language features. Check the output to ensure that the new
* language features are properly documented. * language features are properly documented.
@ -146,7 +146,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
+ "<dd><code>V</code> - This is the second type " + "<dd><code>V</code> - This is the second type "
+ "parameter.", + "parameter.",
// Signature of method with type parameters // Signature of method with type parameters
"public&nbsp;&lt;T extends java.util.List,V&gt;&nbsp;" "public&nbsp;&lt;T extends java.util.List,&#8203;V&gt;&nbsp;"
+ "java.lang.String[]&nbsp;methodThatHasTypeParameters", + "java.lang.String[]&nbsp;methodThatHasTypeParameters",
// Method that returns TypeParameters // Method that returns TypeParameters
"<td class=\"colFirst\"><code><a href=\"TypeParameters.html\" " "<td class=\"colFirst\"><code><a href=\"TypeParameters.html\" "

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @bug 8005091 8009686 8025633 8026567 6469562 8071982 8071984 8162363 8175200 8186332 8182765 * @bug 8005091 8009686 8025633 8026567 6469562 8071982 8071984 8162363 8175200 8186332 8182765
* 8187288
* @summary Make sure that type annotations are displayed correctly * @summary Make sure that type annotations are displayed correctly
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib * @library ../lib
@ -89,7 +90,7 @@ public class TestTypeAnnotations extends JavadocTester {
checkOutput("typeannos/TwoBounds.html", true, checkOutput("typeannos/TwoBounds.html", true,
"<pre>class <span class=\"typeNameLabel\">TwoBounds&lt;K extends <a href=\"" "<pre>class <span class=\"typeNameLabel\">TwoBounds&lt;K extends <a href=\""
+ "ClassParamA.html\" title=\"annotation in typeannos\">" + "ClassParamA.html\" title=\"annotation in typeannos\">"
+ "@ClassParamA</a> java.lang.String,V extends <a href=\"" + "@ClassParamA</a> java.lang.String,&#8203;V extends <a href=\""
+ "ClassParamB.html\" title=\"annotation in typeannos\">@ClassParamB" + "ClassParamB.html\" title=\"annotation in typeannos\">@ClassParamB"
+ "</a> java.lang.String&gt;</span>"); + "</a> java.lang.String&gt;</span>");
@ -114,7 +115,7 @@ public class TestTypeAnnotations extends JavadocTester {
checkOutput("typeannos/DefaultScope.html", true, checkOutput("typeannos/DefaultScope.html", true,
"<pre><a href=\"Parameterized.html\" title=\"class in " "<pre><a href=\"Parameterized.html\" title=\"class in "
+ "typeannos\">Parameterized</a>&lt;<a href=\"FldA.html\" " + "typeannos\">Parameterized</a>&lt;<a href=\"FldA.html\" "
+ "title=\"annotation in typeannos\">@FldA</a> java.lang.String,<a " + "title=\"annotation in typeannos\">@FldA</a> java.lang.String,&#8203;<a "
+ "href=\"FldB.html\" title=\"annotation in typeannos\">" + "href=\"FldB.html\" title=\"annotation in typeannos\">"
+ "@FldB</a> java.lang.String&gt; bothTypeArgs</pre>", + "@FldB</a> java.lang.String&gt; bothTypeArgs</pre>",
@ -141,9 +142,9 @@ public class TestTypeAnnotations extends JavadocTester {
+ "FldA.html\" title=\"annotation in typeannos\">@FldA</a> " + "FldA.html\" title=\"annotation in typeannos\">@FldA</a> "
+ "<a href=\"Parameterized.html\" title=\"class in " + "<a href=\"Parameterized.html\" title=\"class in "
+ "typeannos\">Parameterized</a>&lt;<a href=\"FldA.html\" " + "typeannos\">Parameterized</a>&lt;<a href=\"FldA.html\" "
+ "title=\"annotation in typeannos\">@FldA</a> java.lang.String,<a " + "title=\"annotation in typeannos\">@FldA</a> java.lang.String,&#8203;<a "
+ "href=\"FldB.html\" title=\"annotation in typeannos\">" + "href=\"FldB.html\" title=\"annotation in typeannos\">"
+ "@FldB</a> java.lang.String&gt;,<a href=\"FldB.html\" " + "@FldB</a> java.lang.String&gt;,&#8203;<a href=\"FldB.html\" "
+ "title=\"annotation in typeannos\">@FldB</a> java.lang.String&gt; " + "title=\"annotation in typeannos\">@FldB</a> java.lang.String&gt; "
+ "nestedParameterized</pre>", + "nestedParameterized</pre>",
@ -174,8 +175,8 @@ public class TestTypeAnnotations extends JavadocTester {
+ "<a href=\"MtdParameterized.html\" title=\"class in " + "<a href=\"MtdParameterized.html\" title=\"class in "
+ "typeannos\">MtdParameterized</a>&lt;<a href=\"MRtnA." + "typeannos\">MtdParameterized</a>&lt;<a href=\"MRtnA."
+ "html\" title=\"annotation in typeannos\">@MRtnA</a> java.lang." + "html\" title=\"annotation in typeannos\">@MRtnA</a> java.lang."
+ "String,<a href=\"MRtnB.html\" title=\"annotation in " + "String,&#8203;<a href=\"MRtnB.html\" title=\"annotation in "
+ "typeannos\">@MRtnB</a> java.lang.String&gt;,<a href=\"" + "typeannos\">@MRtnB</a> java.lang.String&gt;,&#8203;<a href=\""
+ "MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> java." + "MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> java."
+ "lang.String&gt;&nbsp;nestedMtdParameterized()</pre>"); + "lang.String&gt;&nbsp;nestedMtdParameterized()</pre>");
@ -199,7 +200,7 @@ public class TestTypeAnnotations extends JavadocTester {
"<pre>public final&nbsp;&lt;K extends <a href=\"" "<pre>public final&nbsp;&lt;K extends <a href=\""
+ "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " + "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> "
+ "java.lang.String,V extends <a href=\"MTyParamA.html\" " + "java.lang.String,&#8203;V extends <a href=\"MTyParamA.html\" "
+ "title=\"annotation in typeannos\">@MTyParamA</a> <a href=\"" + "title=\"annotation in typeannos\">@MTyParamA</a> <a href=\""
+ "MtdTyParameterized.html\" title=\"class in typeannos\">" + "MtdTyParameterized.html\" title=\"class in typeannos\">"
+ "MtdTyParameterized</a>&lt;<a href=\"MTyParamB.html\" " + "MtdTyParameterized</a>&lt;<a href=\"MTyParamB.html\" "
@ -210,7 +211,7 @@ public class TestTypeAnnotations extends JavadocTester {
checkOutput("typeannos/Parameters.html", true, checkOutput("typeannos/Parameters.html", true,
"<pre>void&nbsp;unannotated&#8203;(<a href=\"" "<pre>void&nbsp;unannotated&#8203;(<a href=\""
+ "ParaParameterized.html\" title=\"class in typeannos\">" + "ParaParameterized.html\" title=\"class in typeannos\">"
+ "ParaParameterized</a>&lt;java.lang.String,java.lang.String&gt;" + "ParaParameterized</a>&lt;java.lang.String,&#8203;java.lang.String&gt;"
+ "&nbsp;a)</pre>", + "&nbsp;a)</pre>",
"<pre>void&nbsp;nestedParaParameterized&#8203;(<a href=\"" "<pre>void&nbsp;nestedParaParameterized&#8203;(<a href=\""
@ -219,9 +220,9 @@ public class TestTypeAnnotations extends JavadocTester {
+ "title=\"annotation in typeannos\">@ParamA</a> <a href=\"" + "title=\"annotation in typeannos\">@ParamA</a> <a href=\""
+ "ParaParameterized.html\" title=\"class in typeannos\">" + "ParaParameterized.html\" title=\"class in typeannos\">"
+ "ParaParameterized</a>&lt;<a href=\"ParamA.html\" " + "ParaParameterized</a>&lt;<a href=\"ParamA.html\" "
+ "title=\"annotation in typeannos\">@ParamA</a> java.lang.String," + "title=\"annotation in typeannos\">@ParamA</a> java.lang.String,&#8203;"
+ "<a href=\"ParamB.html\" title=\"annotation in " + "<a href=\"ParamB.html\" title=\"annotation in "
+ "typeannos\">@ParamB</a> java.lang.String&gt;,<a href=\"" + "typeannos\">@ParamB</a> java.lang.String&gt;,&#8203;<a href=\""
+ "ParamB.html\" title=\"annotation in typeannos\">@ParamB" + "ParamB.html\" title=\"annotation in typeannos\">@ParamB"
+ "</a> java.lang.String&gt;&nbsp;a)</pre>", + "</a> java.lang.String&gt;&nbsp;a)</pre>",
@ -272,7 +273,7 @@ public class TestTypeAnnotations extends JavadocTester {
// Test for type annotations on type parameters (TypeParameters.java). // Test for type annotations on type parameters (TypeParameters.java).
checkOutput("typeannos/TestMethods.html", true, checkOutput("typeannos/TestMethods.html", true,
"<pre>&lt;K,<a href=\"TyParaA.html\" title=\"annotation in typeannos\">" "<pre>&lt;K,&#8203;<a href=\"TyParaA.html\" title=\"annotation in typeannos\">"
+ "@TyParaA</a> V extends <a href=\"TyParaA.html\" " + "@TyParaA</a> V extends <a href=\"TyParaA.html\" "
+ "title=\"annotation in typeannos\">@TyParaA</a> " + "title=\"annotation in typeannos\">@TyParaA</a> "
+ "java.lang.String&gt;&nbsp;void&nbsp;secondAnnotated()</pre>" + "java.lang.String&gt;&nbsp;void&nbsp;secondAnnotated()</pre>"

View File

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4927167 4974929 7010344 8025633 8081854 8182765 * @bug 4927167 4974929 7010344 8025633 8081854 8182765 8187288
* @summary When the type parameters are more than 10 characters in length, * @summary When the type parameters are more than 10 characters in length,
* make sure there is a line break between type params and return type * make sure there is a line break between type params and return type
* in member summary. Also, test for type parameter links in package-summary and * in member summary. Also, test for type parameter links in package-summary and
@ -52,7 +52,7 @@ public class TestTypeParameters extends JavadocTester {
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("pkg/C.html", true, checkOutput("pkg/C.html", true,
"<td class=\"colFirst\"><code>&lt;W extends java.lang.String,V extends " "<td class=\"colFirst\"><code>&lt;W extends java.lang.String,&#8203;V extends "
+ "java.util.List&gt;<br>java.lang.Object</code></td>", + "java.util.List&gt;<br>java.lang.Object</code></td>",
"<code>&lt;T&gt;&nbsp;java.lang.Object</code>"); "<code>&lt;T&gt;&nbsp;java.lang.Object</code>");