src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2015, 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. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2016, 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. Oracle designates this
*** 21,87 ****
* 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 com.sun.tools.doclets.formats.html;
import java.util.*;
! import com.sun.javadoc.*;
! import com.sun.tools.javac.jvm.Profile;
! import com.sun.tools.javadoc.RootDocImpl;
! import com.sun.tools.doclets.formats.html.markup.*;
! import com.sun.tools.doclets.internal.toolkit.*;
! import com.sun.tools.doclets.internal.toolkit.builders.*;
! import com.sun.tools.doclets.internal.toolkit.taglets.*;
! import com.sun.tools.doclets.internal.toolkit.util.*;
! import java.io.IOException;
/**
* Generate the Class Information Page.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*
! * @see com.sun.javadoc.ClassDoc
* @see java.util.Collections
* @see java.util.List
* @see java.util.ArrayList
* @see java.util.HashMap
*
* @author Atul M Dambalkar
* @author Robert Field
* @author Bhavesh Patel (Modified)
*/
! public class ClassWriterImpl extends SubWriterHolderWriter
! implements ClassWriter {
! protected final ClassDoc classDoc;
protected final ClassTree classtree;
! protected final ClassDoc prev;
! protected final ClassDoc next;
/**
* @param configuration the configuration data for the doclet
! * @param classDoc the class being documented.
* @param prevClass the previous class that was documented.
* @param nextClass the next class being documented.
* @param classTree the class tree for the given class.
*/
! public ClassWriterImpl (ConfigurationImpl configuration, ClassDoc classDoc,
! ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
throws IOException {
! super(configuration, DocPath.forClass(classDoc));
! this.classDoc = classDoc;
! configuration.currentcd = classDoc;
this.classtree = classTree;
this.prev = prevClass;
this.next = nextClass;
}
--- 21,105 ----
* 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 jdk.javadoc.internal.doclets.formats.html;
+ import java.io.IOException;
import java.util.*;
! import javax.lang.model.element.AnnotationMirror;
! import javax.lang.model.element.Element;
! import javax.lang.model.element.PackageElement;
! import javax.lang.model.element.TypeElement;
! import javax.lang.model.type.TypeMirror;
! import javax.lang.model.util.SimpleElementVisitor8;
! import com.sun.source.doctree.DocTree;
! import com.sun.tools.javac.util.DefinedBy;
! import com.sun.tools.javac.util.DefinedBy.Api;
! import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
! import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
! import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
! import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
! import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
! import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
! import jdk.javadoc.internal.doclets.toolkit.Content;
! import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
! import jdk.javadoc.internal.doclets.toolkit.taglets.ParamTaglet;
! import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
! import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
! import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
! import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
! import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
! import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
! import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
! import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
/**
* Generate the Class Information Page.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*
! * @see javax.lang.model.element.TypeElement
* @see java.util.Collections
* @see java.util.List
* @see java.util.ArrayList
* @see java.util.HashMap
*
* @author Atul M Dambalkar
* @author Robert Field
* @author Bhavesh Patel (Modified)
*/
! public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter {
! protected final TypeElement typeElement;
protected final ClassTree classtree;
! protected final TypeElement prev;
! protected final TypeElement next;
/**
* @param configuration the configuration data for the doclet
! * @param typeElement the class being documented.
* @param prevClass the previous class that was documented.
* @param nextClass the next class being documented.
* @param classTree the class tree for the given class.
+ * @throws java.io.IOException
*/
! public ClassWriterImpl(ConfigurationImpl configuration, TypeElement typeElement,
! TypeElement prevClass, TypeElement nextClass, ClassTree classTree)
throws IOException {
! super(configuration, DocPath.forClass(configuration.utils, typeElement));
! this.typeElement = typeElement;
! configuration.currentTypeElement = typeElement;
this.classtree = classTree;
this.prev = prevClass;
this.next = nextClass;
}
*** 88,97 ****
--- 106,116 ----
/**
* Get this package link.
*
* @return a content tree for the package link
*/
+ @Override
protected Content getNavLinkPackage() {
Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
packageLabel);
Content li = HtmlTree.LI(linkContent);
return li;
*** 100,109 ****
--- 119,129 ----
/**
* Get the class link.
*
* @return a content tree for the class link
*/
+ @Override
protected Content getNavLinkClass() {
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
return li;
}
*** 110,119 ****
--- 130,140 ----
/**
* Get the class use link.
*
* @return a content tree for the class use link
*/
+ @Override
protected Content getNavLinkClassUse() {
Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
Content li = HtmlTree.LI(linkContent);
return li;
}
*** 121,130 ****
--- 142,152 ----
/**
* Get link to previous class.
*
* @return a content tree for the previous class link
*/
+ @Override
public Content getNavLinkPrevious() {
Content li;
if (prev != null) {
Content prevLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, prev)
*** 139,148 ****
--- 161,171 ----
/**
* Get link to next class.
*
* @return a content tree for the next class link
*/
+ @Override
public Content getNavLinkNext() {
Content li;
if (next != null) {
Content nextLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, next)
*** 155,169 ****
}
/**
* {@inheritDoc}
*/
public Content getHeader(String header) {
! String pkgname = (classDoc.containingPackage() != null)?
! classDoc.containingPackage().name(): "";
! String clname = classDoc.name();
! HtmlTree bodyTree = getBody(true, getWindowTitle(clname));
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
? HtmlTree.HEADER()
: bodyTree;
addTop(htmlTree);
addNavLinks(true, htmlTree);
--- 178,190 ----
}
/**
* {@inheritDoc}
*/
+ @Override
public Content getHeader(String header) {
! HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(typeElement)));
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
? HtmlTree.HEADER()
: bodyTree;
addTop(htmlTree);
addNavLinks(true, htmlTree);
*** 171,201 ****
bodyTree.addContent(htmlTree);
}
bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header);
! if (configuration.showProfiles) {
! String sep = "";
! int profile = configuration.profiles.getProfile(getTypeNameForProfile(classDoc));
! if (profile > 0) {
! Content profNameContent = new StringContent();
! for (int i = profile; i < configuration.profiles.getProfileCount(); i++) {
! profNameContent.addContent(sep);
! profNameContent.addContent(Profile.lookup(i).name);
! sep = ", ";
! }
! Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profNameContent);
! div.addContent(profileNameDiv);
! }
! }
! if (pkgname.length() > 0) {
! Content pkgNameContent = new StringContent(pkgname);
Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
div.addContent(pkgNameDiv);
}
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
! LinkInfoImpl.Kind.CLASS_HEADER, classDoc);
//Let's not link to ourselves in the header.
linkInfo.linkToSelf = false;
Content headerContent = new StringContent(header);
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
HtmlStyle.title, headerContent);
--- 192,209 ----
bodyTree.addContent(htmlTree);
}
bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header);
! PackageElement pkg = utils.containingPackage(typeElement);
! if (!pkg.isUnnamed()) {
! Content pkgNameContent = new StringContent(utils.getPackageName(pkg));
Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
div.addContent(pkgNameDiv);
}
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
! LinkInfoImpl.Kind.CLASS_HEADER, typeElement);
//Let's not link to ourselves in the header.
linkInfo.linkToSelf = false;
Content headerContent = new StringContent(header);
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
HtmlStyle.title, headerContent);
*** 210,226 ****
--- 218,236 ----
}
/**
* {@inheritDoc}
*/
+ @Override
public Content getClassContentHeader() {
return getContentHeader();
}
/**
* {@inheritDoc}
*/
+ @Override
public void addFooter(Content contentTree) {
contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
? HtmlTree.FOOTER()
: contentTree;
*** 232,370 ****
}
/**
* {@inheritDoc}
*/
public void printDocument(Content contentTree) throws IOException {
! printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc),
true, contentTree);
}
/**
* {@inheritDoc}
*/
public Content getClassInfoTreeHeader() {
return getMemberTreeHeader();
}
/**
* {@inheritDoc}
*/
public Content getClassInfo(Content classInfoTree) {
return getMemberTree(HtmlStyle.description, classInfoTree);
}
/**
* {@inheritDoc}
*/
public void addClassSignature(String modifiers, Content classInfoTree) {
- boolean isInterface = classDoc.isInterface();
classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
Content pre = new HtmlTree(HtmlTag.PRE);
! addAnnotationInfo(classDoc, pre);
pre.addContent(modifiers);
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
! LinkInfoImpl.Kind.CLASS_SIGNATURE, classDoc);
//Let's not link to ourselves in the signature.
linkInfo.linkToSelf = false;
! Content className = new StringContent(classDoc.name());
Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.linksource) {
! addSrcLink(classDoc, className, pre);
pre.addContent(parameterLinks);
} else {
Content span = HtmlTree.SPAN(HtmlStyle.typeNameLabel, className);
span.addContent(parameterLinks);
pre.addContent(span);
}
! if (!isInterface) {
! Type superclass = utils.getFirstVisibleSuperClass(classDoc,
! configuration);
if (superclass != null) {
pre.addContent(DocletConstants.NL);
pre.addContent("extends ");
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
superclass));
pre.addContent(link);
}
}
! Type[] implIntfacs = classDoc.interfaceTypes();
! if (implIntfacs != null && implIntfacs.length > 0) {
! int counter = 0;
! for (Type implType : implIntfacs) {
! ClassDoc classDoc = implType.asClassDoc();
! if (!(classDoc.isPublic() || utils.isLinkable(classDoc, configuration))) {
continue;
}
! if (counter == 0) {
pre.addContent(DocletConstants.NL);
! pre.addContent(isInterface ? "extends " : "implements ");
} else {
pre.addContent(", ");
}
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
! implType));
pre.addContent(link);
- counter++;
}
}
classInfoTree.addContent(pre);
}
/**
* {@inheritDoc}
*/
public void addClassDescription(Content classInfoTree) {
if(!configuration.nocomment) {
// generate documentation for the class.
! if (classDoc.inlineTags().length > 0) {
! addInlineComment(classDoc, classInfoTree);
}
}
}
/**
* {@inheritDoc}
*/
public void addClassTagInfo(Content classInfoTree) {
if(!configuration.nocomment) {
// Print Information about all the tags here
! addTagsInfo(classDoc, classInfoTree);
}
}
/**
* Get the class hierarchy tree for the given class.
*
* @param type the class to print the hierarchy for
* @return a content tree for class inheritence
*/
! private Content getClassInheritenceTree(Type type) {
! Type sup;
HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
classTreeUl.addStyle(HtmlStyle.inheritance);
Content liTree = null;
do {
! sup = utils.getFirstVisibleSuperClass(
! type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
! configuration);
if (sup != null) {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addStyle(HtmlStyle.inheritance);
ul.addContent(getTreeForClassHelper(type));
if (liTree != null)
ul.addContent(liTree);
Content li = HtmlTree.LI(ul);
liTree = li;
type = sup;
! }
! else
classTreeUl.addContent(getTreeForClassHelper(type));
! }
! while (sup != null);
if (liTree != null)
classTreeUl.addContent(liTree);
return classTreeUl;
}
--- 242,380 ----
}
/**
* {@inheritDoc}
*/
+ @Override
public void printDocument(Content contentTree) throws IOException {
! printHtmlDocument(configuration.metakeywords.getMetaKeywords(typeElement),
true, contentTree);
}
/**
* {@inheritDoc}
*/
+ @Override
public Content getClassInfoTreeHeader() {
return getMemberTreeHeader();
}
/**
* {@inheritDoc}
*/
+ @Override
public Content getClassInfo(Content classInfoTree) {
return getMemberTree(HtmlStyle.description, classInfoTree);
}
/**
* {@inheritDoc}
*/
+ @Override
public void addClassSignature(String modifiers, Content classInfoTree) {
classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
Content pre = new HtmlTree(HtmlTag.PRE);
! addAnnotationInfo(typeElement, pre);
pre.addContent(modifiers);
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
! LinkInfoImpl.Kind.CLASS_SIGNATURE, typeElement);
//Let's not link to ourselves in the signature.
linkInfo.linkToSelf = false;
! Content className = new StringContent(utils.getSimpleName(typeElement));
Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.linksource) {
! addSrcLink(typeElement, className, pre);
pre.addContent(parameterLinks);
} else {
Content span = HtmlTree.SPAN(HtmlStyle.typeNameLabel, className);
span.addContent(parameterLinks);
pre.addContent(span);
}
! if (!utils.isInterface(typeElement)) {
! TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement);
if (superclass != null) {
pre.addContent(DocletConstants.NL);
pre.addContent("extends ");
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
superclass));
pre.addContent(link);
}
}
! List<? extends TypeMirror> interfaces = typeElement.getInterfaces();
! if (!interfaces.isEmpty()) {
! boolean isFirst = true;
! for (TypeMirror type : interfaces) {
! TypeElement tDoc = utils.asTypeElement(type);
! if (!(utils.isPublic(tDoc) || utils.isLinkable(tDoc))) {
continue;
}
! if (isFirst) {
pre.addContent(DocletConstants.NL);
! pre.addContent(utils.isInterface(typeElement) ? "extends " : "implements ");
! isFirst = false;
} else {
pre.addContent(", ");
}
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
! type));
pre.addContent(link);
}
}
classInfoTree.addContent(pre);
}
/**
* {@inheritDoc}
*/
+ @Override
public void addClassDescription(Content classInfoTree) {
if(!configuration.nocomment) {
// generate documentation for the class.
! if (!utils.getBody(typeElement).isEmpty()) {
! addInlineComment(typeElement, classInfoTree);
}
}
}
/**
* {@inheritDoc}
*/
+ @Override
public void addClassTagInfo(Content classInfoTree) {
if(!configuration.nocomment) {
// Print Information about all the tags here
! addTagsInfo(typeElement, classInfoTree);
}
}
/**
* Get the class hierarchy tree for the given class.
*
* @param type the class to print the hierarchy for
* @return a content tree for class inheritence
*/
! private Content getClassInheritenceTree(TypeMirror type) {
! TypeMirror sup;
HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
classTreeUl.addStyle(HtmlStyle.inheritance);
Content liTree = null;
do {
! sup = utils.getFirstVisibleSuperClass(type);
if (sup != null) {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addStyle(HtmlStyle.inheritance);
ul.addContent(getTreeForClassHelper(type));
if (liTree != null)
ul.addContent(liTree);
Content li = HtmlTree.LI(ul);
liTree = li;
type = sup;
! } else
classTreeUl.addContent(getTreeForClassHelper(type));
! } while (sup != null);
if (liTree != null)
classTreeUl.addContent(liTree);
return classTreeUl;
}
*** 372,436 ****
* Get the class helper tree for the given class.
*
* @param type the class to print the helper for
* @return a content tree for class helper
*/
! private Content getTreeForClassHelper(Type type) {
Content li = new HtmlTree(HtmlTag.LI);
! if (type.equals(classDoc)) {
Content typeParameters = getTypeParameterLinks(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
! classDoc));
! if (configuration.shouldExcludeQualifier(
! classDoc.containingPackage().name())) {
! li.addContent(type.asClassDoc().name());
li.addContent(typeParameters);
} else {
! li.addContent(type.asClassDoc().qualifiedName());
li.addContent(typeParameters);
}
} else {
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
! .label(configuration.getClassName(type.asClassDoc())));
li.addContent(link);
}
return li;
}
/**
* {@inheritDoc}
*/
public void addClassTree(Content classContentTree) {
! if (!classDoc.isClass()) {
return;
}
! classContentTree.addContent(getClassInheritenceTree(classDoc));
}
/**
* {@inheritDoc}
*/
public void addTypeParamInfo(Content classInfoTree) {
! if (classDoc.typeParamTags().length > 0) {
! Content typeParam = (new ParamTaglet()).getTagletOutput(classDoc,
getTagletWriterInstance(false));
Content dl = HtmlTree.DL(typeParam);
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
public void addSubClassInfo(Content classInfoTree) {
! if (classDoc.isClass()) {
! if (classDoc.qualifiedName().equals("java.lang.Object") ||
! classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
return; // Don't generate the list, too huge
}
! SortedSet<ClassDoc> subclasses = classtree.subs(classDoc, false);
if (!subclasses.isEmpty()) {
Content label = getResource(
"doclet.Subclasses");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
--- 382,448 ----
* Get the class helper tree for the given class.
*
* @param type the class to print the helper for
* @return a content tree for class helper
*/
! private Content getTreeForClassHelper(TypeMirror type) {
Content li = new HtmlTree(HtmlTag.LI);
! if (type.equals(typeElement.asType())) {
Content typeParameters = getTypeParameterLinks(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
! typeElement));
! if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) {
! li.addContent(utils.asTypeElement(type).getSimpleName().toString());
li.addContent(typeParameters);
} else {
! li.addContent(utils.asTypeElement(type).getQualifiedName().toString());
li.addContent(typeParameters);
}
} else {
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
! .label(configuration.getClassName(utils.asTypeElement(type))));
li.addContent(link);
}
return li;
}
/**
* {@inheritDoc}
*/
+ @Override
public void addClassTree(Content classContentTree) {
! if (!utils.isClass(typeElement)) {
return;
}
! classContentTree.addContent(getClassInheritenceTree(typeElement.asType()));
}
/**
* {@inheritDoc}
*/
+ @Override
public void addTypeParamInfo(Content classInfoTree) {
! if (!utils.getTypeParamTrees(typeElement).isEmpty()) {
! Content typeParam = (new ParamTaglet()).getTagletOutput(typeElement,
getTagletWriterInstance(false));
Content dl = HtmlTree.DL(typeParam);
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
+ @Override
public void addSubClassInfo(Content classInfoTree) {
! if (utils.isClass(typeElement)) {
! if (typeElement.getQualifiedName().toString().equals("java.lang.Object") ||
! typeElement.getQualifiedName().toString().equals("org.omg.CORBA.Object")) {
return; // Don't generate the list, too huge
}
! Set<TypeElement> subclasses = classtree.directSubClasses(typeElement, false);
if (!subclasses.isEmpty()) {
Content label = getResource(
"doclet.Subclasses");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
*** 442,454 ****
}
/**
* {@inheritDoc}
*/
public void addSubInterfacesInfo(Content classInfoTree) {
! if (classDoc.isInterface()) {
! SortedSet<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false);
if (!subInterfaces.isEmpty()) {
Content label = getResource(
"doclet.Subinterfaces");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
--- 454,467 ----
}
/**
* {@inheritDoc}
*/
+ @Override
public void addSubInterfacesInfo(Content classInfoTree) {
! if (utils.isInterface(typeElement)) {
! Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
if (!subInterfaces.isEmpty()) {
Content label = getResource(
"doclet.Subinterfaces");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
*** 460,478 ****
}
/**
* {@inheritDoc}
*/
public void addInterfaceUsageInfo (Content classInfoTree) {
! if (! classDoc.isInterface()) {
return;
}
! if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
! classDoc.qualifiedName().equals("java.io.Serializable")) {
return; // Don't generate the list, too big
}
! SortedSet<ClassDoc> implcl = classtree.implementingclasses(classDoc);
if (!implcl.isEmpty()) {
Content label = getResource(
"doclet.Implementing_Classes");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
--- 473,492 ----
}
/**
* {@inheritDoc}
*/
+ @Override
public void addInterfaceUsageInfo (Content classInfoTree) {
! if (!utils.isInterface(typeElement)) {
return;
}
! if (typeElement.getQualifiedName().toString().equals("java.lang.Cloneable") ||
! typeElement.getQualifiedName().toString().equals("java.io.Serializable")) {
return; // Don't generate the list, too big
}
! Set<TypeElement> implcl = classtree.implementingclasses(typeElement);
if (!implcl.isEmpty()) {
Content label = getResource(
"doclet.Implementing_Classes");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
*** 483,552 ****
}
/**
* {@inheritDoc}
*/
public void addImplementedInterfacesInfo(Content classInfoTree) {
! //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
! // it doesn't walk up the tree like we want it to.
! List<Type> interfaceArray = utils.getAllInterfaces(classDoc, configuration);
! if (classDoc.isClass() && interfaceArray.size() > 0) {
Content label = getResource(
"doclet.All_Implemented_Interfaces");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
! dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES,
! interfaceArray));
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
public void addSuperInterfacesInfo(Content classInfoTree) {
! //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
! // it doesn't walk up the tree like we want it to.
! List<Type> interfaceArray = utils.getAllInterfaces(classDoc, configuration);
! if (classDoc.isInterface() && interfaceArray.size() > 0) {
! Content label = getResource(
! "doclet.All_Superinterfaces");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
! dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES,
! interfaceArray));
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
! public void addNestedClassInfo(Content classInfoTree) {
! ClassDoc outerClass = classDoc.containingClass();
! if (outerClass != null) {
! Content label;
! if (outerClass.isInterface()) {
! label = getResource(
! "doclet.Enclosing_Interface");
! } else {
! label = getResource(
! "doclet.Enclosing_Class");
! }
! Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
dd.addContent(getLink(new LinkInfoImpl(configuration,
! LinkInfoImpl.Kind.CLASS, outerClass)));
dl.addContent(dd);
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
public void addFunctionalInterfaceInfo (Content classInfoTree) {
if (isFunctionalInterface()) {
Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
--- 497,568 ----
}
/**
* {@inheritDoc}
*/
+ @Override
public void addImplementedInterfacesInfo(Content classInfoTree) {
! SortedSet<TypeMirror> interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
! interfaces.addAll(utils.getAllInterfaces(typeElement));
! if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
Content label = getResource(
"doclet.All_Implemented_Interfaces");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
! dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces));
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
+ @Override
public void addSuperInterfacesInfo(Content classInfoTree) {
! SortedSet<TypeMirror> interfaces =
! new TreeSet<>(utils.makeTypeMirrorIndexUseComparator());
! interfaces.addAll(utils.getAllInterfaces(typeElement));
!
! if (utils.isInterface(typeElement) && !interfaces.isEmpty()) {
! Content label = getResource("doclet.All_Superinterfaces");
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
! dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces));
classInfoTree.addContent(dl);
}
}
/**
* {@inheritDoc}
*/
! @Override
! public void addNestedClassInfo(final Content classInfoTree) {
! Element outerClass = typeElement.getEnclosingElement();
! if (outerClass == null)
! return;
! new SimpleElementVisitor8<Void, Void>() {
! @Override @DefinedBy(Api.LANGUAGE_MODEL)
! public Void visitType(TypeElement e, Void p) {
! String label = utils.isInterface(e)
! ? "doclet.Enclosing_Interface"
! : "doclet.Enclosing_Class";
! Content dt = HtmlTree.DT(getResource(label));
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
dd.addContent(getLink(new LinkInfoImpl(configuration,
! LinkInfoImpl.Kind.CLASS, e)));
dl.addContent(dd);
classInfoTree.addContent(dl);
+ return null;
}
+ }.visit(outerClass);
}
/**
* {@inheritDoc}
*/
+ @Override
public void addFunctionalInterfaceInfo (Content classInfoTree) {
if (isFunctionalInterface()) {
Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
*** 555,591 ****
classInfoTree.addContent(dl);
}
}
public boolean isFunctionalInterface() {
! if (configuration.root instanceof RootDocImpl) {
! RootDocImpl root = (RootDocImpl) configuration.root;
! AnnotationDesc[] annotationDescList = classDoc.annotations();
! for (AnnotationDesc annoDesc : annotationDescList) {
! if (root.isFunctionalInterface(annoDesc)) {
return true;
}
}
- }
return false;
}
/**
* {@inheritDoc}
*/
public void addClassDeprecationInfo(Content classInfoTree) {
Content hr = new HtmlTree(HtmlTag.HR);
classInfoTree.addContent(hr);
! Tag[] deprs = classDoc.tags("deprecated");
! if (utils.isDeprecated(classDoc)) {
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
! if (deprs.length > 0) {
! Tag[] commentTags = deprs[0].inlineTags();
! if (commentTags.length > 0) {
div.addContent(getSpace());
! addInlineDeprecatedComment(classDoc, deprs[0], div);
}
}
classInfoTree.addContent(div);
}
}
--- 571,608 ----
classInfoTree.addContent(dl);
}
}
public boolean isFunctionalInterface() {
! List<? extends AnnotationMirror> annotationMirrors = ((Element) typeElement).getAnnotationMirrors();
! for (AnnotationMirror anno : annotationMirrors) {
! if (utils.isFunctionalInterface(anno)) {
return true;
}
}
return false;
}
+
/**
* {@inheritDoc}
*/
+ @Override
public void addClassDeprecationInfo(Content classInfoTree) {
Content hr = new HtmlTree(HtmlTag.HR);
classInfoTree.addContent(hr);
! List<? extends DocTree> deprs = utils.getBlockTags(typeElement, DocTree.Kind.DEPRECATED);
! if (utils.isDeprecated(typeElement)) {
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
! if (!deprs.isEmpty()) {
! CommentHelper ch = utils.getCommentHelper(typeElement);
! DocTree dt = deprs.get(0);
! List<? extends DocTree> commentTags = ch.getBody(configuration, dt);
! if (!commentTags.isEmpty()) {
div.addContent(getSpace());
! addInlineDeprecatedComment(typeElement, deprs.get(0), div);
}
}
classInfoTree.addContent(div);
}
}
*** 596,630 ****
* @param context the id of the context where the link will be printed
* @param list the list of classes
* @return a content tree for the class list
*/
private Content getClassLinks(LinkInfoImpl.Kind context, Collection<?> list) {
- Object[] typeList = list.toArray();
Content dd = new HtmlTree(HtmlTag.DD);
boolean isFirst = true;
! for (Object item : typeList) {
if (!isFirst) {
Content separator = new StringContent(", ");
dd.addContent(separator);
} else {
isFirst = false;
}
!
! if (item instanceof ClassDoc) {
! Content link = getLink(new LinkInfoImpl(configuration, context, (ClassDoc)item));
dd.addContent(link);
} else {
! Content link = getLink(new LinkInfoImpl(configuration, context, (Type)item));
dd.addContent(link);
}
}
return dd;
}
/**
* {@inheritDoc}
*/
protected Content getNavLinkTree() {
Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
treeLabel, "", "");
Content li = HtmlTree.LI(treeLinkContent);
return li;
--- 613,649 ----
* @param context the id of the context where the link will be printed
* @param list the list of classes
* @return a content tree for the class list
*/
private Content getClassLinks(LinkInfoImpl.Kind context, Collection<?> list) {
Content dd = new HtmlTree(HtmlTag.DD);
boolean isFirst = true;
! for (Object type : list) {
if (!isFirst) {
Content separator = new StringContent(", ");
dd.addContent(separator);
} else {
isFirst = false;
}
! // TODO: should we simply split this method up to avoid instanceof ?
! if (type instanceof TypeElement) {
! Content link = getLink(
! new LinkInfoImpl(configuration, context, (TypeElement)(type)));
dd.addContent(link);
} else {
! Content link = getLink(
! new LinkInfoImpl(configuration, context, ((TypeMirror)type)));
dd.addContent(link);
}
}
return dd;
}
/**
* {@inheritDoc}
*/
+ @Override
protected Content getNavLinkTree() {
Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
treeLabel, "", "");
Content li = HtmlTree.LI(treeLinkContent);
return li;
*** 639,649 ****
try {
Content div = HtmlTree.DIV(getNavSummaryLinks());
div.addContent(getNavDetailLinks());
subDiv.addContent(div);
} catch (Exception e) {
- e.printStackTrace();
throw new DocletAbortException(e);
}
}
/**
--- 658,667 ----
*** 655,687 ****
Content li = HtmlTree.LI(summaryLabel);
li.addContent(getSpace());
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
! String[] navLinkLabels = new String[] {
! "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
! "doclet.navMethod"
! };
! for (int i = 0; i < navLinkLabels.length; i++ ) {
Content liNav = new HtmlTree(HtmlTag.LI);
! if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
continue;
}
! if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
continue;
}
AbstractMemberWriter writer =
! ((AbstractMemberWriter) memberSummaryBuilder.
! getMemberSummaryWriter(i));
if (writer == null) {
! liNav.addContent(getResource(navLinkLabels[i]));
} else {
writer.addNavSummaryLink(
! memberSummaryBuilder.members(i),
! memberSummaryBuilder.getVisibleMemberMap(i), liNav);
}
! if (i < navLinkLabels.length-1) {
addNavGap(liNav);
}
ulNav.addContent(liNav);
}
return ulNav;
--- 673,700 ----
Content li = HtmlTree.LI(summaryLabel);
li.addContent(getSpace());
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
! for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.summarySet) {
Content liNav = new HtmlTree(HtmlTag.LI);
! if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
continue;
}
! if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
continue;
}
AbstractMemberWriter writer =
! ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
if (writer == null) {
! liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
} else {
writer.addNavSummaryLink(
! memberSummaryBuilder.members(kind),
! memberSummaryBuilder.getVisibleMemberMap(kind), liNav);
}
! if (kind != Kind.METHODS) {
addNavGap(liNav);
}
ulNav.addContent(liNav);
}
return ulNav;
*** 689,726 ****
/**
* Get detail links for the navigation bar.
*
* @return the content tree for the detail links
*/
protected Content getNavDetailLinks() throws Exception {
Content li = HtmlTree.LI(detailLabel);
li.addContent(getSpace());
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
! String[] navLinkLabels = new String[] {
! "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
! "doclet.navMethod"
! };
! for (int i = 1; i < navLinkLabels.length; i++ ) {
Content liNav = new HtmlTree(HtmlTag.LI);
AbstractMemberWriter writer =
((AbstractMemberWriter) memberSummaryBuilder.
! getMemberSummaryWriter(i));
! if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
continue;
}
! if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
continue;
}
if (writer == null) {
! liNav.addContent(getResource(navLinkLabels[i]));
} else {
! writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav);
}
! if (i < navLinkLabels.length - 1) {
addNavGap(liNav);
}
ulNav.addContent(liNav);
}
return ulNav;
--- 702,736 ----
/**
* Get detail links for the navigation bar.
*
* @return the content tree for the detail links
+ * @throws java.lang.Exception
*/
protected Content getNavDetailLinks() throws Exception {
Content li = HtmlTree.LI(detailLabel);
li.addContent(getSpace());
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
! for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.detailSet) {
Content liNav = new HtmlTree(HtmlTag.LI);
AbstractMemberWriter writer =
((AbstractMemberWriter) memberSummaryBuilder.
! getMemberSummaryWriter(kind));
! if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
continue;
}
! if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
continue;
}
if (writer == null) {
! liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
} else {
! writer.addNavDetailLink(memberSummaryBuilder.members(kind), liNav);
}
! if (kind != Kind.METHODS) {
addNavGap(liNav);
}
ulNav.addContent(liNav);
}
return ulNav;
*** 736,748 ****
liNav.addContent("|");
liNav.addContent(getSpace());
}
/**
! * Return the classDoc being documented.
*
! * @return the classDoc being documented.
*/
! public ClassDoc getClassDoc() {
! return classDoc;
}
}
--- 746,759 ----
liNav.addContent("|");
liNav.addContent(getSpace());
}
/**
! * Return the TypeElement being documented.
*
! * @return the TypeElement being documented.
*/
! @Override
! public TypeElement getTypeElement() {
! return typeElement;
}
}