Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8240138: Cleanup HtmlTree
Reviewed-by: prappo
  • Loading branch information
jonathan-gibbons committed Mar 11, 2020
1 parent 6b487c3 commit 5b9a09cb9c811a740237ba2d9296b06e265e2c48
Showing with 421 additions and 527 deletions.
  1. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
  2. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java
  3. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java
  4. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java
  5. +1 −1 ...avadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java
  6. +1 −1 ...are/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
  7. +1 −1 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java
  8. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java
  9. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
  10. +3 −3 ...k.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java
  11. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java
  12. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
  13. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java
  14. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java
  15. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java
  16. +0 −24 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
  17. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
  18. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
  19. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java
  20. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java
  21. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java
  22. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java
  23. +2 −2 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
  24. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SystemPropertiesWriter.java
  25. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
  26. +2 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java
  27. +3 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java
  28. +1 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTag.java
  29. +381 −453 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
  30. +4 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java
  31. +1 −12 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java
@@ -177,7 +177,7 @@ protected void addContents(Character uc, List<? extends Element> memberlist,
protected void addHeading(Character uc, Content contentTree) {
String unicode = uc.toString();
Content headContent = new StringContent(unicode);
HtmlTree heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, false,
HtmlTree heading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
HtmlStyle.title, headContent);
heading.setId(getNameForIndex(unicode));
contentTree.add(heading);
@@ -114,7 +114,7 @@ protected void addTree(SortedSet<TypeElement> sset, String heading,
if (!sset.isEmpty()) {
TypeElement firstTypeElement = sset.first();
Content headingContent = contents.getContent(heading);
Content sectionHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true,
Content sectionHeading = HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING,
headingContent);
HtmlTree htmlTree = HtmlTree.SECTION(HtmlStyle.hierarchy, sectionHeading);
addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null,
@@ -141,7 +141,7 @@ protected void addContents(Content content) {
}
}
Content titleContent = contents.allClassesLabel;
Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
content.add(headerDiv);
@@ -82,7 +82,7 @@ protected void buildAllPackagesFile() throws DocFileIOException {
Content mainContent = new ContentBuilder();
addPackages(mainContent);
Content titleContent = contents.allPackagesLabel;
Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
Content footer = HtmlTree.FOOTER();
@@ -103,7 +103,7 @@ public Content getAnnotationDetailsTreeHeader() {
@Override
public Content getAnnotationDocTreeHeader(Element member) {
Content annotationDocTree = new ContentBuilder();
Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(name(member)));
annotationDocTree.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, annotationDocTree).setId(name(member));
@@ -105,7 +105,7 @@ public Content getAnnotationDetailsTreeHeader() {
public Content getAnnotationDocTreeHeader(Element member) {
String simpleName = name(member);
Content annotationDocTree = new ContentBuilder();
Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(simpleName));
annotationDocTree.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, annotationDocTree)
@@ -109,7 +109,7 @@ public Content getHeader(String header) {
}
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, new StringContent(header));
heading.add(getTypeParameterLinks(linkInfo));
div.add(heading);
@@ -439,8 +439,8 @@ protected HtmlTree getClassUseHeader() {
headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype));
headingContent.add(new HtmlTree(HtmlTag.BR));
headingContent.add(clname);
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
true, HtmlStyle.title, headingContent);
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headingContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bodyContents.setHeader(headerContent).addMainContent(div);
return bodyTree;
@@ -140,7 +140,7 @@ public Content getHeader(String header) {
LinkInfoImpl.Kind.CLASS_HEADER, typeElement);
//Let's not link to ourselves in the header.
linkInfo.linkToSelf = false;
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, new StringContent(header));
heading.add(getTypeParameterLinks(linkInfo));
div.add(heading);
@@ -134,11 +134,11 @@ public void addLinkToPackageContent(PackageElement pkg,
@Override
public void addContentsList(Content contentListTree) {
Content titleContent = contents.constantsSummaryTitle;
Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent);
Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
Content headingContent = contents.contentsHeading;
Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING,
headingContent);
HtmlTree section = HtmlTree.SECTION(HtmlStyle.packages, heading);
section.add(contentListTree);
@@ -167,7 +167,7 @@ public void addPackageName(PackageElement pkg, Content summariesTree, boolean fi
pkgNameContent = getPackageLabel(parsedPackageName);
}
Content headingContent = new StringContent(".*");
Content heading = HtmlTree.HEADING(Headings.ConstantsSummary.PACKAGE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.ConstantsSummary.PACKAGE_HEADING,
pkgNameContent);
heading.add(headingContent);
summaryTree = HtmlTree.SECTION(HtmlStyle.constantsSummary, heading)
@@ -118,7 +118,7 @@ public Content getConstructorDetailsTreeHeader(Content memberDetailsTree) {
public Content getConstructorDocTreeHeader(ExecutableElement constructor) {
String erasureAnchor;
Content constructorDocTree = new ContentBuilder();
HtmlTree heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
HtmlTree heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(name(constructor)));
if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
heading.setId(erasureAnchor);
@@ -329,11 +329,11 @@ private void addIndexLink(DeprecatedAPIListBuilder builder,
*/
public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
Content headContent = contents.deprecatedAPI;
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
Content headingContent = contents.contentsHeading;
div.add(HtmlTree.HEADING(Headings.CONTENT_HEADING, true,
div.add(HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING,
headingContent));
Content ul = new HtmlTree(HtmlTag.UL);
for (DeprElementKind kind : DeprElementKind.values()) {
@@ -89,7 +89,7 @@ public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement,
public Content getEnumConstantsTreeHeader(VariableElement enumConstant,
Content enumConstantsDetailsTree) {
Content enumConstantsTree = new ContentBuilder();
HtmlTree heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
HtmlTree heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(name(enumConstant)));
enumConstantsTree.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, enumConstantsTree)
@@ -90,7 +90,7 @@ public Content getFieldDetailsTreeHeader(Content memberDetailsTree) {
@Override
public Content getFieldDocTreeHeader(VariableElement field) {
Content fieldTree = new ContentBuilder();
Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(name(field)));
fieldTree.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, fieldTree).setId(name(field));
@@ -118,7 +118,7 @@ protected void generateHelpFile() throws DocFileIOException {
*/
protected void addHelpFileContents(Content contentTree) {
// Heading
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false, HtmlStyle.title,
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.title,
contents.getContent("doclet.help.main_heading"));
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
Content intro = HtmlTree.DIV(HtmlStyle.subTitle,
@@ -286,30 +286,6 @@ public String replaceDocRootDir(String htmlstr) {
private static final Pattern docrootPattern =
Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE);

/**
* Get the script to show or hide the All classes link.
*
* @param id id of the element to show or hide
* @return a content tree for the script
*/
public Content getAllClassesLinkScript(String id) {
Script script = new Script("<!--\n" +
" allClassesLink = document.getElementById(")
.appendStringLiteral(id)
.append(");\n" +
" if(window==top) {\n" +
" allClassesLink.style.display = \"block\";\n" +
" }\n" +
" else {\n" +
" allClassesLink.style.display = \"none\";\n" +
" }\n" +
" //-->\n");
Content div = HtmlTree.DIV(script.asContent());
Content div_noscript = HtmlTree.DIV(contents.noScriptMessage);
Content noScript = HtmlTree.NOSCRIPT(div_noscript);
div.add(noScript);
return div;
}

/**
* Add method information.
@@ -104,7 +104,7 @@ public Content getMethodDetailsTreeHeader(Content memberDetailsTree) {
public Content getMethodDocTreeHeader(ExecutableElement method) {
String erasureAnchor;
Content methodDocTree = new ContentBuilder();
HtmlTree heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
HtmlTree heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(name(method)));
if ((erasureAnchor = getErasureAnchor(method)) != null) {
heading.setId(erasureAnchor);
@@ -201,7 +201,7 @@ public Content getModuleHeader(String heading) {
div.add(annotationContent);
Content label = mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL)
? contents.openModuleLabel : contents.moduleLabel;
Content tHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content tHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, label);
tHeading.add(Entity.NO_BREAK_SPACE);
Content moduleHead = new RawHtml(heading);
@@ -100,7 +100,7 @@ protected void generatePackageTreeFile() throws DocFileIOException {
Content mainContent = new ContentBuilder();
Content headContent = contents.getContent("doclet.Hierarchy_For_Package",
utils.getPackageName(packageElement));
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false,
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
if (configuration.packages.size() > 1) {
@@ -247,7 +247,7 @@ private HtmlTree getPackageUseHeader() {
headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText));
headingContent.add(new HtmlTree(HtmlTag.BR));
headingContent.add(name);
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headingContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bodyContents.setHeader(headerContent)
@@ -120,7 +120,7 @@ public Content getPackageHeader(String heading) {
Content annotationContent = new HtmlTree(HtmlTag.P);
addAnnotationInfo(packageElement, annotationContent);
div.add(annotationContent);
Content tHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content tHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, contents.packageLabel);
tHeading.add(Entity.NO_BREAK_SPACE);
Content packageHead = new StringContent(heading);
@@ -82,7 +82,7 @@ public Content getPropertyDetailsTreeHeader(Content memberDetailsTree) {
@Override
public Content getPropertyDocTreeHeader(ExecutableElement property) {
Content propertyDocTree = new ContentBuilder();
Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING,
Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING,
new StringContent(utils.getPropertyLabel(name(property))));
propertyDocTree.add(heading);
return HtmlTree.SECTION(HtmlStyle.detail, propertyDocTree)
@@ -79,7 +79,7 @@ public Content getHeader(String header) {
navBar.setUserHeader(getUserHeaderFooter(true));
headerContent.add(navBar.getContent(Navigation.Position.TOP));
Content h1Content = new StringContent(header);
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, h1Content);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
bodyContents.setHeader(headerContent)
@@ -117,7 +117,7 @@ public Content getPackageSerializedHeader() {
*/
@Override
public Content getPackageHeader(String packageName) {
Content heading = HtmlTree.HEADING(Headings.SerializedForm.PACKAGE_HEADING, true,
Content heading = HtmlTree.HEADING_TITLE(Headings.SerializedForm.PACKAGE_HEADING,
contents.packageLabel);
heading.add(Entity.NO_BREAK_SPACE);
heading.add(packageName);
@@ -118,7 +118,7 @@ protected void buildSystemPropertiesPage() throws DocFileIOException {
Content mainContent = new ContentBuilder();
addSystemProperties(mainContent);
Content titleContent = new StringContent(resources.getText("doclet.systemProperties"));
Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
Content pHeading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, titleContent);
Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading);
mainTree.add(headerDiv);
@@ -108,7 +108,7 @@ public static void generate(HtmlConfiguration configuration,
public void generateTreeFile() throws DocFileIOException {
HtmlTree body = getTreeHeader();
Content headContent = contents.hierarchyForAllPackages;
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false,
Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
addPackageTreeLinks(div);
@@ -27,6 +27,7 @@

import java.io.IOException;
import java.io.Writer;
import java.util.Objects;

import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
@@ -49,7 +50,7 @@ public class Comment extends Content {
* @param comment comment text for the comment
*/
public Comment(String comment) {
commentText = nullCheck(comment);
commentText = Objects.requireNonNull(comment);
}

@Override
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import jdk.javadoc.internal.doclets.toolkit.Content;

@@ -49,7 +50,7 @@ public ContentBuilder(Content... contents) {

@Override
public ContentBuilder add(Content content) {
nullCheck(content);
Objects.requireNonNull(content);
ensureMutableContents();
if (content instanceof ContentBuilder) {
contents.addAll(((ContentBuilder) content).contents);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, 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
@@ -60,7 +60,6 @@ public enum HtmlTag {
HR(BlockType.BLOCK, EndTag.NOEND),
HTML(BlockType.OTHER, EndTag.END),
I(BlockType.INLINE, EndTag.END),
IFRAME(BlockType.OTHER, EndTag.END),
IMG(BlockType.INLINE, EndTag.NOEND),
INPUT(BlockType.BLOCK, EndTag.NOEND),
LABEL(BlockType.INLINE, EndTag.END),

0 comments on commit 5b9a09c

Please sign in to comment.