src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 55232 9b392b044f64
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
53991
786825220790 8219801: Pages do not have <h1>
jjg
parents: 53883
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    26
package jdk.javadoc.internal.doclets.formats.html;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    27
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    28
import java.util.ArrayList;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    29
import java.util.List;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    30
import java.util.Set;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    31
import java.util.TreeSet;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    32
import java.util.stream.Collectors;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    34
import javax.lang.model.element.Element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    35
import javax.lang.model.element.ExecutableElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    36
import javax.lang.model.element.Modifier;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    37
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    38
import javax.lang.model.element.TypeParameterElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    39
import javax.lang.model.type.TypeMirror;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 7681
diff changeset
    40
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    41
import com.sun.source.doctree.DocTree;
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    42
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
    43
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    44
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    45
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    46
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    47
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47847
diff changeset
    48
import jdk.javadoc.internal.doclets.formats.html.markup.Links;
55197
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
    49
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    50
import jdk.javadoc.internal.doclets.formats.html.markup.Table;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    51
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    52
import jdk.javadoc.internal.doclets.toolkit.Content;
47450
d3e20c816f60 8189843: Missing \"id\" attributes in table rows
jjg
parents: 47427
diff changeset
    53
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    54
import jdk.javadoc.internal.doclets.toolkit.Resources;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    55
import jdk.javadoc.internal.doclets.toolkit.taglets.DeprecatedTaglet;
55197
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
    56
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    57
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    58
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    59
import static javax.lang.model.element.Modifier.ABSTRACT;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    60
import static javax.lang.model.element.Modifier.NATIVE;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    61
import static javax.lang.model.element.Modifier.PUBLIC;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    62
import static javax.lang.model.element.Modifier.STRICTFP;
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
    63
import static javax.lang.model.element.Modifier.SYNCHRONIZED;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 * The base class for member writers.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    68
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    69
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    70
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    71
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    72
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 * @author Jamie Ho (Re-write)
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
    76
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 */
47450
d3e20c816f60 8189843: Missing \"id\" attributes in table rows
jjg
parents: 47427
diff changeset
    78
public abstract class AbstractMemberWriter implements MemberSummaryWriter {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42831
diff changeset
    80
    protected final HtmlConfiguration configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
    81
    protected final Utils utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    protected final SubWriterHolderWriter writer;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    83
    protected final Contents contents;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    84
    protected final Resources resources;
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47847
diff changeset
    85
    protected final Links links;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    86
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    87
    protected final TypeElement typeElement;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public final boolean nodepr;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
    90
    protected boolean printedSummaryHeader = false;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
    91
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    92
    public AbstractMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
    93
        this.configuration = writer.configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        this.writer = writer;
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
    95
        this.nodepr = configuration.nodeprecated;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    96
        this.typeElement = typeElement;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    97
        this.utils = configuration.utils;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    98
        this.contents = configuration.contents;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    99
        this.resources = configuration.resources;
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47850
diff changeset
   100
        this.links = writer.links;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public AbstractMemberWriter(SubWriterHolderWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        this(writer, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    /*** abstracts ***/
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   109
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   110
     * Add the summary label for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   111
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   112
     * @param memberTree the content tree to which the label will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   113
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   114
    public abstract void addSummaryLabel(Content memberTree);
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   115
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   116
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   117
     * Get the summary for the member summary table.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   118
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   119
     * @return a string for the table summary
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   120
     */
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   121
    private String getTableSummaryX() { return null; }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   123
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   124
     * Get the summary table header for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   125
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   126
     * @param member the member to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   127
     * @return the summary table header
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   128
     */
47427
251676148c62 8189405: More cleanup in HtmlWriter
jjg
parents: 47272
diff changeset
   129
    public abstract TableHeader getSummaryTableHeader(Element member);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   131
    private Table summaryTable;
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   132
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   133
    private Table getSummaryTable() {
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   134
        if (summaryTable == null) {
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   135
            summaryTable = createSummaryTable();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   136
        }
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   137
        return summaryTable;
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   138
    }
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   139
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   140
    /**
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   141
     * Create the summary table for this element.
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   142
     * The table should be created and initialized if needed, and configured
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
   143
     * so that it is ready to add content with {@link Table#addRow(Content[])}
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   144
     * and similar methods.
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   145
     *
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   146
     * @return the summary table
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   147
     */
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   148
    protected abstract Table createSummaryTable();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   149
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   150
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   151
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   152
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   153
     * Add inherited summary label for the member.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   154
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   155
     * @param typeElement the TypeElement to which to link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   156
     * @param inheritedTree the content tree to which the inherited summary label will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   157
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   158
    public abstract void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   160
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   161
     * Add the anchor for the summary section of the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   162
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   163
     * @param typeElement the TypeElement to be documented
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   164
     * @param memberTree the content tree to which the summary anchor will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   165
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   166
    public abstract void addSummaryAnchor(TypeElement typeElement, Content memberTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   168
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   169
     * Add the anchor for the inherited summary section of the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   170
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   171
     * @param typeElement the TypeElement to be documented
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   172
     * @param inheritedTree the content tree to which the inherited summary anchor will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   173
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   174
    public abstract void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   176
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   177
     * Add the summary type for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   178
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   179
     * @param member the member to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   180
     * @param tdSummaryType the content tree to which the type will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   181
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   182
    protected abstract void addSummaryType(Element member, Content tdSummaryType);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   183
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   184
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   185
     * Add the summary link for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   186
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   187
     * @param typeElement the TypeElement to be documented
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   188
     * @param member the member to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   189
     * @param tdSummary the content tree to which the link will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   190
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   191
    protected void addSummaryLink(TypeElement typeElement, Element member, Content tdSummary) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   192
        addSummaryLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, tdSummary);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   195
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   196
     * Add the summary link for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   197
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   198
     * @param context the id of the context where the link will be printed
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   199
     * @param typeElement the TypeElement to be documented
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   200
     * @param member the member to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   201
     * @param tdSummary the content tree to which the summary link will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   202
     */
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 15034
diff changeset
   203
    protected abstract void addSummaryLink(LinkInfoImpl.Kind context,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   204
            TypeElement typeElement, Element member, Content tdSummary);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   205
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   206
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   207
     * Add the inherited summary link for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   208
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   209
     * @param typeElement the TypeElement to be documented
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   210
     * @param member the member to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   211
     * @param linksTree the content tree to which the inherited summary link will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   212
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   213
    protected abstract void addInheritedSummaryLink(TypeElement typeElement,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   214
            Element member, Content linksTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   216
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   217
     * Get the deprecated link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   218
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   219
     * @param member the member being linked to
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   220
     * @return a content tree representing the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   221
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   222
    protected abstract Content getDeprecatedLink(Element member);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   224
    protected CharSequence makeSpace(int len) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        if (len <= 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        }
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14260
diff changeset
   228
        StringBuilder sb = new StringBuilder(len);
17564
c329fe11193d 8011288: Erratic/inconsistent indentation of signatures
jjg
parents: 17560
diff changeset
   229
        for (int i = 0; i < len; i++) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
            sb.append(' ');
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   231
        }
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   232
        return sb;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   236
     * Add the modifier and type for the member in the member summary.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   237
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   238
     * @param member the member to add the type for
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   239
     * @param type the type to add
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   240
     * @param tdSummaryType the content tree to which the modified and type will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   242
    protected void addModifierAndType(Element member, TypeMirror type,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   243
            Content tdSummaryType) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   244
        HtmlTree code = new HtmlTree(HtmlTag.CODE);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   245
        addModifier(member, code);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        if (type == null) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   247
            code.add(utils.isClass(member) ? "class" : "interface");
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
   248
            code.add(Entity.NO_BREAK_SPACE);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   250
            List<? extends TypeParameterElement> list = utils.isExecutableElement(member)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   251
                    ? ((ExecutableElement)member).getTypeParameters()
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   252
                    : null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   253
            if (list != null && !list.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   254
                Content typeParameters = ((AbstractExecutableMemberWriter) this)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   255
                        .getTypeParameters((ExecutableElement)member);
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   256
                    code.add(typeParameters);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
                //Code to avoid ugly wrapping in member summary table.
17564
c329fe11193d 8011288: Erratic/inconsistent indentation of signatures
jjg
parents: 17560
diff changeset
   258
                if (typeParameters.charCount() > 10) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   259
                    code.add(new HtmlTree(HtmlTag.BR));
17564
c329fe11193d 8011288: Erratic/inconsistent indentation of signatures
jjg
parents: 17560
diff changeset
   260
                } else {
54610
a9ab154b1384 8222669: Create and use new html.Entity class
jjg
parents: 54596
diff changeset
   261
                    code.add(Entity.NO_BREAK_SPACE);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                }
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   263
                code.add(
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
   264
                        writer.getLink(new LinkInfoImpl(configuration,
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   265
                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
            } else {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   267
                code.add(
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
   268
                        writer.getLink(new LinkInfoImpl(configuration,
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   269
                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        }
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   273
        tdSummaryType.add(code);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   276
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   277
     * Add the modifier for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   278
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   279
     * @param member the member to add the type for
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   280
     * @param code the content tree to which the modified will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   281
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   282
    private void addModifier(Element member, Content code) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   283
        if (utils.isProtected(member)) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   284
            code.add("protected ");
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   285
        } else if (utils.isPrivate(member)) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   286
            code.add("private ");
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   287
        } else if (!utils.isPublic(member)) { // Package private
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   288
            code.add(resources.getText("doclet.Package_private"));
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   289
            code.add(" ");
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   290
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   291
        boolean isAnnotatedTypeElement = utils.isAnnotationType(member.getEnclosingElement());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   292
        if (!isAnnotatedTypeElement && utils.isMethod(member)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   293
            if (!utils.isInterface(member.getEnclosingElement()) && utils.isAbstract(member)) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   294
                code.add("abstract ");
14965
bb1eb01b8c41 8004893: the javadoc/doclet needs to be updated to accommodate lambda changes
bpatel
parents: 14549
diff changeset
   295
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   296
            if (utils.isDefault(member)) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   297
                code.add("default ");
14965
bb1eb01b8c41 8004893: the javadoc/doclet needs to be updated to accommodate lambda changes
bpatel
parents: 14549
diff changeset
   298
            }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   299
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   300
        if (utils.isStatic(member)) {
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   301
            code.add("static ");
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   302
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   303
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   304
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   305
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   306
     * Add the deprecated information for the given member.
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   307
     *
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   308
     * @param member the member being documented.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   309
     * @param contentTree the content tree to which the deprecated information will be added.
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   310
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   311
    protected void addDeprecatedInfo(Element member, Content contentTree) {
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17570
diff changeset
   312
        Content output = (new DeprecatedTaglet()).getTagletOutput(member,
17567
56e83a873757 8012176: reduce use of TagletOutputImpl.toString
jjg
parents: 17564
diff changeset
   313
            writer.getTagletWriterInstance(false));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17570
diff changeset
   314
        if (!output.isEmpty()) {
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17570
diff changeset
   315
            Content deprecatedContent = output;
47272
e0d686cdf608 8183511: improve style for deprecated text
bpatel
parents: 47216
diff changeset
   316
            Content div = HtmlTree.DIV(HtmlStyle.deprecationBlock, deprecatedContent);
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   317
            contentTree.add(div);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   318
        }
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   319
    }
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1789
diff changeset
   320
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   321
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   322
     * Add the comment for the given member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   323
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   324
     * @param member the member being documented.
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 14258
diff changeset
   325
     * @param htmltree the content tree to which the comment will be added.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   326
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   327
    protected void addComment(Element member, Content htmltree) {
41452
ddaef4bba083 8165991: Fix DocTreeFactory newDocCommentTree
ksrini
parents: 41157
diff changeset
   328
        if (!utils.getFullBody(member).isEmpty()) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   329
            writer.addInlineComment(member, htmltree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   333
    protected String name(Element member) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   334
        return utils.getSimpleName(member);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   337
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    * Return true if the given <code>ProgramElement</code> is inherited
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
    * by the class that is being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
    * @param ped The <code>ProgramElement</code> being checked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    * return true if the <code>ProgramElement</code> is being inherited and
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
    * false otherwise.
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
   344
     *@return true if inherited
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   346
    protected boolean isInherited(Element ped){
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   347
        return (!utils.isPrivate(ped) &&
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   348
                (!utils.isPackagePrivate(ped) ||
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   349
                    ped.getEnclosingElement().equals(ped.getEnclosingElement())));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   353
     * Add use information to the documentation tree.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   354
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   355
     * @param mems list of program elements for which the use information will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   356
     * @param heading the section heading
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   357
     * @param contentTree the content tree to which the use information will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     */
53562
0d9dee001667 8215577: Remove javadoc support for HTML 4
pmuthuswamy
parents: 52644
diff changeset
   359
    protected void addUseInfo(List<? extends Element> mems, Content heading, Content contentTree) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   360
        if (mems == null || mems.isEmpty()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   363
        List<? extends Element> members = mems;
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   364
        boolean printedUseTableHeader = false;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
        if (members.size() > 0) {
53562
0d9dee001667 8215577: Remove javadoc support for HTML 4
pmuthuswamy
parents: 52644
diff changeset
   366
            Table useTable = new Table(HtmlStyle.useSummary)
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   367
                    .setCaption(heading)
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   368
                    .setRowScopeColumn(1)
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   369
                    .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   370
            for (Element element : members) {
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   371
                TypeElement te = (typeElement == null)
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   372
                        ? utils.getEnclosingTypeElement(element)
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   373
                        : typeElement;
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   374
                if (!printedUseTableHeader) {
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   375
                    useTable.setHeader(getSummaryTableHeader(element));
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   376
                    printedUseTableHeader = true;
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   377
                }
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   378
                Content summaryType = new ContentBuilder();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   379
                addSummaryType(element, summaryType);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   380
                Content typeContent = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   381
                if (te != null
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   382
                        && !utils.isConstructor(element)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   383
                        && !utils.isClass(element)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   384
                        && !utils.isInterface(element)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   385
                        && !utils.isAnnotationType(element)) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   386
                    HtmlTree name = new HtmlTree(HtmlTag.SPAN);
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   387
                    name.setStyle(HtmlStyle.typeNameLabel);
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   388
                    name.add(name(te) + ".");
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   389
                    typeContent.add(name);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   390
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   391
                addSummaryLink(utils.isClass(element) || utils.isInterface(element)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   392
                        ? LinkInfoImpl.Kind.CLASS_USE
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   393
                        : LinkInfoImpl.Kind.MEMBER,
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   394
                        te, element, typeContent);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   395
                Content desc = new ContentBuilder();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   396
                writer.addSummaryLinkComment(this, element, desc);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   397
                useTable.addRow(summaryType, typeContent, desc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
            }
54060
53a95878619f 8220202: Simplify/standardize method naming for HtmlTree
jjg
parents: 53991
diff changeset
   399
            contentTree.add(useTable.toContent());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   403
    protected void serialWarning(Element e, String key, String a1, String a2) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14266
diff changeset
   404
        if (configuration.serialwarn) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
   405
            configuration.messages.warning(e, key, a1, a2);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   410
     * Add the member summary for the given class.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   411
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   412
     * @param tElement the class that is being documented
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   413
     * @param member the member being documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   414
     * @param firstSentenceTags the first sentence tags to be added to the summary
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   415
     */
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47847
diff changeset
   416
    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   417
    public void addMemberSummary(TypeElement tElement, Element member,
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   418
            List<? extends DocTree> firstSentenceTags) {
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   419
        if (tElement != typeElement) {
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   420
            throw new IllegalStateException();
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   421
        }
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   422
        Table table = getSummaryTable();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   423
        List<Content> rowContents = new ArrayList<>();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   424
        Content summaryType = new ContentBuilder();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   425
        addSummaryType(member, summaryType);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   426
        if (!summaryType.isEmpty())
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   427
            rowContents.add(summaryType);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   428
        Content summaryLink = new ContentBuilder();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   429
        addSummaryLink(tElement, member, summaryLink);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   430
        rowContents.add(summaryLink);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   431
        Content desc = new ContentBuilder();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   432
        writer.addSummaryLinkComment(this, member, firstSentenceTags, desc);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   433
        rowContents.add(desc);
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   434
        table.addRow(member, rowContents);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   435
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   436
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   437
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   438
     * Add inherited member summary for the given class and member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   439
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   440
     * @param tElement the class the inherited member belongs to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   441
     * @param nestedClass the inherited member that is summarized
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   442
     * @param isFirst true if this is the first member in the list
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   443
     * @param isLast true if this is the last member in the list
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   444
     * @param linksTree the content tree to which the summary will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
     */
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   446
    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   447
    public void addInheritedMemberSummary(TypeElement tElement,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   448
            Element nestedClass, boolean isFirst, boolean isLast,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   449
            Content linksTree) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   450
        writer.addInheritedMemberSummary(this, tElement, nestedClass, isFirst,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   451
                linksTree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   452
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   453
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   454
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   455
     * Get the inherited summary header for the given class.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   456
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   457
     * @param tElement the class the inherited member belongs to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   458
     * @return a content tree for the inherited summary header
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   459
     */
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   460
    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   461
    public Content getInheritedSummaryHeader(TypeElement tElement) {
54596
86c1da00dd6a 8219998: Eliminate inherently singleton lists
pmuthuswamy
parents: 54060
diff changeset
   462
        Content inheritedTree = writer.getMemberInheritedTree();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   463
        writer.addInheritedSummaryHeader(this, tElement, inheritedTree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   464
        return inheritedTree;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   465
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   466
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   467
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   468
     * Get the inherited summary links tree.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   469
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   470
     * @return a content tree for the inherited summary links
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   471
     */
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   472
    @Override
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   473
    public Content getInheritedSummaryLinksTree() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   474
        return new HtmlTree(HtmlTag.CODE);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   475
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   476
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   477
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   478
     * Get the summary table tree for the given class.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   479
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   480
     * @param tElement the class for which the summary table is generated
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   481
     * @return a content tree for the summary table
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   482
     */
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   483
    @Override
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   484
    public Content getSummaryTableTree(TypeElement tElement) {
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   485
        if (tElement != typeElement) {
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   486
            throw new IllegalStateException();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   487
        }
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   488
        Table table = getSummaryTable();
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   489
        if (table.needsScript()) {
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   490
            writer.getMainBodyScript().append(table.getScript());
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   491
        }
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   492
        return table.toContent();
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   493
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   494
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   495
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   496
     * Get the member tree to be documented.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   497
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   498
     * @param memberTree the content tree of member to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   499
     * @return a content tree that will be added to the class documentation
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   500
     */
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47450
diff changeset
   501
    @Override
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   502
    public Content getMemberTree(Content memberTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   503
        return writer.getMemberTree(memberTree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   504
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   505
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   506
    /**
55197
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   507
     * A content builder for member signatures.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   508
     */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   509
    class MemberSignature {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   510
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   511
        private Element element;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   512
        private Content typeParameters;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   513
        private Content returnType;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   514
        private Content parameters;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   515
        private Content exceptions;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   516
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   517
        // Threshold for length of type parameters before switching from inline to block representation.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   518
        private final static int TYPE_PARAMS_MAX_INLINE_LENGTH = 50;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   519
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   520
        // Threshold for combined length of modifiers, type params and return type before breaking
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   521
        // it up with a line break before the return type.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   522
        private final static int RETURN_TYPE_MAX_LINE_LENGTH = 50;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   523
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   524
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   525
         * Create a new member signature builder.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   526
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   527
         * @param element The element for which to create a signature.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   528
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   529
        MemberSignature(Element element) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   530
            this.element = element;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   531
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   532
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   533
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   534
         * Add the type parameters for an executable member.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   535
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   536
         * @param typeParameters the content tree containing the type parameters to add.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   537
         * @return this MemberSignature instance
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   538
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   539
        MemberSignature addTypeParameters(Content typeParameters) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   540
            this.typeParameters = typeParameters;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   541
            return this;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   542
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   543
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   544
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   545
         * Add the return type for an executable member.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   546
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   547
         * @param returnType the content tree containing the return type to add.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   548
         * @return this MemberSignature instance
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   549
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   550
        MemberSignature addReturnType(Content returnType) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   551
            this.returnType = returnType;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   552
            return this;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   553
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   554
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   555
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   556
         * Add the type information for a non-executable member.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   557
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   558
         * @param type the type of the member.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   559
         * @return this MemberSignature instance
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   560
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   561
        MemberSignature addType(TypeMirror type) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   562
            this.returnType = writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, type));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   563
            return this;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   564
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   565
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   566
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   567
         * Add the parameter information of an executable member.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   568
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   569
         * @param paramTree the content tree containing the parameter information.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   570
         * @return this MemberSignature instance
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   571
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   572
        MemberSignature addParameters(Content paramTree) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   573
            this.parameters = paramTree;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   574
            return this;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   575
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   576
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   577
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   578
         * Add the exception information of an executable member.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   579
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   580
         * @param exceptionTree the content tree containing the exception information
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   581
         * @return this MemberSignature instance
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   582
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   583
        MemberSignature addExceptions(Content exceptionTree) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   584
            this.exceptions = exceptionTree;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   585
            return this;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   586
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   587
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   588
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   589
         * Return a HTML tree containing the member signature.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   590
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   591
         * @return a HTML tree containing the member signature
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   592
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   593
        Content toContent() {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   594
            Content content = new ContentBuilder();
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   595
            // Position of last line separator.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   596
            int lastLineSeparator = 0;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   597
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   598
            // Annotations
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   599
            Content annotationInfo = writer.getAnnotationInfo(element.getAnnotationMirrors(), true);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   600
            if (!annotationInfo.isEmpty()) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   601
                content.add(HtmlTree.SPAN(HtmlStyle.annotations, annotationInfo));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   602
                lastLineSeparator = content.charCount();
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   603
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   604
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   605
            // Modifiers
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   606
            appendModifiers(content);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   607
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   608
            // Type parameters
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   609
            if (typeParameters != null && !typeParameters.isEmpty()) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   610
                lastLineSeparator = appendTypeParameters(content, lastLineSeparator);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   611
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   612
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   613
            // Return type
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   614
            if (returnType != null) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   615
                content.add(HtmlTree.SPAN(HtmlStyle.returnType, returnType));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   616
                content.add(Entity.NO_BREAK_SPACE);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   617
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   618
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   619
            // Name
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   620
            HtmlTree nameSpan = new HtmlTree(HtmlTag.SPAN);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   621
            nameSpan.setStyle(HtmlStyle.memberName);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   622
            if (configuration.linksource) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   623
                Content name = new StringContent(name(element));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   624
                writer.addSrcLink(element, name, nameSpan);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   625
            } else {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   626
                nameSpan.add(name(element));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   627
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   628
            content.add(nameSpan);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   629
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   630
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   631
            // Parameters and exceptions
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   632
            if (parameters != null) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   633
                appendParametersAndExceptions(content, lastLineSeparator);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   634
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   635
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   636
            return HtmlTree.DIV(HtmlStyle.memberSignature, content);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   637
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   638
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   639
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   640
         * Add the modifier for the member. The modifiers are ordered as specified
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   641
         * by <em>The Java Language Specification</em>.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   642
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   643
         * @param htmltree the content tree to which the modifier information will be added.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   644
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   645
        private void appendModifiers(Content htmltree) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   646
            Set<Modifier> set = new TreeSet<>(element.getModifiers());
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   647
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   648
            // remove the ones we really don't need
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   649
            set.remove(NATIVE);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   650
            set.remove(SYNCHRONIZED);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   651
            set.remove(STRICTFP);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   652
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   653
            // According to JLS, we should not be showing public modifier for
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   654
            // interface methods.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   655
            if ((utils.isField(element) || utils.isMethod(element))
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   656
                    && ((writer instanceof ClassWriterImpl
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   657
                    && utils.isInterface(((ClassWriterImpl) writer).getTypeElement())  ||
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   658
                    writer instanceof AnnotationTypeWriterImpl) )) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   659
                // Remove the implicit abstract and public modifiers
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   660
                if (utils.isMethod(element) &&
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   661
                        (utils.isInterface(element.getEnclosingElement()) ||
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   662
                                utils.isAnnotationType(element.getEnclosingElement()))) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   663
                    set.remove(ABSTRACT);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   664
                    set.remove(PUBLIC);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   665
                }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   666
                if (!utils.isMethod(element)) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   667
                    set.remove(PUBLIC);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   668
                }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   669
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   670
            if (!set.isEmpty()) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   671
                String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" "));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   672
                htmltree.add(HtmlTree.SPAN(HtmlStyle.modifiers, new StringContent(mods)));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   673
                htmltree.add(Entity.NO_BREAK_SPACE);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   674
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   675
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   676
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   677
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   678
         * Append the type parameter information to the HTML tree.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   679
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   680
         * @param htmltree the HTML tree
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   681
         * @param lastLineSeparator index of last line separator in HTML tree
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   682
         * @return the new index of the last line separator
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   683
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   684
        private int appendTypeParameters(Content htmltree, int lastLineSeparator) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   685
            // Apply different wrapping strategies for type parameters
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   686
            // depending of combined length of type parameters and return type.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   687
            int typeParamLength = typeParameters.charCount();
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   688
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   689
            if (typeParamLength >= TYPE_PARAMS_MAX_INLINE_LENGTH) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   690
                htmltree.add(HtmlTree.SPAN(HtmlStyle.typeParametersLong, typeParameters));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   691
            } else {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   692
                htmltree.add(HtmlTree.SPAN(HtmlStyle.typeParameters, typeParameters));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   693
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   694
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   695
            int lineLength = htmltree.charCount() - lastLineSeparator;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   696
            int newLastLineSeparator = lastLineSeparator;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   697
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   698
            // sum below includes length of modifiers plus type params added above
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   699
            if (lineLength + returnType.charCount()> RETURN_TYPE_MAX_LINE_LENGTH) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   700
                htmltree.add(DocletConstants.NL);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   701
                newLastLineSeparator = htmltree.charCount();
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   702
            } else {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   703
                htmltree.add(Entity.NO_BREAK_SPACE);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   704
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   705
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   706
            return newLastLineSeparator;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   707
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   708
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   709
        /**
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   710
         * Append the parameters and exceptions information to the HTML tree.
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   711
         *
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   712
         * @param htmltree the HTML tree
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   713
         * @param lastLineSeparator the index of the last line separator in HTML tree
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   714
         */
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   715
        private void appendParametersAndExceptions(Content htmltree, int lastLineSeparator) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   716
            // Record current position for indentation of exceptions
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   717
            int indentSize = htmltree.charCount() - lastLineSeparator;
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   718
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   719
            if (parameters.isEmpty()) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   720
                htmltree.add("()");
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   721
            } else {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   722
                parameters.add(")");
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   723
                htmltree.add(Entity.ZERO_WIDTH_SPACE);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   724
                htmltree.add("(");
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   725
                htmltree.add(HtmlTree.SPAN(HtmlStyle.arguments, parameters));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   726
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   727
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   728
            // Exceptions
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   729
            if (exceptions != null && !exceptions.isEmpty()) {
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   730
                CharSequence indent = makeSpace(indentSize + 1 - 7);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   731
                htmltree.add(DocletConstants.NL);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   732
                htmltree.add(indent);
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   733
                htmltree.add("throws ");
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   734
                htmltree.add(HtmlTree.SPAN(HtmlStyle.exceptions, exceptions));
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   735
            }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   736
        }
0ca8e495bbba 8214126: Method signatures not formatted correctly in browser
hannesw
parents: 54610
diff changeset
   737
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
}