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;
import java.util.ArrayList;
import java.util.List;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
@ -131,6 +133,52 @@ public class LinkFactoryImpl extends LinkFactory {
* {@inheritDoc}
*/
@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) {
LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
((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;
}
td.colFirst, th.colFirst {
white-space:nowrap;
font-size:13px;
}
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;
z-index: 1;
}
.details pre {
white-space:normal;
}
/*
* Styles for user-provided tables.

View file

@ -25,7 +25,6 @@
package jdk.javadoc.internal.doclets.toolkit.util.links;
import java.util.ArrayList;
import java.util.List;
import javax.lang.model.element.Element;
@ -218,13 +217,14 @@ public abstract class LinkFactory {
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 typeParam the type parameter to link to
* @return the link
* @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
*/
protected abstract Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam);
protected abstract Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel);
/**
* Returns links to the type parameters.
@ -236,51 +236,5 @@ public abstract class LinkFactory {
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);
}