提交 3338bba0 编写于 作者: L lana

Merge

......@@ -52,6 +52,7 @@ import com.sun.source.tree.Tree;
public abstract class Trees {
/**
* Gets a Trees object for a given CompilationTask.
* @param task the compilation task for which to get the Trees object
* @throws IllegalArgumentException if the task does not support the Trees API.
*/
public static Trees instance(CompilationTask task) {
......@@ -61,7 +62,8 @@ public abstract class Trees {
}
/**
* Gets a Trees object for a given CompilationTask.
* Gets a Trees object for a given ProcessingEnvironment.
* @param env the processing environment for which to get the Trees object
* @throws IllegalArgumentException if the env does not support the Trees API.
*/
public static Trees instance(ProcessingEnvironment env) {
......@@ -162,6 +164,12 @@ public abstract class Trees {
*/
public abstract Scope getScope(TreePath path);
/**
* Gets the doc comment, if any, for the Tree node identified by a given TreePath.
* Returns null if no doc comment was found.
*/
public abstract String getDocComment(TreePath path);
/**
* Checks whether a given type is accessible in a given scope.
* @param scope the scope to be checked
......
......@@ -51,16 +51,16 @@ import com.sun.tools.javac.parser.DocCommentScanner;
* or deletion without notice.</b>
*/
@SuppressWarnings("deprecation")
public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
/** The context key for the compiler. */
protected static final Context.Key<JavaCompiler> compilerKey =
new Context.Key<JavaCompiler>();
protected static final Context.Key<AptJavaCompiler> compilerKey =
new Context.Key<AptJavaCompiler>();
/** Get the JavaCompiler instance for this context. */
public static JavaCompiler instance(Context context) {
JavaCompiler instance = context.get(compilerKey);
public static AptJavaCompiler instance(Context context) {
AptJavaCompiler instance = context.get(compilerKey);
if (instance == null)
instance = new JavaCompiler(context);
instance = new AptJavaCompiler(context);
return instance;
}
......@@ -107,7 +107,7 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
/** Construct a new compiler from a shared context.
*/
public JavaCompiler(Context context) {
public AptJavaCompiler(Context context) {
super(preRegister(context));
context.put(compilerKey, this);
......
......@@ -421,7 +421,7 @@ public class Main {
},
new AptOption("-version", "opt.version") {
boolean process(String option) {
Bark.printLines(out, ownName + " " + JavaCompiler.version());
Bark.printLines(out, ownName + " " + AptJavaCompiler.version());
return super.process(option);
}
},
......@@ -1111,11 +1111,11 @@ public class Main {
}
int exitCode = EXIT_OK;
JavaCompiler comp = null;
AptJavaCompiler comp = null;
try {
context.put(Bark.outKey, out);
comp = JavaCompiler.instance(context);
comp = AptJavaCompiler.instance(context);
if (comp == null)
return EXIT_SYSERR;
......@@ -1184,7 +1184,7 @@ public class Main {
*/
void bugMessage(Throwable ex) {
Bark.printLines(out, getLocalizedString("msg.bug",
JavaCompiler.version()));
AptJavaCompiler.version()));
ex.printStackTrace(out);
}
......
......@@ -120,7 +120,7 @@ public class FilerImpl implements Filer {
private final Options opts;
private final DeclarationMaker declMaker;
private final com.sun.tools.apt.main.JavaCompiler comp;
private final com.sun.tools.apt.main.AptJavaCompiler comp;
// Platform's default encoding
private final static String DEFAULT_ENCODING =
......@@ -177,7 +177,7 @@ public class FilerImpl implements Filer {
opts = Options.instance(context);
declMaker = DeclarationMaker.instance(context);
bark = Bark.instance(context);
comp = com.sun.tools.apt.main.JavaCompiler.instance(context);
comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context);
roundOver = false;
this.filesCreated = comp.getAggregateGenFiles();
......
......@@ -26,12 +26,16 @@
package com.sun.tools.doclets.formats.html;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
/**
* Print method and constructor info.
*
* @author Robert Field
* @author Atul M Dambalkar
* @author Bhavesh Patel (Modified)
*/
public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
......@@ -45,82 +49,111 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
}
/**
* Write the type parameters for the executable member.
* Add the type parameters for the executable member.
*
* @param member the member to write type parameters for.
* @param htmltree the content tree to which the parameters will be added.
* @return the display length required to write this information.
*/
protected int writeTypeParameters(ExecutableMemberDoc member) {
protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
LinkInfoImpl linkInfo = new LinkInfoImpl(
LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
String typeParameters = writer.getTypeParameterLinks(linkInfo);
if (linkInfo.displayLength > 0) {
writer.print(typeParameters + " ");
Content linkContent = new RawHtml(typeParameters);
htmltree.addContent(linkContent);
htmltree.addContent(writer.getSpace());
writer.displayLength += linkInfo.displayLength + 1;
}
return linkInfo.displayLength;
}
protected void writeSignature(ExecutableMemberDoc member) {
writer.displayLength = 0;
writer.pre();
writer.writeAnnotationInfo(member);
printModifiers(member);
writeTypeParameters(member);
if (configuration().linksource &&
member.position().line() != classdoc.position().line()) {
writer.printSrcLink(member, member.name());
} else {
strong(member.name());
}
writeParameters(member);
writeExceptions(member);
writer.preEnd();
}
protected void writeDeprecatedLink(ProgramElementDoc member) {
/**
* {@inheritDoc}
*/
protected Content getDeprecatedLink(ProgramElementDoc member) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
emd.qualifiedName() + emd.flatSignature(), false);
return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
emd.qualifiedName() + emd.flatSignature());
}
protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
/**
* Add the summary link for the member.
*
* @param context the id of the context where the link will be printed
* @param classDoc the classDoc that we should link to
* @param member the member being linked to
* @param tdSummary the content tree to which the link will be added
*/
protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
String name = emd.name();
writer.strong();
writer.printDocLink(context, cd, (MemberDoc) emd,
name, false);
writer.strongEnd();
Content strong = HtmlTree.STRONG(new RawHtml(
writer.getDocLink(context, cd, (MemberDoc) emd,
name, false)));
Content code = HtmlTree.CODE(strong);
writer.displayLength = name.length();
writeParameters(emd, false);
addParameters(emd, false, code);
tdSummary.addContent(code);
}
protected void writeInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member) {
writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
member.name(), false);
/**
* Add the inherited summary link for the member.
*
* @param classDoc the classDoc that we should link to
* @param member the member being linked to
* @param linksTree the content tree to which the link will be added
*/
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
linksTree.addContent(new RawHtml(
writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
member.name(), false)));
}
protected void writeParam(ExecutableMemberDoc member, Parameter param,
boolean isVarArg) {
/**
* Add the parameter for the executable member.
*
* @param member the member to write parameter for.
* @param param the parameter that needs to be written.
* @param isVarArg true if this is a link to var arg.
* @param tree the content tree to which the parameter information will be added.
*/
protected void addParam(ExecutableMemberDoc member, Parameter param,
boolean isVarArg, Content tree) {
if (param.type() != null) {
writer.printLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
isVarArg));
Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
isVarArg)));
tree.addContent(link);
}
if(param.name().length() > 0) {
writer.space();
writer.print(param.name());
tree.addContent(writer.getSpace());
tree.addContent(param.name());
}
}
protected void writeParameters(ExecutableMemberDoc member) {
writeParameters(member, true);
/**
* Add all the parameters for the executable member.
*
* @param member the member to write parameters for.
* @param tree the content tree to which the parameters information will be added.
*/
protected void addParameters(ExecutableMemberDoc member, Content htmltree) {
addParameters(member, true, htmltree);
}
protected void writeParameters(ExecutableMemberDoc member,
boolean includeAnnotations) {
print('(');
/**
* Add all the parameters for the executable member.
*
* @param member the member to write parameters for.
* @param includeAnnotations true if annotation information needs to be added.
* @param tree the content tree to which the parameters information will be added.
*/
protected void addParameters(ExecutableMemberDoc member,
boolean includeAnnotations, Content htmltree) {
htmltree.addContent("(");
Parameter[] params = member.parameters();
String indent = makeSpace(writer.displayLength);
if (configuration().linksource) {
......@@ -132,58 +165,70 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
Parameter param = params[paramstart];
if (!param.name().startsWith("this$")) {
if (includeAnnotations) {
boolean foundAnnotations =
writer.writeAnnotationInfo(indent.length(), member, param);
if (foundAnnotations) {
writer.println();
writer.print(indent);
boolean foundAnnotations =
writer.addAnnotationInfo(indent.length(),
member, param, htmltree);
if (foundAnnotations) {
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
}
}
writeParam(member, param,
(paramstart == params.length - 1) && member.isVarArgs());
addParam(member, param,
(paramstart == params.length - 1) && member.isVarArgs(), htmltree);
break;
}
}
for (int i = paramstart + 1; i < params.length; i++) {
writer.print(',');
writer.println();
writer.print(indent);
htmltree.addContent(",");
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
if (includeAnnotations) {
boolean foundAnnotations =
writer.writeAnnotationInfo(indent.length(), member, params[i]);
writer.addAnnotationInfo(indent.length(), member, params[i],
htmltree);
if (foundAnnotations) {
writer.println();
writer.print(indent);
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
}
}
writeParam(member, params[i], (i == params.length - 1) && member.isVarArgs());
addParam(member, params[i], (i == params.length - 1) && member.isVarArgs(),
htmltree);
}
writer.print(')');
htmltree.addContent(")");
}
protected void writeExceptions(ExecutableMemberDoc member) {
/**
* Add exceptions for the executable member.
*
* @param member the member to write exceptions for.
* @param htmltree the content tree to which the exceptions information will be added.
*/
protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
Type[] exceptions = member.thrownExceptionTypes();
if(exceptions.length > 0) {
LinkInfoImpl memberTypeParam = new LinkInfoImpl(
LinkInfoImpl.CONTEXT_MEMBER, member, false);
LinkInfoImpl.CONTEXT_MEMBER, member, false);
int retlen = getReturnTypeLength(member);
writer.getTypeParameterLinks(memberTypeParam);
retlen += memberTypeParam.displayLength == 0 ?
0 : memberTypeParam.displayLength + 1;
String indent = makeSpace(modifierString(member).length() +
member.name().length() + retlen - 4);
writer.println();
writer.print(indent);
writer.print("throws ");
member.name().length() + retlen - 4);
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
htmltree.addContent("throws ");
indent += " ";
writer.printLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_MEMBER, exceptions[0]));
Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
htmltree.addContent(link);
for(int i = 1; i < exceptions.length; i++) {
writer.println(",");
writer.print(indent);
writer.printLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_MEMBER, exceptions[i]));
htmltree.addContent(",");
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
htmltree.addContent(exceptionLink);
}
}
}
......
......@@ -30,6 +30,8 @@ import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
/**
* Generate Index for all the Member Names with Indexing in
......@@ -39,6 +41,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
*
* @see IndexBuilder
* @author Atul M Dambalkar
* @author Bhavesh Patel (Modified)
*/
public class AbstractIndexWriter extends HtmlDocletWriter {
......@@ -78,175 +81,187 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
}
/**
* Print the text "Index" in strong format in the navigation bar.
* Get the index label for navigation bar.
*
* @return a content tree for the tree label
*/
protected void navLinkIndex() {
navCellRevStart();
fontStyle("NavBarFont1Rev");
strongText("doclet.Index");
fontEnd();
navCellEnd();
protected Content getNavLinkIndex() {
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
return li;
}
/**
* Generate the member information for the unicode character along with the
* Add the member information for the unicode character along with the
* list of the members.
*
* @param unicode Unicode for which member list information to be generated.
* @param memberlist List of members for the unicode character.
* @param unicode Unicode for which member list information to be generated
* @param memberlist List of members for the unicode character
* @param contentTree the content tree to which the information will be added
*/
protected void generateContents(Character unicode, List<? extends Doc> memberlist) {
anchor("_" + unicode + "_");
h2();
strong(unicode.toString());
h2End();
protected void addContents(Character unicode, List<? extends Doc> memberlist,
Content contentTree) {
contentTree.addContent(getMarkerAnchor("_" + unicode + "_"));
Content headContent = new StringContent(unicode.toString());
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
HtmlStyle.title, headContent);
contentTree.addContent(heading);
int memberListSize = memberlist.size();
// Display the list only if there are elements to be displayed.
if (memberListSize > 0) {
dl();
Content dl = new HtmlTree(HtmlTag.DL);
for (int i = 0; i < memberListSize; i++) {
Doc element = memberlist.get(i);
if (element instanceof MemberDoc) {
printDescription((MemberDoc)element);
addDescription((MemberDoc)element, dl);
} else if (element instanceof ClassDoc) {
printDescription((ClassDoc)element);
addDescription((ClassDoc)element, dl);
} else if (element instanceof PackageDoc) {
printDescription((PackageDoc)element);
addDescription((PackageDoc)element, dl);
}
}
dlEnd();
contentTree.addContent(dl);
}
hr();
}
/**
* Print one line summary comment for the package.
* Add one line summary comment for the package.
*
* @param pkg PackageDoc passed.
* @param pkg the package to be documented
* @param dlTree the content tree to which the description will be added
*/
protected void printDescription(PackageDoc pkg) {
dt();
printPackageLink(pkg, Util.getPackageName(pkg), true);
print(" - ");
print(configuration.getText("doclet.package") + " " + pkg.name());
dtEnd();
dd();
printSummaryComment(pkg);
ddEnd();
protected void addDescription(PackageDoc pkg, Content dlTree) {
Content link = getPackageLink(pkg, new StringContent(Util.getPackageName(pkg)));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
dt.addContent(getResource("doclet.package"));
dt.addContent(" " + pkg.name());
dlTree.addContent(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addSummaryComment(pkg, dd);
dlTree.addContent(dd);
}
/**
* Print one line summary comment for the class.
* Add one line summary comment for the class.
*
* @param cd ClassDoc passed.
* @param cd the class being documented
* @param dlTree the content tree to which the description will be added
*/
protected void printDescription(ClassDoc cd) {
dt();
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true));
print(" - ");
printClassInfo(cd);
dtEnd();
dd();
printComment(cd);
ddEnd();
protected void addDescription(ClassDoc cd, Content dlTree) {
Content link = new RawHtml(
getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
addClassInfo(cd, dt);
dlTree.addContent(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addComment(cd, dd);
dlTree.addContent(dd);
}
/**
* Print the classkind(class, interface, exception, error of the class
* Add the classkind(class, interface, exception, error of the class
* passed.
*
* @param cd ClassDoc.
* @param cd the class being documented
* @param contentTree the content tree to which the class info will be added
*/
protected void printClassInfo(ClassDoc cd) {
print(configuration.getText("doclet.in",
Util.getTypeName(configuration, cd, false),
getPackageLink(cd.containingPackage(),
protected void addClassInfo(ClassDoc cd, Content contentTree) {
contentTree.addContent(getResource("doclet.in",
Util.getTypeName(configuration, cd, false),
getPackageLinkString(cd.containingPackage(),
Util.getPackageName(cd.containingPackage()), false)));
}
/**
* Generate Description for Class, Field, Method or Constructor.
* for Java.* Packages Class Members.
* Add description for Class, Field, Method or Constructor.
*
* @param member MemberDoc for the member of the Class Kind.
* @see com.sun.javadoc.MemberDoc
* @param member MemberDoc for the member of the Class Kind
* @param dlTree the content tree to which the description will be added
*/
protected void printDescription(MemberDoc member) {
protected void addDescription(MemberDoc member, Content dlTree) {
String name = (member instanceof ExecutableMemberDoc)?
member.name() + ((ExecutableMemberDoc)member).flatSignature() :
member.name();
if (name.indexOf("<") != -1 || name.indexOf(">") != -1) {
name = Util.escapeHtmlChars(name);
}
ClassDoc containing = member.containingClass();
dt();
printDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name, true);
println(" - ");
printMemberDesc(member);
println();
dtEnd();
dd();
printComment(member);
ddEnd();
println();
Content span = HtmlTree.SPAN(HtmlStyle.strong,
getDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name));
Content dt = HtmlTree.DT(span);
dt.addContent(" - ");
addMemberDesc(member, dt);
dlTree.addContent(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addComment(member, dd);
dlTree.addContent(dd);
}
/**
* Print comment for each element in the index. If the element is deprecated
* Add comment for each element in the index. If the element is deprecated
* and it has a @deprecated tag, use that comment. Else if the containing
* class for this element is deprecated, then add the word "Deprecated." at
* the start and then print the normal comment.
*
* @param element Index element.
* @param element Index element
* @param contentTree the content tree to which the comment will be added
*/
protected void printComment(ProgramElementDoc element) {
protected void addComment(ProgramElementDoc element, Content contentTree) {
Tag[] tags;
Content span = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.block);
if (Util.isDeprecated(element)) {
strongText("doclet.Deprecated"); space();
div.addContent(span);
if ((tags = element.tags("deprecated")).length > 0)
printInlineDeprecatedComment(element, tags[0]);
addInlineDeprecatedComment(element, tags[0], div);
contentTree.addContent(div);
} else {
ClassDoc cont = element.containingClass();
while (cont != null) {
if (Util.isDeprecated(cont)) {
strongText("doclet.Deprecated"); space();
div.addContent(span);
contentTree.addContent(div);
break;
}
cont = cont.containingClass();
}
printSummaryComment(element);
addSummaryComment(element, contentTree);
}
}
/**
* Print description about the Static Varible/Method/Constructor for a
* Add description about the Static Varible/Method/Constructor for a
* member.
*
* @param member MemberDoc for the member within the Class Kind.
* @see com.sun.javadoc.MemberDoc
* @param member MemberDoc for the member within the Class Kind
* @param contentTree the content tree to which the member description will be added
*/
protected void printMemberDesc(MemberDoc member) {
protected void addMemberDesc(MemberDoc member, Content contentTree) {
ClassDoc containing = member.containingClass();
String classdesc = Util.getTypeName(configuration, containing, true) + " " +
getPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
false);
String classdesc = Util.getTypeName(
configuration, containing, true) + " ";
if (member.isField()) {
if (member.isStatic()) {
printText("doclet.Static_variable_in", classdesc);
contentTree.addContent(
getResource("doclet.Static_variable_in", classdesc));
} else {
printText("doclet.Variable_in", classdesc);
contentTree.addContent(
getResource("doclet.Variable_in", classdesc));
}
} else if (member.isConstructor()) {
printText("doclet.Constructor_for", classdesc);
contentTree.addContent(
getResource("doclet.Constructor_for", classdesc));
} else if (member.isMethod()) {
if (member.isStatic()) {
printText("doclet.Static_method_in", classdesc);
contentTree.addContent(
getResource("doclet.Static_method_in", classdesc));
} else {
printText("doclet.Method_in", classdesc);
contentTree.addContent(
getResource("doclet.Method_in", classdesc));
}
}
addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
false, contentTree);
}
}
......@@ -25,9 +25,11 @@
package com.sun.tools.doclets.formats.html;
import com.sun.javadoc.*;
import java.io.*;
import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
/**
* Abstract class to generate the overview files in
......@@ -56,105 +58,127 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
packages = configuration.packages;
}
protected abstract void printNavigationBarHeader();
protected abstract void printNavigationBarFooter();
protected abstract void printOverviewHeader();
/**
* Adds the navigation bar header to the documentation tree.
*
* @param body the document tree to which the navigation bar header will be added
*/
protected abstract void addNavigationBarHeader(Content body);
protected abstract void printIndexHeader(String text, String tableSummary);
/**
* Adds the navigation bar footer to the documentation tree.
*
* @param body the document tree to which the navigation bar footer will be added
*/
protected abstract void addNavigationBarFooter(Content body);
protected abstract void printIndexRow(PackageDoc pkg);
/**
* Adds the overview header to the documentation tree.
*
* @param body the document tree to which the overview header will be added
*/
protected abstract void addOverviewHeader(Content body);
protected abstract void printIndexFooter();
/**
* Adds the packages list to the documentation tree.
*
* @param packages an array of packagedoc objects
* @param text caption for the table
* @param tableSummary summary for the table
* @param body the document tree to which the packages list will be added
*/
protected abstract void addPackagesList(PackageDoc[] packages, String text,
String tableSummary, Content body);
/**
* Generate the contants in the package index file. Call appropriate
* Generate and prints the contents in the package index file. Call appropriate
* methods from the sub-class in order to generate Frame or Non
* Frame format.
*
* @param title the title of the window.
* @param includeScript boolean set true if windowtitle script is to be included
*/
protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException {
protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException {
String windowOverview = configuration.getText(title);
printHtmlHeader(windowOverview,
configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle),
includeScript);
printNavigationBarHeader();
printOverviewHeader();
generateIndex();
printOverview();
printNavigationBarFooter();
printBodyHtmlEnd();
Content body = getBody(includeScript, getWindowTitle(windowOverview));
addNavigationBarHeader(body);
addOverviewHeader(body);
addIndex(body);
addOverview(body);
addNavigationBarFooter(body);
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
configuration.doctitle), includeScript, body);
}
/**
* Default to no overview, overwrite to add overview.
* Default to no overview, override to add overview.
*
* @param body the document tree to which the overview will be added
*/
protected void printOverview() throws IOException {
protected void addOverview(Content body) throws IOException {
}
/**
* Generate the frame or non-frame package index.
* Adds the frame or non-frame package index to the documentation tree.
*
* @param body the document tree to which the index will be added
*/
protected void generateIndex() {
printIndexContents(packages, "doclet.Package_Summary",
protected void addIndex(Content body) {
addIndexContents(packages, "doclet.Package_Summary",
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Package_Summary"),
configuration.getText("doclet.packages")));
configuration.getText("doclet.packages")), body);
}
/**
* Generate code for package index contents. Call appropriate methods from
* the sub-classes.
* Adds package index contents. Call appropriate methods from
* the sub-classes. Adds it to the body HtmlTree
*
* @param packages Array of packages to be documented.
* @param text String which will be used as the heading.
* @param packages array of packages to be documented
* @param text string which will be used as the heading
* @param tableSummary summary for the table
* @param body the document tree to which the index contents will be added
*/
protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) {
protected void addIndexContents(PackageDoc[] packages, String text,
String tableSummary, Content body) {
if (packages.length > 0) {
Arrays.sort(packages);
printIndexHeader(text, tableSummary);
printAllClassesPackagesLink();
for(int i = 0; i < packages.length; i++) {
if (packages[i] != null) {
printIndexRow(packages[i]);
}
}
printIndexFooter();
addAllClassesLink(body);
addPackagesList(packages, text, tableSummary, body);
}
}
/**
* Print the doctitle, if it is specified on the command line.
* Adds the doctitle to the documentation tree, if it is specified on the command line.
*
* @param body the document tree to which the title will be added
*/
protected void printConfigurationTitle() {
protected void addConfigurationTitle(Content body) {
if (configuration.doctitle.length() > 0) {
center();
h1(configuration.doctitle);
centerEnd();
Content title = new RawHtml(configuration.doctitle);
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
HtmlStyle.title, title);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
body.addContent(div);
}
}
/**
* Highlight "Overview" in the strong format, in the navigation bar as this
* is the overview page.
* Returns highlighted "Overview", in the navigation bar as this is the
* overview page.
*
* @return a Content object to be added to the documentation tree
*/
protected void navLinkContents() {
navCellRevStart();
fontStyle("NavBarFont1Rev");
strongText("doclet.Overview");
fontEnd();
navCellEnd();
protected Content getNavLinkContents() {
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
return li;
}
/**
* Do nothing. This will be overridden in PackageIndexFrameWriter.
*
* @param body the document tree to which the all classes link will be added
*/
protected void printAllClassesPackagesLink() {
protected void addAllClassesLink(Content body) {
}
}
......@@ -25,11 +25,12 @@
package com.sun.tools.doclets.formats.html;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.javadoc.*;
import java.io.*;
import java.util.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.javadoc.*;
/**
* Abstract class to print the class hierarchy page for all the Classes. This
......@@ -46,6 +47,8 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
*/
protected final ClassTree classtree;
private static final String LI_CIRCLE = "circle";
/**
* Constructor initilises classtree variable. This constructor will be used
* while generating global tree file "overview-tree.html".
......@@ -87,55 +90,64 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
}
/**
* Generate each level of the class tree. For each sub-class or
* Add each level of the class tree. For each sub-class or
* sub-interface indents the next level information.
* Recurses itself to generate subclasses info.
* To iterate is human, to recurse is divine - L. Peter Deutsch.
* Recurses itself to add subclasses info.
*
* @param parent the superclass or superinterface of the list.
* @param list list of the sub-classes at this level.
* @param isEnum true if we are generating a tree for enums.
* @param parent the superclass or superinterface of the list
* @param list list of the sub-classes at this level
* @param isEnum true if we are generating a tree for enums
* @param contentTree the content tree to which the level information will be added
*/
protected void generateLevelInfo(ClassDoc parent, List<ClassDoc> list,
boolean isEnum) {
if (list.size() > 0) {
ul();
for (int i = 0; i < list.size(); i++) {
protected void addLevelInfo(ClassDoc parent, List<ClassDoc> list,
boolean isEnum, Content contentTree) {
int size = list.size();
if (size > 0) {
Content ul = new HtmlTree(HtmlTag.UL);
for (int i = 0; i < size; i++) {
ClassDoc local = list.get(i);
printPartialInfo(local);
printExtendsImplements(parent, local);
generateLevelInfo(local, classtree.subs(local, isEnum),
isEnum); // Recurse
HtmlTree li = new HtmlTree(HtmlTag.LI);
li.addAttr(HtmlAttr.TYPE, LI_CIRCLE);
addPartialInfo(local, li);
addExtendsImplements(parent, local, li);
addLevelInfo(local, classtree.subs(local, isEnum),
isEnum, li); // Recurse
ul.addContent(li);
}
ulEnd();
contentTree.addContent(ul);
}
}
/**
* Generate the heading for the tree depending upon tree type if it's a
* Class Tree or Interface tree and also print the tree.
* Add the heading for the tree depending upon tree type if it's a
* Class Tree or Interface tree.
*
* @param list List of classes which are at the most base level, all the
* other classes in this run will derive from these classes.
* @param heading Heading for the tree.
* other classes in this run will derive from these classes
* @param heading heading for the tree
* @param div the content tree to which the tree will be added
*/
protected void generateTree(List<ClassDoc> list, String heading) {
protected void addTree(List<ClassDoc> list, String heading, Content div) {
if (list.size() > 0) {
ClassDoc firstClassDoc = list.get(0);
printTreeHeading(heading);
generateLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
list,
list == classtree.baseEnums());
Content headingContent = getResource(heading);
div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
headingContent));
addLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
list, list == classtree.baseEnums(), div);
}
}
/**
* Print the information regarding the classes which this class extends or
* Add information regarding the classes which this class extends or
* implements.
*
* @param cd The classdoc under consideration.
* @param parent the parent class of the class being documented
* @param cd the classdoc under consideration
* @param contentTree the content tree to which the information will be added
*/
protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) {
protected void addExtendsImplements(ClassDoc parent, ClassDoc cd,
Content contentTree) {
ClassDoc[] interfaces = cd.interfaces();
if (interfaces.length > (cd.isInterface()? 1 : 0)) {
Arrays.sort(interfaces);
......@@ -148,53 +160,43 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
}
if (counter == 0) {
if (cd.isInterface()) {
print(" (" + configuration.getText("doclet.also") + " extends ");
contentTree.addContent(" (");
contentTree.addContent(getResource("doclet.also"));
contentTree.addContent(" extends ");
} else {
print(" (implements ");
contentTree.addContent(" (implements ");
}
} else {
print(", ");
contentTree.addContent(", ");
}
printPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
interfaces[i]);
addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
interfaces[i], contentTree);
counter++;
}
}
if (counter > 0) {
println(")");
contentTree.addContent(")");
}
}
}
/**
* Print information about the class kind, if it's a "class" or "interface".
* Add information about the class kind, if it's a "class" or "interface".
*
* @param cd classdoc.
* @param cd the class being documented
* @param contentTree the content tree to which the information will be added
*/
protected void printPartialInfo(ClassDoc cd) {
li("circle");
printPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd);
protected void addPartialInfo(ClassDoc cd, Content contentTree) {
addPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd, contentTree);
}
/**
* Print the heading for the tree.
* Get the tree label for the navigation bar.
*
* @param heading Heading for the tree.
*/
protected void printTreeHeading(String heading) {
h2();
println(configuration.getText(heading));
h2End();
}
/**
* Highlight "Tree" word in the navigation bar, since this is the tree page.
* @return a content tree for the tree label
*/
protected void navLinkTree() {
navCellRevStart();
fontStyle("NavBarFont1Rev");
strongText("doclet.Tree");
fontEnd();
navCellEnd();
protected Content getNavLinkTree() {
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
return li;
}
}
......@@ -25,11 +25,14 @@
package com.sun.tools.doclets.formats.html;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.javadoc.*;
import java.io.*;
import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.formats.html.markup.*;
/**
* Generate the file with list of all the classes in this run. This page will be
* used in the left-hand bottom frame, when "All Classes" link is clicked in
......@@ -38,6 +41,7 @@ import java.util.*;
*
* @author Atul M Dambalkar
* @author Doug Kramer
* @author Bhavesh Patel (Modified)
*/
public class AllClassesFrameWriter extends HtmlDocletWriter {
......@@ -56,6 +60,11 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
*/
protected IndexBuilder indexbuilder;
/**
* BR tag to be used within a document tree.
*/
final HtmlTree BR = new HtmlTree(HtmlTag.BR);
/**
* Construct AllClassesFrameWriter object. Also initilises the indexbuilder
* variable in this class.
......@@ -84,12 +93,12 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
try {
allclassgen = new AllClassesFrameWriter(configuration,
filename, indexbuilder);
allclassgen.generateAllClassesFile(true);
allclassgen.buildAllClassesFile(true);
allclassgen.close();
filename = OUTPUT_FILE_NAME_NOFRAMES;
allclassgen = new AllClassesFrameWriter(configuration,
filename, indexbuilder);
allclassgen.generateAllClassesFile(false);
allclassgen.buildAllClassesFile(false);
allclassgen.close();
} catch (IOException exc) {
configuration.standardmessage.
......@@ -100,30 +109,34 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
}
/**
* Print all the classes in table format in the file.
* Print all the classes in the file.
* @param wantFrames True if we want frames.
*/
protected void generateAllClassesFile(boolean wantFrames) throws IOException {
protected void buildAllClassesFile(boolean wantFrames) throws IOException {
String label = configuration.getText("doclet.All_Classes");
printHtmlHeader(label, null, false);
printAllClassesTableHeader();
printAllClasses(wantFrames);
printAllClassesTableFooter();
printBodyHtmlEnd();
Content body = getBody(false, getWindowTitle(label));
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
HtmlStyle.bar, allclassesLabel);
body.addContent(heading);
Content ul = new HtmlTree(HtmlTag.UL);
// Generate the class links and add it to the tdFont tree.
addAllClasses(ul, wantFrames);
Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
body.addContent(div);
printHtmlDocument(null, false, body);
}
/**
* Use the sorted index of all the classes and print all the classes.
* Use the sorted index of all the classes and add all the classes to the
* content list.
*
* @param content HtmlTree content to which all classes information will be added
* @param wantFrames True if we want frames.
*/
protected void printAllClasses(boolean wantFrames) {
protected void addAllClasses(Content content, boolean wantFrames) {
for (int i = 0; i < indexbuilder.elements().length; i++) {
Character unicode = (Character)((indexbuilder.elements())[i]);
generateContents(indexbuilder.getMemberList(unicode), wantFrames);
addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
}
}
......@@ -136,46 +149,25 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
*
* @param classlist Sorted list of classes.
* @param wantFrames True if we want frames.
* @param content HtmlTree content to which the links will be added
*/
protected void generateContents(List<Doc> classlist, boolean wantFrames) {
protected void addContents(List<Doc> classlist, boolean wantFrames,
Content content) {
for (int i = 0; i < classlist.size(); i++) {
ClassDoc cd = (ClassDoc)classlist.get(i);
if (!Util.isCoreClass(cd)) {
continue;
}
String label = italicsClassName(cd, false);
Content linkContent;
if(wantFrames){
printLink(new LinkInfoImpl(LinkInfoImpl.ALL_CLASSES_FRAME, cd,
label, "classFrame")
);
linkContent = new RawHtml(getLink(new LinkInfoImpl(
LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
} else {
printLink(new LinkInfoImpl(cd, label));
linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
}
br();
Content li = HtmlTree.LI(linkContent);
content.addContent(li);
}
}
/**
* Print the heading "All Classes" and also print Html table tag.
*/
protected void printAllClassesTableHeader() {
fontSizeStyle("+1", "FrameHeadingFont");
strongText("doclet.All_Classes");
fontEnd();
br();
table();
tr();
tdNowrap();
fontStyle("FrameItemFont");
}
/**
* Print Html closing table tag.
*/
protected void printAllClassesTableFooter() {
fontEnd();
tdEnd();
trEnd();
tableEnd();
}
}
......@@ -28,6 +28,7 @@ package com.sun.tools.doclets.formats.html;
import java.io.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
/**
......@@ -54,29 +55,26 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
/**
* {@inheritDoc}
*/
public void writeMemberSummaryHeader(ClassDoc classDoc) {
writer.println("<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->");
writer.println();
writer.printSummaryHeader(this, classDoc);
public Content getMemberSummaryHeader(ClassDoc classDoc,
Content memberSummaryTree) {
memberSummaryTree.addContent(
HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, classDoc, memberTree);
return memberTree;
}
/**
* {@inheritDoc}
*/
public void writeDefaultValueInfo(MemberDoc member) {
public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) {
if (((AnnotationTypeElementDoc) member).defaultValue() != null) {
writer.printMemberDetailsListStartTag();
writer.dd();
writer.dl();
writer.dt();
writer.strong(ConfigurationImpl.getInstance().
getText("doclet.Default"));
writer.dtEnd();
writer.dd();
writer.print(((AnnotationTypeElementDoc) member).defaultValue());
writer.ddEnd();
writer.dlEnd();
writer.ddEnd();
Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
Content dl = HtmlTree.DL(dt);
Content dd = HtmlTree.DD(new StringContent(
((AnnotationTypeElementDoc) member).defaultValue().toString()));
dl.addContent(dd);
annotationDocTree.addContent(dl);
}
}
......@@ -90,45 +88,58 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
/**
* {@inheritDoc}
*/
public void printSummaryLabel() {
writer.printText("doclet.Annotation_Type_Optional_Member_Summary");
public void addSummaryLabel(Content memberTree) {
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
memberTree.addContent(label);
}
/**
* {@inheritDoc}
*/
public void printTableSummary() {
writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
public String getTableSummary() {
return configuration().getText("doclet.Member_Table_Summary",
configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
configuration().getText("doclet.annotation_type_optional_members")));
configuration().getText("doclet.annotation_type_optional_members"));
}
public void printSummaryTableHeader(ProgramElementDoc member) {
/**
* {@inheritDoc}
*/
public String getCaption() {
return configuration().getText("doclet.Annotation_Type_Optional_Members");
}
/**
* {@inheritDoc}
*/
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
configuration().getText("doclet.0_and_1",
configuration().getText("doclet.Annotation_Type_Optional_Member"),
configuration().getText("doclet.Description"))
};
writer.summaryTableHeader(header, "col");
return header;
}
/**
* {@inheritDoc}
*/
public void printSummaryAnchor(ClassDoc cd) {
writer.anchor("annotation_type_optional_element_summary");
public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
memberTree.addContent(writer.getMarkerAnchor(
"annotation_type_optional_element_summary"));
}
/**
* {@inheritDoc}
*/
protected void printNavSummaryLink(ClassDoc cd, boolean link) {
protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
if (link) {
writer.printHyperLink("", "annotation_type_optional_element_summary",
configuration().getText("doclet.navAnnotationTypeOptionalMember"));
return writer.getHyperLink("", "annotation_type_optional_element_summary",
writer.getResource("doclet.navAnnotationTypeOptionalMember"));
} else {
writer.printText("doclet.navAnnotationTypeOptionalMember");
return writer.getResource("doclet.navAnnotationTypeOptionalMember");
}
}
}
......@@ -28,6 +28,7 @@ package com.sun.tools.doclets.formats.html;
import java.io.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
/**
......@@ -51,241 +52,228 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
}
/**
* Write the annotation type member summary header for the given class.
*
* @param classDoc the class the summary belongs to.
*/
public void writeMemberSummaryHeader(ClassDoc classDoc) {
writer.println("<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->");
writer.println();
writer.printSummaryHeader(this, classDoc);
}
/**
* Write the annotation type member summary footer for the given class.
*
* @param classDoc the class the summary belongs to.
* {@inheritDoc}
*/
public void writeMemberSummaryFooter(ClassDoc classDoc) {
writer.printSummaryFooter(this, classDoc);
public Content getMemberSummaryHeader(ClassDoc classDoc,
Content memberSummaryTree) {
memberSummaryTree.addContent(
HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, classDoc, memberTree);
return memberTree;
}
/**
* {@inheritDoc}
*/
public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
//Not appliable.
public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
Content memberDetailsTree) {
if (!writer.printedAnnotationHeading) {
memberDetailsTree.addContent(writer.getMarkerAnchor(
"annotation_type_element_detail"));
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
writer.annotationTypeDetailsLabel);
memberDetailsTree.addContent(heading);
writer.printedAnnotationHeading = true;
}
}
/**
* {@inheritDoc}
*/
public void writeInheritedMemberSummary(ClassDoc classDoc,
ProgramElementDoc member, boolean isFirst, boolean isLast) {
//Not appliable.
public Content getAnnotationDocTreeHeader(MemberDoc member,
Content annotationDetailsTree) {
annotationDetailsTree.addContent(
writer.getMarkerAnchor(member.name() +
((ExecutableMemberDoc) member).signature()));
Content annotationDocTree = writer.getMemberTreeHeader();
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
heading.addContent(member.name());
annotationDocTree.addContent(heading);
return annotationDocTree;
}
/**
* {@inheritDoc}
*/
public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
//Not appliable.
public Content getSignature(MemberDoc member) {
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(member, pre);
addModifiers(member, pre);
Content link = new RawHtml(
writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
getType(member))));
pre.addContent(link);
pre.addContent(writer.getSpace());
if (configuration().linksource) {
Content memberName = new StringContent(member.name());
writer.addSrcLink(member, memberName, pre);
} else {
addName(member.name(), pre);
}
return pre;
}
/**
* {@inheritDoc}
*/
public void writeHeader(ClassDoc classDoc, String header) {
writer.println();
writer.println("<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->");
writer.println();
writer.anchor("annotation_type_element_detail");
writer.printTableHeadingBackground(header);
writer.println();
public void addDeprecated(MemberDoc member, Content annotationDocTree) {
addDeprecatedInfo(member, annotationDocTree);
}
/**
* {@inheritDoc}
*/
public void writeMemberHeader(MemberDoc member, boolean isFirst) {
if (! isFirst) {
writer.printMemberHeader();
writer.println("");
}
writer.anchor(member.name() + ((ExecutableMemberDoc) member).signature());
writer.h3();
writer.print(member.name());
writer.h3End();
public void addComments(MemberDoc member, Content annotationDocTree) {
addComment(member, annotationDocTree);
}
/**
* {@inheritDoc}
*/
public void writeSignature(MemberDoc member) {
writer.pre();
writer.writeAnnotationInfo(member);
printModifiers(member);
writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
getType(member)));
print(' ');
if (configuration().linksource) {
writer.printSrcLink(member, member.name());
} else {
strong(member.name());
}
writer.preEnd();
assert !writer.getMemberDetailsListPrinted();
public void addTags(MemberDoc member, Content annotationDocTree) {
writer.addTagsInfo(member, annotationDocTree);
}
/**
* {@inheritDoc}
*/
public void writeComments(MemberDoc member) {
printComment(member);
public Content getAnnotationDetails(Content annotationDetailsTree) {
return getMemberTree(annotationDetailsTree);
}
/**
* Write the tag output for the given member.
*
* @param member the member being documented.
* {@inheritDoc}
*/
public void writeTags(MemberDoc member) {
writer.printTags(member);
public Content getAnnotationDoc(Content annotationDocTree,
boolean isLastContent) {
return getMemberTree(annotationDocTree, isLastContent);
}
/**
* Write the annotation type member footer.
* Close the writer.
*/
public void writeMemberFooter() {
printMemberFooter();
public void close() throws IOException {
writer.close();
}
/**
* Write the footer for the annotation type member documentation.
*
* @param classDoc the class that the annotation type member belong to.
* {@inheritDoc}
*/
public void writeFooter(ClassDoc classDoc) {
//No footer to write for annotation type member documentation
public void addSummaryLabel(Content memberTree) {
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
memberTree.addContent(label);
}
/**
* Close the writer.
* {@inheritDoc}
*/
public void close() throws IOException {
writer.close();
public String getTableSummary() {
return configuration().getText("doclet.Member_Table_Summary",
configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
configuration().getText("doclet.annotation_type_required_members"));
}
/**
* {@inheritDoc}
*/
public void printSummaryLabel() {
writer.printText("doclet.Annotation_Type_Required_Member_Summary");
public String getCaption() {
return configuration().getText("doclet.Annotation_Type_Required_Members");
}
/**
* {@inheritDoc}
*/
public void printTableSummary() {
writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
configuration().getText("doclet.annotation_type_required_members")));
}
public void printSummaryTableHeader(ProgramElementDoc member) {
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
configuration().getText("doclet.0_and_1",
configuration().getText("doclet.Annotation_Type_Required_Member"),
configuration().getText("doclet.Description"))
};
writer.summaryTableHeader(header, "col");
return header;
}
/**
* {@inheritDoc}
*/
public void printSummaryAnchor(ClassDoc cd) {
writer.anchor("annotation_type_required_element_summary");
public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
memberTree.addContent(writer.getMarkerAnchor(
"annotation_type_required_element_summary"));
}
/**
* {@inheritDoc}
*/
public void printInheritedSummaryAnchor(ClassDoc cd) {
} // no such
public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
}
/**
* {@inheritDoc}
*/
public void printInheritedSummaryLabel(ClassDoc cd) {
// no such
public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
}
/**
* {@inheritDoc}
*/
protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
writer.strong();
writer.printDocLink(context, (MemberDoc) member, member.name(), false);
writer.strongEnd();
protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
}
/**
* {@inheritDoc}
*/
protected void writeInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member) {
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
//Not applicable.
}
/**
* {@inheritDoc}
*/
protected void printSummaryType(ProgramElementDoc member) {
protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
MemberDoc m = (MemberDoc)member;
printModifierAndType(m, getType(m));
addModifierAndType(m, getType(m), tdSummaryType);
}
/**
* {@inheritDoc}
*/
protected void writeDeprecatedLink(ProgramElementDoc member) {
writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
(MemberDoc) member, ((MemberDoc)member).qualifiedName(), false);
protected Content getDeprecatedLink(ProgramElementDoc member) {
return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
(MemberDoc) member, ((MemberDoc)member).qualifiedName());
}
/**
* {@inheritDoc}
*/
protected void printNavSummaryLink(ClassDoc cd, boolean link) {
protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
if (link) {
writer.printHyperLink("", "annotation_type_required_element_summary",
configuration().getText("doclet.navAnnotationTypeRequiredMember"));
return writer.getHyperLink("", "annotation_type_required_element_summary",
writer.getResource("doclet.navAnnotationTypeRequiredMember"));
} else {
writer.printText("doclet.navAnnotationTypeRequiredMember");
return writer.getResource("doclet.navAnnotationTypeRequiredMember");
}
}
/**
* {@inheritDoc}
*/
protected void printNavDetailLink(boolean link) {
protected void addNavDetailLink(boolean link, Content liNav) {
if (link) {
writer.printHyperLink("", "annotation_type_element_detail",
configuration().getText("doclet.navAnnotationTypeMember"));
liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail",
writer.getResource("doclet.navAnnotationTypeMember")));
} else {
writer.printText("doclet.navAnnotationTypeMember");
liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
}
}
/**
* {@inheritDoc}
*/
public void writeDeprecated(MemberDoc member) {
printDeprecated(member);
}
private Type getType(MemberDoc member) {
if (member instanceof FieldDoc) {
return ((FieldDoc) member).type();
......
......@@ -29,6 +29,7 @@ import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.internal.toolkit.builders.*;
import com.sun.tools.doclets.formats.html.markup.*;
/**
* Generate the Class Information Page.
......@@ -40,6 +41,7 @@ import com.sun.tools.doclets.internal.toolkit.builders.*;
*
* @author Atul M Dambalkar
* @author Robert Field
* @author Bhavesh Patel (Modified)
*/
public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
implements AnnotationTypeWriter {
......@@ -69,126 +71,168 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
}
/**
* Print this package link
* Get this package link.
*
* @return a content tree for the package link
*/
protected void navLinkPackage() {
navCellStart();
printHyperLink("package-summary.html", "",
configuration.getText("doclet.Package"), true, "NavBarFont1");
navCellEnd();
protected Content getNavLinkPackage() {
Content linkContent = getHyperLink("package-summary.html", "",
packageLabel);
Content li = HtmlTree.LI(linkContent);
return li;
}
/**
* Print class page indicator
* Get the class link.
*
* @return a content tree for the class link
*/
protected void navLinkClass() {
navCellRevStart();
fontStyle("NavBarFont1Rev");
strongText("doclet.Class");
fontEnd();
navCellEnd();
protected Content getNavLinkClass() {
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
return li;
}
/**
* Print class use link
* Get the class use link.
*
* @return a content tree for the class use link
*/
protected void navLinkClassUse() {
navCellStart();
printHyperLink("class-use/" + filename, "",
configuration.getText("doclet.navClassUse"), true, "NavBarFont1");
navCellEnd();
protected Content getNavLinkClassUse() {
Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
Content li = HtmlTree.LI(linkContent);
return li;
}
/**
* Print previous package link
* Get link to previous class.
*
* @return a content tree for the previous class link
*/
protected void navLinkPrevious() {
if (prev == null) {
printText("doclet.Prev_Class");
} else {
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
prev.asClassDoc(), "",
configuration.getText("doclet.Prev_Class"), true));
public Content getNavLinkPrevious() {
Content li;
if (prev != null) {
Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "",
configuration.getText("doclet.Prev_Class"), true)));
li = HtmlTree.LI(prevLink);
}
else
li = HtmlTree.LI(prevclassLabel);
return li;
}
/**
* Print next package link
* Get link to next class.
*
* @return a content tree for the next class link
*/
protected void navLinkNext() {
if (next == null) {
printText("doclet.Next_Class");
} else {
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
next.asClassDoc(), "",
configuration.getText("doclet.Next_Class"), true));
public Content getNavLinkNext() {
Content li;
if (next != null) {
Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "",
configuration.getText("doclet.Next_Class"), true)));
li = HtmlTree.LI(nextLink);
}
else
li = HtmlTree.LI(nextclassLabel);
return li;
}
/**
* {@inheritDoc}
*/
public void writeHeader(String header) {
public Content getHeader(String header) {
String pkgname = (annotationType.containingPackage() != null)?
annotationType.containingPackage().name(): "";
String clname = annotationType.name();
printHtmlHeader(clname,
configuration.metakeywords.getMetaKeywords(annotationType), true);
printTop();
navLinks(true);
hr();
println("<!-- ======== START OF CLASS DATA ======== -->");
h2();
Content bodyTree = getBody(true, getWindowTitle(clname));
addTop(bodyTree);
addNavLinks(true, bodyTree);
bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.addStyle(HtmlStyle.header);
if (pkgname.length() > 0) {
font("-1"); print(pkgname); fontEnd(); br();
Content pkgNameContent = new StringContent(pkgname);
Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent);
div.addContent(pkgNamePara);
}
print(header + getTypeParameterLinks(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS_HEADER,
annotationType, false)));
h2End();
LinkInfoImpl linkInfo = new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
Content headerContent = new StringContent(header);
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
HtmlStyle.title, headerContent);
heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
div.addContent(heading);
bodyTree.addContent(div);
return bodyTree;
}
/**
* {@inheritDoc}
*/
public Content getAnnotationContentHeader() {
return getContentHeader();
}
/**
* {@inheritDoc}
*/
public void addFooter(Content contentTree) {
contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
addNavLinks(false, contentTree);
addBottom(contentTree);
}
/**
* {@inheritDoc}
*/
public void writeFooter() {
println("<!-- ========= END OF CLASS DATA ========= -->");
hr();
navLinks(false);
printBottom();
printBodyHtmlEnd();
public void printDocument(Content contentTree) {
printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
true, contentTree);
}
/**
* {@inheritDoc}
*/
public void writeAnnotationTypeSignature(String modifiers) {
preNoNewLine();
writeAnnotationInfo(annotationType);
print(modifiers);
String name = annotationType.name() +
getTypeParameterLinks(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false));
public Content getAnnotationInfoTreeHeader() {
return getMemberTreeHeader();
}
/**
* {@inheritDoc}
*/
public Content getAnnotationInfo(Content annotationInfoTree) {
return getMemberTree(HtmlStyle.description, annotationInfoTree);
}
/**
* {@inheritDoc}
*/
public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
Content pre = new HtmlTree(HtmlTag.PRE);
addAnnotationInfo(annotationType, pre);
pre.addContent(modifiers);
LinkInfoImpl linkInfo = new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
Content name = new RawHtml (annotationType.name() +
getTypeParameterLinks(linkInfo));
if (configuration().linksource) {
printSrcLink(annotationType, name);
addSrcLink(annotationType, name, pre);
} else {
strong(name);
pre.addContent(HtmlTree.STRONG(name));
}
preEnd();
p();
annotationInfoTree.addContent(pre);
}
/**
* {@inheritDoc}
*/
public void writeAnnotationTypeDescription() {
public void addAnnotationTypeDescription(Content annotationInfoTree) {
if(!configuration.nocomment) {
// generate documentation for the class.
if (annotationType.inlineTags().length > 0) {
printInlineComment(annotationType);
p();
addInlineComment(annotationType, annotationInfoTree);
}
}
}
......@@ -196,148 +240,152 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
/**
* {@inheritDoc}
*/
public void writeAnnotationTypeTagInfo() {
boolean needHr = annotationType.elements().length > 0;
public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
if(!configuration.nocomment) {
// Print Information about all the tags here
printTags(annotationType);
if (needHr) {
hr();
}
p();
} else if (needHr) {
hr();
addTagsInfo(annotationType, annotationInfoTree);
}
}
/**
* {@inheritDoc}
*/
public void writeAnnotationTypeDeprecationInfo() {
hr();
public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
Content hr = new HtmlTree(HtmlTag.HR);
annotationInfoTree.addContent(hr);
Tag[] deprs = annotationType.tags("deprecated");
if (Util.isDeprecated(annotationType)) {
strongText("doclet.Deprecated");
Content strong = HtmlTree.STRONG(deprecatedPhrase);
Content div = HtmlTree.DIV(HtmlStyle.block, strong);
if (deprs.length > 0) {
Tag[] commentTags = deprs[0].inlineTags();
if (commentTags.length > 0) {
space();
printInlineDeprecatedComment(annotationType, deprs[0]);
div.addContent(getSpace());
addInlineDeprecatedComment(annotationType, deprs[0], div);
}
}
p();
annotationInfoTree.addContent(div);
}
}
protected void navLinkTree() {
navCellStart();
printHyperLink("package-tree.html", "",
configuration.getText("doclet.Tree"), true, "NavBarFont1");
navCellEnd();
/**
* {@inheritDoc}
*/
public void addAnnotationDetailsMarker(Content memberDetails) {
memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
}
protected void printSummaryDetailLinks() {
try {
tr();
tdVAlignClass("top", "NavBarCell3");
font("-2");
print(" ");
navSummaryLinks();
fontEnd();
tdEnd();
/**
* {@inheritDoc}
*/
protected Content getNavLinkTree() {
Content treeLinkContent = getHyperLink("package-tree.html",
"", treeLabel, "", "");
Content li = HtmlTree.LI(treeLinkContent);
return li;
}
tdVAlignClass("top", "NavBarCell3");
font("-2");
navDetailLinks();
fontEnd();
tdEnd();
trEnd();
/**
* Add summary details to the navigation bar.
*
* @param subDiv the content tree to which the summary detail links will be added
*/
protected void addSummaryDetailLinks(Content subDiv) {
try {
Content div = HtmlTree.DIV(getNavSummaryLinks());
div.addContent(getNavDetailLinks());
subDiv.addContent(div);
} catch (Exception e) {
e.printStackTrace();
throw new DocletAbortException();
}
}
protected void navSummaryLinks() throws Exception {
printText("doclet.Summary");
space();
/**
* Get summary links for navigation bar.
*
* @return the content tree for the navigation summary links
*/
protected Content getNavSummaryLinks() throws Exception {
Content li = HtmlTree.LI(summaryLabel);
li.addContent(getSpace());
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
writeNavSummaryLink(memberSummaryBuilder,
"doclet.navAnnotationTypeRequiredMember",
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
navGap();
writeNavSummaryLink(memberSummaryBuilder,
"doclet.navAnnotationTypeOptionalMember",
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
Content liNavReq = new HtmlTree(HtmlTag.LI);
addNavSummaryLink(memberSummaryBuilder,
"doclet.navAnnotationTypeRequiredMember",
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
addNavGap(liNavReq);
ulNav.addContent(liNavReq);
Content liNavOpt = new HtmlTree(HtmlTag.LI);
addNavSummaryLink(memberSummaryBuilder,
"doclet.navAnnotationTypeOptionalMember",
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
ulNav.addContent(liNavOpt);
return ulNav;
}
private void writeNavSummaryLink(MemberSummaryBuilder builder,
String label, int type) {
/**
* Add the navigation summary link.
*
* @param builder builder for the member to be documented
* @param label the label for the navigation
* @param type type to be documented
* @param liNav the content tree to which the navigation summary link will be added
*/
protected void addNavSummaryLink(MemberSummaryBuilder builder,
String label, int type, Content liNav) {
AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
getMemberSummaryWriter(type));
getMemberSummaryWriter(type));
if (writer == null) {
printText(label);
liNav.addContent(getResource(label));
} else {
writer.printNavSummaryLink(null,
! builder.getVisibleMemberMap(type).noVisibleMembers());
liNav.addContent(writer.getNavSummaryLink(null,
! builder.getVisibleMemberMap(type).noVisibleMembers()));
}
}
/**
* Method navDetailLinks
*
* @throws Exception
* Get detail links for the navigation bar.
*
* @return the content tree for the detail links
*/
protected void navDetailLinks() throws Exception {
printText("doclet.Detail");
space();
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);
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
AbstractMemberWriter writerOptional =
((AbstractMemberWriter) memberSummaryBuilder.
((AbstractMemberWriter) memberSummaryBuilder.
getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL));
AbstractMemberWriter writerRequired =
((AbstractMemberWriter) memberSummaryBuilder.
((AbstractMemberWriter) memberSummaryBuilder.
getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED));
if (writerOptional != null){
writerOptional.printNavDetailLink(annotationType.elements().length > 0);
Content liNavOpt = new HtmlTree(HtmlTag.LI);
writerOptional.addNavDetailLink(annotationType.elements().length > 0, liNavOpt);
ulNav.addContent(liNavOpt);
} else if (writerRequired != null){
writerRequired.printNavDetailLink(annotationType.elements().length > 0);
Content liNavReq = new HtmlTree(HtmlTag.LI);
writerRequired.addNavDetailLink(annotationType.elements().length > 0, liNavReq);
ulNav.addContent(liNavReq);
} else {
printText("doclet.navAnnotationTypeMember");
Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
ulNav.addContent(liNav);
}
}
protected void navGap() {
space();
print('|');
space();
return ulNav;
}
/**
* If this is an inner class or interface, write the enclosing class or
* interface.
* Add gap between navigation bar elements.
*
* @param liNav the content tree to which the gap will be added
*/
public void writeNestedClassInfo() {
ClassDoc outerClass = annotationType.containingClass();
if (outerClass != null) {
dl();
dt();
if (annotationType.isInterface()) {
strongText("doclet.Enclosing_Interface");
} else {
strongText("doclet.Enclosing_Class");
}
dtEnd();
dd();
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
false));
ddEnd();
dlEnd();
}
protected void addNavGap(Content liNav) {
liNav.addContent(getSpace());
liNav.addContent("|");
liNav.addContent(getSpace());
}
/**
......@@ -346,11 +394,4 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
public AnnotationTypeDoc getAnnotationTypeDoc() {
return annotationType;
}
/**
* {@inheritDoc}
*/
public void completeMemberSummaryBuild() {
p();
}
}
......@@ -25,11 +25,12 @@
package com.sun.tools.doclets.formats.html;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.javadoc.*;
import java.io.*;
import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.formats.html.markup.*;
/**
* Write the Constants Summary Page in HTML format.
......@@ -76,67 +77,106 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
/**
* {@inheritDoc}
*/
public void writeHeader() {
printHtmlHeader(configuration.getText("doclet.Constants_Summary"),
null, true);
printTop();
navLinks(true);
hr();
center();
h1(); printText("doclet.Constants_Summary"); h1End();
centerEnd();
public Content getHeader() {
String label = configuration.getText("doclet.Constants_Summary");
Content bodyTree = getBody(true, getWindowTitle(label));
addTop(bodyTree);
addNavLinks(true, bodyTree);
return bodyTree;
}
hr(4, "noshade");
/**
* {@inheritDoc}
*/
public Content getContentsHeader() {
return new HtmlTree(HtmlTag.UL);
}
/**
* {@inheritDoc}
*/
public void writeFooter() {
hr();
navLinks(false);
printBottom();
printBodyHtmlEnd();
public void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
Set<String> printedPackageHeaders, Content contentListTree) {
String packageName = pkg.name();
//add link to summary
Content link;
if (packageName.length() == 0) {
link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
"", defaultPackageLabel, "", "");
} else {
Content packageNameContent = getPackageLabel(parsedPackageName);
packageNameContent.addContent(".*");
link = getHyperLink("#" + parsedPackageName,
"", packageNameContent, "", "");
printedPackageHeaders.add(parsedPackageName);
}
contentListTree.addContent(HtmlTree.LI(link));
}
/**
* {@inheritDoc}
*/
public void writeContentsHeader() {
strong(configuration.getText("doclet.Contents"));
ul();
public Content getContentsList(Content contentListTree) {
Content titleContent = getResource(
"doclet.Constants_Summary");
Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.title, titleContent);
Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
Content headingContent = getResource(
"doclet.Contents");
div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
headingContent));
div.addContent(contentListTree);
return div;
}
/**
* {@inheritDoc}
*/
public void writeContentsFooter() {
ulEnd();
println();
public Content getConstantSummaries() {
HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
return summariesDiv;
}
/**
* {@inheritDoc}
*/
public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set<String> printedPackageHeaders) {
String packageName = pkg.name();
//add link to summary
li();
if (packageName.length() == 0) {
printHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
DocletConstants.DEFAULT_PACKAGE_NAME);
public void addPackageName(PackageDoc pkg, String parsedPackageName,
Content summariesTree) {
Content pkgNameContent;
if (parsedPackageName.length() == 0) {
summariesTree.addContent(getMarkerAnchor(
DocletConstants.UNNAMED_PACKAGE_ANCHOR));
pkgNameContent = defaultPackageLabel;
} else {
printHyperLink("#" + parsedPackageName, parsedPackageName + ".*");
printedPackageHeaders.add(parsedPackageName);
summariesTree.addContent(getMarkerAnchor(
parsedPackageName));
pkgNameContent = getPackageLabel(parsedPackageName);
}
println();
Content headingContent = new StringContent(".*");
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
pkgNameContent);
heading.addContent(headingContent);
summariesTree.addContent(heading);
}
/**
* {@inheritDoc}
*/
public void writeConstantMembersHeader(ClassDoc cd) {
public Content getClassConstantHeader() {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addStyle(HtmlStyle.blockList);
return ul;
}
/**
* Get the table caption and header for the constant summary table
*
* @param cd classdoc to be documented
* @return constant members header content
*/
public Content getConstantMembersHeader(ClassDoc cd) {
//generate links backward only to public classes.
String classlink = (cd.isPublic() || cd.isProtected())?
getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
......@@ -144,112 +184,120 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
cd.qualifiedName();
String name = cd.containingPackage().name();
if (name.length() > 0) {
writeClassName(name + "." + classlink);
return getClassName(name + "." + classlink);
} else {
writeClassName(classlink);
return getClassName(classlink);
}
}
/**
* Get the class name in the table caption and the table header.
*
* @param classStr the class name to print.
* @return the table caption and header
*/
protected Content getClassName(String classStr) {
Content table = HtmlTree.TABLE(0, 3, 0, constantsTableSummary,
getTableCaption(classStr));
table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
return table;
}
/**
* {@inheritDoc}
*/
public void writeConstantMembersFooter(ClassDoc cd) {
tableFooter(false);
p();
public void addConstantMembers(ClassDoc cd, List<FieldDoc> fields,
Content classConstantTree) {
currentClassDoc = cd;
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < fields.size(); ++i) {
HtmlTree tr = new HtmlTree(HtmlTag.TR);
if (i%2 == 0)
tr.addStyle(HtmlStyle.altColor);
else
tr.addStyle(HtmlStyle.rowColor);
addConstantMember(fields.get(i), tr);
tbody.addContent(tr);
}
Content table = getConstantMembersHeader(cd);
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
classConstantTree.addContent(li);
}
/**
* Print the class name in the table heading.
* @param classStr the heading to print.
* Add the row for the constant summary table.
*
* @param member the field to be documented.
* @param trTree an htmltree object for the table row
*/
protected void writeClassName(String classStr) {
table(1, 3, 0, constantsTableSummary);
tableSubCaptionStart();
write(classStr);
tableCaptionEnd();
summaryTableHeader(constantsTableHeader, "col");
private void addConstantMember(FieldDoc member, HtmlTree trTree) {
trTree.addContent(getTypeColumn(member));
trTree.addContent(getNameColumn(member));
trTree.addContent(getValue(member));
}
private void tableFooter(boolean isHeader) {
fontEnd();
if (isHeader) {
thEnd();
} else {
tdEnd();
/**
* Get the type column for the constant summary table row.
*
* @param member the field to be documented.
* @return the type column of the constant table row
*/
private Content getTypeColumn(FieldDoc member) {
Content anchor = getMarkerAnchor(currentClassDoc.qualifiedName() +
"." + member.name());
Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
Content code = new HtmlTree(HtmlTag.CODE);
StringTokenizer mods = new StringTokenizer(member.modifiers());
while(mods.hasMoreTokens()) {
Content modifier = new StringContent(mods.nextToken());
code.addContent(modifier);
code.addContent(getSpace());
}
trEnd();
tableEnd();
p();
Content type = new RawHtml(getLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
code.addContent(type);
tdType.addContent(code);
return tdType;
}
/**
* {@inheritDoc}
* Get the name column for the constant summary table row.
*
* @param member the field to be documented.
* @return the name column of the constant table row
*/
public void writePackageName(PackageDoc pkg, String parsedPackageName) {
String pkgname;
if (parsedPackageName.length() == 0) {
anchor(DocletConstants.UNNAMED_PACKAGE_ANCHOR);
pkgname = DocletConstants.DEFAULT_PACKAGE_NAME;
} else {
anchor(parsedPackageName);
pkgname = parsedPackageName;
}
table(1, "100%", 3, 0);
trBgcolorStyle("#CCCCFF", "TableHeadingColor");
thAlign("left");
font("+2");
write(pkgname + ".*");
tableFooter(true);
private Content getNameColumn(FieldDoc member) {
Content nameContent = new RawHtml(getDocLink(
LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member, member.name(), false));
Content code = HtmlTree.CODE(nameContent);
return HtmlTree.TD(code);
}
/**
* {@inheritDoc}
* Get the value column for the constant summary table row.
*
* @param member the field to be documented.
* @return the value column of the constant table row
*/
public void writeConstantMembers(ClassDoc cd, List<FieldDoc> fields) {
currentClassDoc = cd;
for (int i = 0; i < fields.size(); ++i) {
writeConstantMember(fields.get(i));
}
private Content getValue(FieldDoc member) {
Content valueContent = new StringContent(member.constantValueExpression());
Content code = HtmlTree.CODE(valueContent);
return HtmlTree.TD(HtmlStyle.colLast, code);
}
private void writeConstantMember(FieldDoc member) {
trBgcolorStyle("white", "TableRowColor");
anchor(currentClassDoc.qualifiedName() + "." + member.name());
writeTypeColumn(member);
writeNameColumn(member);
writeValue(member);
trEnd();
/**
* {@inheritDoc}
*/
public void addFooter(Content contentTree) {
addNavLinks(false, contentTree);
addBottom(contentTree);
}
private void writeTypeColumn(FieldDoc member) {
tdAlign("right");
font("-1");
code();
StringTokenizer mods = new StringTokenizer(member.modifiers());
while(mods.hasMoreTokens()) {
print(mods.nextToken() + "&nbsp;");
}
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY,
member.type()));
codeEnd();
fontEnd();
tdEnd();
}
private void writeNameColumn(FieldDoc member) {
tdAlign("left");
code();
printDocLink(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member,
member.name(), false);
codeEnd();
tdEnd();
}
private void writeValue(FieldDoc member) {
tdAlign("right");
code();
print(Util.escapeHtmlChars(member.constantValueExpression()));
codeEnd();
tdEnd();
/**
* {@inheritDoc}
*/
public void printDocument(Content contentTree) {
printHtmlDocument(null, true, contentTree);
}
}
......@@ -29,6 +29,7 @@ import java.io.*;
import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
......@@ -43,7 +44,6 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
implements ConstructorWriter, MemberSummaryWriter {
private boolean foundNonPubConstructor = false;
private boolean printedSummaryHeader = false;
/**
* Construct a new ConstructorWriterImpl.
......@@ -75,125 +75,112 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
}
/**
* Write the constructors summary header for the given class.
*
* @param classDoc the class the summary belongs to.
*/
public void writeMemberSummaryHeader(ClassDoc classDoc) {
printedSummaryHeader = true;
writer.println();
writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->");
writer.println();
writer.printSummaryHeader(this, classDoc);
}
/**
* Write the constructors summary footer for the given class.
*
* @param classDoc the class the summary belongs to.
* {@inheritDoc}
*/
public void writeMemberSummaryFooter(ClassDoc classDoc) {
writer.printSummaryFooter(this, classDoc);
public Content getMemberSummaryHeader(ClassDoc classDoc,
Content memberSummaryTree) {
memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, classDoc, memberTree);
return memberTree;
}
/**
* Write the header for the constructor documentation.
*
* @param classDoc the class that the constructors belong to.
* {@inheritDoc}
*/
public void writeHeader(ClassDoc classDoc, String header) {
writer.println();
writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->");
writer.println();
writer.anchor("constructor_detail");
writer.printTableHeadingBackground(header);
public Content getConstructorDetailsTreeHeader(ClassDoc classDoc,
Content memberDetailsTree) {
memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS);
Content constructorDetailsTree = writer.getMemberTreeHeader();
constructorDetailsTree.addContent(writer.getMarkerAnchor("constructor_detail"));
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
writer.constructorDetailsLabel);
constructorDetailsTree.addContent(heading);
return constructorDetailsTree;
}
/**
* Write the constructor header for the given constructor.
*
* @param constructor the constructor being documented.
* @param isFirst the flag to indicate whether or not the constructor is the
* first to be documented.
* {@inheritDoc}
*/
public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) {
if (! isFirst) {
writer.printMemberHeader();
}
writer.println();
public Content getConstructorDocTreeHeader(ConstructorDoc constructor,
Content constructorDetailsTree) {
String erasureAnchor;
if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
writer.anchor(erasureAnchor);
constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
}
writer.anchor(constructor);
writer.h3();
writer.print(constructor.name());
writer.h3End();
constructorDetailsTree.addContent(
writer.getMarkerAnchor(writer.getAnchor(constructor)));
Content constructorDocTree = writer.getMemberTreeHeader();
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
heading.addContent(constructor.name());
constructorDocTree.addContent(heading);
return constructorDocTree;
}
/**
* Write the signature for the given constructor.
*
* @param constructor the constructor being documented.
* {@inheritDoc}
*/
public void writeSignature(ConstructorDoc constructor) {
public Content getSignature(ConstructorDoc constructor) {
writer.displayLength = 0;
writer.pre();
writer.writeAnnotationInfo(constructor);
printModifiers(constructor);
//printReturnType((ConstructorDoc)constructor);
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(constructor, pre);
addModifiers(constructor, pre);
if (configuration().linksource) {
writer.printSrcLink(constructor, constructor.name());
Content constructorName = new StringContent(constructor.name());
writer.addSrcLink(constructor, constructorName, pre);
} else {
strong(constructor.name());
addName(constructor.name(), pre);
}
writeParameters(constructor);
writeExceptions(constructor);
writer.preEnd();
assert !writer.getMemberDetailsListPrinted();
addParameters(constructor, pre);
addExceptions(constructor, pre);
return pre;
}
/**
* Write the deprecated output for the given constructor.
*
* @param constructor the constructor being documented.
* {@inheritDoc}
*/
public void writeDeprecated(ConstructorDoc constructor) {
printDeprecated(constructor);
@Override
public void setSummaryColumnStyle(HtmlTree tdTree) {
if (foundNonPubConstructor)
tdTree.addStyle(HtmlStyle.colLast);
else
tdTree.addStyle(HtmlStyle.colOne);
}
/**
* Write the comments for the given constructor.
*
* @param constructor the constructor being documented.
* {@inheritDoc}
*/
public void writeComments(ConstructorDoc constructor) {
printComment(constructor);
public void addDeprecated(ConstructorDoc constructor, Content constructorDocTree) {
addDeprecatedInfo(constructor, constructorDocTree);
}
/**
* Write the tag output for the given constructor.
*
* @param constructor the constructor being documented.
* {@inheritDoc}
*/
public void writeTags(ConstructorDoc constructor) {
writer.printTags(constructor);
public void addComments(ConstructorDoc constructor, Content constructorDocTree) {
addComment(constructor, constructorDocTree);
}
/**
* Write the constructor footer.
* {@inheritDoc}
*/
public void writeConstructorFooter() {
printMemberFooter();
public void addTags(ConstructorDoc constructor, Content constructorDocTree) {
writer.addTagsInfo(constructor, constructorDocTree);
}
/**
* Write the footer for the constructor documentation.
*
* @param classDoc the class that the constructors belong to.
* {@inheritDoc}
*/
public Content getConstructorDetails(Content constructorDetailsTree) {
return getMemberTree(constructorDetailsTree);
}
/**
* {@inheritDoc}
*/
public void writeFooter(ClassDoc classDoc) {
//No footer to write for constructor documentation
public Content getConstructorDoc(Content constructorDocTree,
boolean isLastContent) {
return getMemberTree(constructorDocTree, isLastContent);
}
/**
......@@ -212,17 +199,35 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
this.foundNonPubConstructor = foundNonPubConstructor;
}
public void printSummaryLabel() {
writer.printText("doclet.Constructor_Summary");
/**
* {@inheritDoc}
*/
public void addSummaryLabel(Content memberTree) {
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
writer.getResource("doclet.Constructor_Summary"));
memberTree.addContent(label);
}
public void printTableSummary() {
writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
/**
* {@inheritDoc}
*/
public String getTableSummary() {
return configuration().getText("doclet.Member_Table_Summary",
configuration().getText("doclet.Constructor_Summary"),
configuration().getText("doclet.constructors")));
configuration().getText("doclet.constructors"));
}
/**
* {@inheritDoc}
*/
public String getCaption() {
return configuration().getText("doclet.Constructors");
}
public void printSummaryTableHeader(ProgramElementDoc member) {
/**
* {@inheritDoc}
*/
public String[] getSummaryTableHeader(ProgramElementDoc member) {
String[] header;
if (foundNonPubConstructor) {
header = new String[] {
......@@ -239,87 +244,73 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
configuration().getText("doclet.Description"))
};
}
writer.summaryTableHeader(header, "col");
return header;
}
public void printSummaryAnchor(ClassDoc cd) {
writer.anchor("constructor_summary");
/**
* {@inheritDoc}
*/
public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
memberTree.addContent(writer.getMarkerAnchor("constructor_summary"));
}
public void printInheritedSummaryAnchor(ClassDoc cd) {
} // no such
/**
* {@inheritDoc}
*/
public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
}
public void printInheritedSummaryLabel(ClassDoc cd) {
// no such
/**
* {@inheritDoc}
*/
public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
}
public int getMemberKind() {
return VisibleMemberMap.CONSTRUCTORS;
}
protected void navSummaryLink(List<?> members) {
printNavSummaryLink(classdoc,
members.size() > 0? true: false);
}
protected void printNavSummaryLink(ClassDoc cd, boolean link) {
/**
* {@inheritDoc}
*/
protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
if (link) {
writer.printHyperLink("", "constructor_summary",
ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
return writer.getHyperLink("", "constructor_summary",
writer.getResource("doclet.navConstructor"));
} else {
writer.printText("doclet.navConstructor");
return writer.getResource("doclet.navConstructor");
}
}
protected void printNavDetailLink(boolean link) {
/**
* {@inheritDoc}
*/
protected void addNavDetailLink(boolean link, Content liNav) {
if (link) {
writer.printHyperLink("", "constructor_detail",
ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
liNav.addContent(writer.getHyperLink("", "constructor_detail",
writer.getResource("doclet.navConstructor")));
} else {
writer.printText("doclet.navConstructor");
liNav.addContent(writer.getResource("doclet.navConstructor"));
}
}
protected void printSummaryType(ProgramElementDoc member) {
/**
* {@inheritDoc}
*/
protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
if (foundNonPubConstructor) {
writer.printTypeSummaryHeader();
Content code = new HtmlTree(HtmlTag.CODE);
if (member.isProtected()) {
print("protected ");
code.addContent("protected ");
} else if (member.isPrivate()) {
print("private ");
code.addContent("private ");
} else if (member.isPublic()) {
writer.space();
code.addContent(writer.getSpace());
} else {
writer.printText("doclet.Package_private");
code.addContent(
configuration().getText("doclet.Package_private"));
}
writer.printTypeSummaryFooter();
tdSummaryType.addContent(code);
}
}
/**
* Write the inherited member summary header for the given class.
*
* @param classDoc the class the summary belongs to.
*/
public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
if(! printedSummaryHeader){
//We don't want inherited summary to not be under heading.
writeMemberSummaryHeader(classDoc);
writeMemberSummaryFooter(classDoc);
printedSummaryHeader = true;
}
}
/**
* {@inheritDoc}
*/
public void writeInheritedMemberSummary(ClassDoc classDoc,
ProgramElementDoc member, boolean isFirst, boolean isLast) {}
/**
* Write the inherited member summary footer for the given class.
*
* @param classDoc the class the summary belongs to.
*/
public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册