src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
author hannesw
Tue, 27 Nov 2018 13:02:28 +0100
changeset 52695 99eb43bc3595
parent 52685 6d243dcde190
child 54060 53a95878619f
permissions -rw-r--r--
8213716: javadoc search not working with Japanese and Chinese locales Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47850
diff changeset
     2
 * Copyright (c) 2003, 2018, 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: 2216
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: 2216
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: 2216
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
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: 33920
diff changeset
    26
package jdk.javadoc.internal.doclets.formats.html;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    27
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    28
import java.util.List;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 36500
diff changeset
    29
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    30
import javax.lang.model.element.Element;
40511
1b3c502e0bdc 8155995: Update javadoc to include module search
bpatel
parents: 40303
diff changeset
    31
import javax.lang.model.element.ModuleElement;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    32
import javax.lang.model.element.PackageElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    33
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    34
import javax.lang.model.element.VariableElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    35
import javax.lang.model.type.TypeMirror;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    36
import javax.lang.model.util.SimpleElementVisitor9;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    37
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    38
import com.sun.source.doctree.DocTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    39
import com.sun.source.doctree.IndexTree;
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
    40
import com.sun.source.doctree.SystemPropertyTree;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    41
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    42
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    43
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    44
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    45
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44567
diff changeset
    46
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    47
import jdk.javadoc.internal.doclets.toolkit.Content;
52685
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
    48
import jdk.javadoc.internal.doclets.toolkit.DocletElement;
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
    49
import jdk.javadoc.internal.doclets.toolkit.Resources;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    50
import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    51
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    52
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    53
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    54
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    55
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    56
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    57
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * The taglet writer that writes HTML.
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9608
diff changeset
    62
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9608
diff changeset
    63
 *  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: 9608
diff changeset
    64
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9608
diff changeset
    65
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 9608
diff changeset
    66
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * @author Jamie Ho
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
    68
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
public class TagletWriterImpl extends TagletWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
    73
    private final HtmlDocletWriter htmlWriter;
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44567
diff changeset
    74
    private final HtmlConfiguration configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    75
    private final Utils utils;
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
    76
    private final boolean inSummary;
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
    77
    private final Resources resources;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
    80
        this(htmlWriter, isFirstSentence, false);
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
    81
    }
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
    82
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
    83
    public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence, boolean inSummary) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
    84
        super(isFirstSentence);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        this.htmlWriter = htmlWriter;
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
    86
        configuration = htmlWriter.configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    87
        this.utils = configuration.utils;
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
    88
        this.inSummary = inSummary;
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
    89
        resources = configuration.getResources();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
    95
    public Content getOutputInstance() {
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
    96
        return new ContentBuilder();
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
    97
    }
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
    98
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
    99
    /**
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   100
     * {@inheritDoc}
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   101
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   102
    protected Content codeTagOutput(Element element, DocTree tag) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   103
        CommentHelper ch = utils.getCommentHelper(element);
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 35426
diff changeset
   104
        StringContent content = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   105
        Content result = HtmlTree.CODE(content);
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   106
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   109
    protected Content indexTagOutput(Element element, DocTree tag) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   110
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   111
        IndexTree itt = (IndexTree)tag;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   112
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   113
        String tagText =  ch.getText(itt.getSearchTerm());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   114
        if (tagText.charAt(0) == '"' && tagText.charAt(tagText.length() - 1) == '"') {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   115
            tagText = tagText.substring(1, tagText.length() - 1);
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 25874
diff changeset
   116
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   117
        String desc = ch.getText(itt.getDescription());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   118
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   119
        return createAnchorAndSearchIndex(element, tagText,desc);
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 25874
diff changeset
   120
    }
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 25874
diff changeset
   121
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     */
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   125
    public Content getDocRootOutput() {
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   126
        String path;
22005
4270ada5dcd1 8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents: 21478
diff changeset
   127
        if (htmlWriter.pathToRoot.isEmpty())
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   128
            path = ".";
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   129
        else
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   130
            path = htmlWriter.pathToRoot.getPath();
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   131
        return new StringContent(path);
17565
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   132
    }
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   133
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   134
    /**
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   135
     * {@inheritDoc}
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   136
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   137
    public Content deprecatedTagOutput(Element element) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   138
        ContentBuilder result = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   139
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   140
        List<? extends DocTree> deprs = utils.getBlockTags(element, DocTree.Kind.DEPRECATED);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   141
        if (utils.isTypeElement(element)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   142
            if (utils.isDeprecated(element)) {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   143
                result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
42816
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 40606
diff changeset
   144
                        htmlWriter.getDeprecatedPhrase(element)));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   145
                if (!deprs.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   146
                    List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   147
                    if (!commentTags.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   148
                        result.addContent(commentTagsToOutput(null, element, commentTags, false));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   153
            if (utils.isDeprecated(element)) {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   154
                result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
42816
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 40606
diff changeset
   155
                        htmlWriter.getDeprecatedPhrase(element)));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   156
                if (!deprs.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   157
                    List<? extends DocTree> bodyTags = ch.getBody(configuration, deprs.get(0));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   158
                    Content body = commentTagsToOutput(null, element, bodyTags, false);
21023
1192bdc59d82 8026370: javadoc creates empty <span class="italic"></span>
bpatel
parents: 19253
diff changeset
   159
                    if (!body.isEmpty())
47300
a905ce398074 8074407: javadoc: using <pre> after @deprecated tag causes warnings
bpatel
parents: 47216
diff changeset
   160
                        result.addContent(HtmlTree.DIV(HtmlStyle.deprecationComment, body));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
            } else {
42816
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 40606
diff changeset
   163
                Element ee = utils.getEnclosingTypeElement(element);
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 40606
diff changeset
   164
                if (utils.isDeprecated(ee)) {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   165
                    result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
42816
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 40606
diff changeset
   166
                        htmlWriter.getDeprecatedPhrase(ee)));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        }
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   170
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   176
    protected Content literalTagOutput(Element element, DocTree tag) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   177
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   178
        Content result = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   179
        return result;
17565
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   180
    }
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   181
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   182
    /**
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   183
     * {@inheritDoc}
a705fe5e539f 8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents: 17560
diff changeset
   184
     */
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   185
    public Content getParamHeader(String header) {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   186
        HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.paramLabel,
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   187
                new StringContent(header)));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   188
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   194
    public Content paramTagOutput(Element element, DocTree paramTag, String paramName) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   195
        ContentBuilder body = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   196
        CommentHelper ch = utils.getCommentHelper(element);
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   197
        body.addContent(HtmlTree.CODE(new RawHtml(paramName)));
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   198
        body.addContent(" - ");
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   199
        List<? extends DocTree> description = ch.getDescription(configuration, paramTag);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
   200
        body.addContent(htmlWriter.commentTagsToContent(paramTag, element, description, false, inSummary));
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   201
        HtmlTree result = HtmlTree.DD(body);
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   202
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   208
    public Content propertyTagOutput(Element element, DocTree tag, String prefix) {
17572
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   209
        Content body = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   210
        CommentHelper ch = utils.getCommentHelper(element);
17572
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   211
        body.addContent(new RawHtml(prefix));
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   212
        body.addContent(" ");
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   213
        body.addContent(HtmlTree.CODE(new RawHtml(ch.getText(tag))));
17572
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   214
        body.addContent(".");
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   215
        Content result = HtmlTree.P(body);
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   216
        return result;
17572
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   217
    }
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   218
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   219
    /**
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   220
     * {@inheritDoc}
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17568
diff changeset
   221
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   222
    public Content returnTagOutput(Element element, DocTree returnTag) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   223
        ContentBuilder result = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   224
        CommentHelper ch = utils.getCommentHelper(element);
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   225
        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel,
52644
43efb4ca6d6c 8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents: 52487
diff changeset
   226
                new StringContent(resources.getText("doclet.Returns")))));
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
   227
        result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent(
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
   228
                returnTag, element, ch.getDescription(configuration, returnTag), false, inSummary)));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   229
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   235
    public Content seeTagOutput(Element holder, List<? extends DocTree> seeTags) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   236
        ContentBuilder body = new ContentBuilder();
51190
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   237
        for (DocTree dt : seeTags) {
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   238
            appendSeparatorIfNotEmpty(body);
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   239
            body.addContent(htmlWriter.seeTagToContent(holder, dt));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   241
        if (utils.isVariableElement(holder) && ((VariableElement)holder).getConstantValue() != null &&
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
                htmlWriter instanceof ClassWriterImpl) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
            //Automatically add link to constant values page for constant fields.
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   244
            appendSeparatorIfNotEmpty(body);
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   245
            DocPath constantsPath =
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   246
                    htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES);
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   247
            String whichConstant =
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   248
                    ((ClassWriterImpl) htmlWriter).getTypeElement().getQualifiedName() + "." +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   249
                    utils.getSimpleName(holder);
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   250
            DocLink link = constantsPath.fragment(whichConstant);
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47850
diff changeset
   251
            body.addContent(htmlWriter.links.createLink(link,
52644
43efb4ca6d6c 8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents: 52487
diff changeset
   252
                    new StringContent(resources.getText("doclet.Constants_Summary"))));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   254
        if (utils.isClass(holder) && utils.isSerializable((TypeElement)holder)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
            //Automatically add link to serialized form page for serializable classes.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   256
            if (SerializedFormBuilder.serialInclude(utils, holder) &&
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   257
                      SerializedFormBuilder.serialInclude(utils, utils.containingPackage(holder))) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   258
                appendSeparatorIfNotEmpty(body);
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   259
                DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   260
                DocLink link = serialPath.fragment(utils.getFullyQualifiedName(holder));
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47850
diff changeset
   261
                body.addContent(htmlWriter.links.createLink(link,
52644
43efb4ca6d6c 8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents: 52487
diff changeset
   262
                        new StringContent(resources.getText("doclet.Serialized_Form"))));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        }
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   265
        if (body.isEmpty())
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   266
            return body;
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   267
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   268
        ContentBuilder result = new ContentBuilder();
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   269
        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel,
52644
43efb4ca6d6c 8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents: 52487
diff changeset
   270
                new StringContent(resources.getText("doclet.See_Also")))));
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   271
        result.addContent(HtmlTree.DD(body));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   272
        return result;
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   273
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   276
    private void appendSeparatorIfNotEmpty(ContentBuilder body) {
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   277
        if (!body.isEmpty()) {
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   278
            body.addContent(", ");
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   279
            body.addContent(DocletConstants.NL);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        }
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   281
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   286
    public Content simpleTagOutput(Element element, List<? extends DocTree> simpleTags, String header) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   287
        CommentHelper ch = utils.getCommentHelper(element);
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   288
        ContentBuilder result = new ContentBuilder();
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   289
        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   290
        ContentBuilder body = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   291
        boolean many = false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   292
        for (DocTree simpleTag : simpleTags) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   293
            if (many) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   294
                body.addContent(", ");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   296
            List<? extends DocTree> bodyTags = ch.getBody(configuration, simpleTag);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
   297
            body.addContent(htmlWriter.commentTagsToContent(simpleTag, element, bodyTags, false, inSummary));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   298
            many = true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        }
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   300
        result.addContent(HtmlTree.DD(body));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   301
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   307
    public Content simpleTagOutput(Element element, DocTree simpleTag, String header) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   308
        ContentBuilder result = new ContentBuilder();
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   309
        result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   310
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   311
        List<? extends DocTree> description = ch.getDescription(configuration, simpleTag);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
   312
        Content body = htmlWriter.commentTagsToContent(simpleTag, element, description, false, inSummary);
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   313
        result.addContent(HtmlTree.DD(body));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   314
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     */
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   320
    protected Content systemPropertyTagOutput(Element element, DocTree tag) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   321
        SystemPropertyTree itt = (SystemPropertyTree)tag;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   322
        String tagText = itt.getPropertyName().toString();
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   323
        return HtmlTree.CODE(createAnchorAndSearchIndex(element, tagText,
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   324
                resources.getText("doclet.System_Property")));
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   325
    }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   326
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   327
    /**
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   328
     * {@inheritDoc}
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   329
     */
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   330
    public Content getThrowsHeader() {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21023
diff changeset
   331
        HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.throwsLabel,
52644
43efb4ca6d6c 8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents: 52487
diff changeset
   332
                new StringContent(resources.getText("doclet.Throws"))));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   333
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   339
    public Content throwsTagOutput(Element element, DocTree throwsTag) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   340
        ContentBuilder body = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   341
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   342
        Element exception = ch.getException(configuration, throwsTag);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   343
        Content excName;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   344
        if (exception == null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   345
            excName = new RawHtml(ch.getExceptionName(throwsTag).toString());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   346
        } else if (exception.asType() == null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   347
            excName = new RawHtml(utils.getFullyQualifiedName(exception));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   348
        } else {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   349
            LinkInfoImpl link = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   350
                                                 exception.asType());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   351
            link.excludeTypeBounds = true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   352
            excName = htmlWriter.getLink(link);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   353
        }
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   354
        body.addContent(HtmlTree.CODE(excName));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   355
        List<? extends DocTree> description = ch.getDescription(configuration, throwsTag);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
   356
        Content desc = htmlWriter.commentTagsToContent(throwsTag, element, description, false, inSummary);
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   357
        if (desc != null && !desc.isEmpty()) {
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   358
            body.addContent(" - ");
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
   359
            body.addContent(desc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
        }
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   361
        HtmlTree result = HtmlTree.DD(body);
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   362
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   368
    public Content throwsTagOutput(TypeMirror throwsType) {
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   369
        HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink(
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 17565
diff changeset
   370
                new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType))));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17572
diff changeset
   371
        return result;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   377
    public Content valueTagOutput(VariableElement field, String constantVal, boolean includeLink) {
50612
e10812a82a3b 8204330: Javadoc IllegalArgumentException: HTML special chars in constant value
jjg
parents: 48759
diff changeset
   378
        return includeLink
e10812a82a3b 8204330: Javadoc IllegalArgumentException: HTML special chars in constant value
jjg
parents: 48759
diff changeset
   379
                ? htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field, constantVal, false)
e10812a82a3b 8204330: Javadoc IllegalArgumentException: HTML special chars in constant value
jjg
parents: 48759
diff changeset
   380
                : new StringContent(constantVal);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   386
    public Content commentTagsToOutput(DocTree holderTag, List<? extends DocTree> tags) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
        return commentTagsToOutput(holderTag, null, tags, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   393
    public Content commentTagsToOutput(Element holder, List<? extends DocTree> tags) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   394
        return commentTagsToOutput(null, holder, tags, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   400
    public Content commentTagsToOutput(DocTree holderTag,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   401
        Element holder, List<? extends DocTree> tags, boolean isFirstSentence) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   402
        return htmlWriter.commentTagsToContent(holderTag, holder,
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51190
diff changeset
   403
                tags, isFirstSentence, inSummary);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44567
diff changeset
   409
    public BaseConfiguration configuration() {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   410
        return configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
    }
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   412
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   413
    private Content createAnchorAndSearchIndex(Element element, String tagText, String desc){
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   414
        String anchorName = htmlWriter.links.getName(tagText);
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   415
        Content result = null;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   416
        if (isFirstSentence && inSummary) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   417
            result = new StringContent(tagText);
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   418
        } else {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   419
            result = HtmlTree.A_ID(HtmlStyle.searchTagResult, anchorName, new StringContent(tagText));
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   420
            if (configuration.createindex && !tagText.isEmpty()) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   421
                SearchIndexItem si = new SearchIndexItem();
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   422
                si.setLabel(tagText);
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   423
                si.setDescription(desc);
52685
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   424
                si.setUrl(htmlWriter.path.getPath() + "#" + anchorName);
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   425
                DocPaths docPaths = configuration.docPaths;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   426
                new SimpleElementVisitor9<Void, Void>() {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   427
                    @Override
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   428
                    public Void visitVariable(VariableElement e, Void p) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   429
                        TypeElement te = utils.getEnclosingTypeElement(e);
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   430
                        si.setHolder(utils.getFullyQualifiedName(e) + "." + utils.getSimpleName(e));
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   431
                        return null;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   432
                    }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   433
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   434
                    @Override
52685
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   435
                    public Void visitUnknown(Element e, Void p) {
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   436
                        if (e instanceof DocletElement) {
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   437
                            DocletElement de = (DocletElement) e;
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   438
                            switch (de.getSubKind()) {
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   439
                                case OVERVIEW:
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   440
                                    si.setHolder(resources.getText("doclet.Overview"));
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   441
                                    break;
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   442
                                case DOCFILE:
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   443
                                    si.setHolder(de.getPackageElement().toString());
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   444
                                    break;
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   445
                                default:
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   446
                                    throw new IllegalStateException();
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   447
                            }
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   448
                            return null;
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   449
                        } else {
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   450
                            return super.visitUnknown(e, p);
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   451
                        }
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   452
                    }
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   453
6d243dcde190 8213956: javadoc crash using {@index} in doc-files file
jjg
parents: 52644
diff changeset
   454
                    @Override
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   455
                    protected Void defaultAction(Element e, Void p) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   456
                        si.setHolder(utils.getFullyQualifiedName(e));
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   457
                        return null;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   458
                    }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   459
                }.visit(element);
52695
99eb43bc3595 8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents: 52685
diff changeset
   460
                si.setCategory(SearchIndexItem.Category.SEARCH_TAGS);
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   461
                configuration.tagSearchIndex.add(si);
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   462
            }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   463
        }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   464
        return result;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
   465
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
}