src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
author pmuthuswamy
Fri, 22 Feb 2019 11:10:55 +0530
changeset 53885 e03bbe023e50
parent 53880 3f1e9372557f
child 54002 fb9541185457
permissions -rw-r--r--
8215584: Remove support for the "old" doclet API in com/sun/javadoc Reviewed-by: jjg, hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
     2
 * Copyright (c) 1998, 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: 3891
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: 3891
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: 3891
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3891
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3891
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;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
47849
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
    28
import jdk.javadoc.internal.doclets.formats.html.markup.Head;
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47748
diff changeset
    29
import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47748
diff changeset
    30
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.*;
51797
3efead10e303 8210047: some pages contain content outside of landmark region
pmuthuswamy
parents: 51190
diff changeset
    32
import java.util.function.Supplier;
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
    33
import java.util.regex.Matcher;
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
    34
import java.util.regex.Pattern;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    36
import javax.lang.model.element.AnnotationMirror;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    37
import javax.lang.model.element.AnnotationValue;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    38
import javax.lang.model.element.Element;
47328
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
    39
import javax.lang.model.element.ElementKind;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    40
import javax.lang.model.element.ExecutableElement;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
    41
import javax.lang.model.element.ModuleElement;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    42
import javax.lang.model.element.Name;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    43
import javax.lang.model.element.PackageElement;
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
    44
import javax.lang.model.element.QualifiedNameable;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    45
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    46
import javax.lang.model.element.VariableElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    47
import javax.lang.model.type.DeclaredType;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    48
import javax.lang.model.type.TypeMirror;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    49
import javax.lang.model.util.SimpleAnnotationValueVisitor9;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    50
import javax.lang.model.util.SimpleElementVisitor9;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    51
import javax.lang.model.util.SimpleTypeVisitor9;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    52
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    53
import com.sun.source.doctree.AttributeTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    54
import com.sun.source.doctree.AttributeTree.ValueKind;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    55
import com.sun.source.doctree.CommentTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    56
import com.sun.source.doctree.DocRootTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    57
import com.sun.source.doctree.DocTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    58
import com.sun.source.doctree.DocTree.Kind;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    59
import com.sun.source.doctree.EndElementTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    60
import com.sun.source.doctree.EntityTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    61
import com.sun.source.doctree.ErroneousTree;
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40508
diff changeset
    62
import com.sun.source.doctree.IndexTree;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    63
import com.sun.source.doctree.InheritDocTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    64
import com.sun.source.doctree.LinkTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    65
import com.sun.source.doctree.LiteralTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    66
import com.sun.source.doctree.SeeTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    67
import com.sun.source.doctree.StartElementTree;
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
    68
import com.sun.source.doctree.SummaryTree;
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
    69
import com.sun.source.doctree.SystemPropertyTree;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    70
import com.sun.source.doctree.TextTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    71
import com.sun.source.util.SimpleDocTreeVisitor;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    72
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    73
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    74
import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    75
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    76
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    77
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    78
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
    79
import jdk.javadoc.internal.doclets.formats.html.markup.Links;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    80
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
    81
import jdk.javadoc.internal.doclets.formats.html.markup.Script;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    82
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    83
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    84
import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    85
import jdk.javadoc.internal.doclets.toolkit.Content;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
    86
import jdk.javadoc.internal.doclets.toolkit.Messages;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    87
import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
    88
import jdk.javadoc.internal.doclets.toolkit.Resources;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    89
import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    90
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40508
diff changeset
    91
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    92
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40508
diff changeset
    93
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    94
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    95
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    96
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    97
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    98
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
    99
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   100
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   101
import static com.sun.source.doctree.DocTree.Kind.*;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   102
import static jdk.javadoc.internal.doclets.toolkit.util.CommentHelper.SPACER;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   103
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
 * Class for the Html Format Code Generation specific to JavaDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
 * This Class contains methods related to the Html Code Generation which
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
 * are used extensively while generating the entire documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
   110
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
   111
 *  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
   112
 *  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
   113
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
   114
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
 * @author Robert Field
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 2086
diff changeset
   117
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
 */
47852
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   119
public class HtmlDocletWriter {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * Relative path from the file getting generated to the destination
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * directory. For example, if the file getting generated is
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   124
     * "java/lang/Object.html", then the path to the root is "../..".
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * This string can be empty if the file getting generated is in
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * the destination directory.
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   128
    public final DocPath pathToRoot;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    /**
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   131
     * Platform-independent path from the current or the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * destination directory to the file getting generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * Used when creating the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   135
    public final DocPath path;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * Name of the file getting generated. If the file getting generated is
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * "java/lang/Object.html", then the filename is "Object.html".
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   141
    public final DocPath filename;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * The global configuration information for this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 43870
diff changeset
   146
    public final HtmlConfiguration configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 24603
diff changeset
   148
    protected final Utils utils;
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 24603
diff changeset
   149
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   150
    protected final Contents contents;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   151
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   152
    protected final Messages messages;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   153
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   154
    protected final Resources resources;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   155
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
   156
    protected final Links links;
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
   157
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
   158
    protected final DocPaths docPaths;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
   159
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   161
     * To check whether annotation heading is printed or not.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   162
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   163
    protected boolean printedAnnotationHeading = false;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   164
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   165
    /**
20237
b6d89903c867 8015249: javadoc fails to document static final fields in annotation types
bpatel
parents: 19920
diff changeset
   166
     * To check whether annotation field heading is printed or not.
b6d89903c867 8015249: javadoc fails to document static final fields in annotation types
bpatel
parents: 19920
diff changeset
   167
     */
b6d89903c867 8015249: javadoc fails to document static final fields in annotation types
bpatel
parents: 19920
diff changeset
   168
    protected boolean printedAnnotationFieldHeading = false;
b6d89903c867 8015249: javadoc fails to document static final fields in annotation types
bpatel
parents: 19920
diff changeset
   169
b6d89903c867 8015249: javadoc fails to document static final fields in annotation types
bpatel
parents: 19920
diff changeset
   170
    /**
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   171
     * To check whether the repeated annotations is documented or not.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   172
     */
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   173
    private boolean isAnnotationDocumented = false;
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   174
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   175
    /**
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   176
     * To check whether the container annotations is documented or not.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   177
     */
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   178
    private boolean isContainerDocumented = false;
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   179
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 31943
diff changeset
   180
    HtmlTree fixedNavDiv = new HtmlTree(HtmlTag.DIV);
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 31943
diff changeset
   181
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
   182
    /**
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   183
     * The window title of this file.
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   184
     */
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   185
    protected String winTitle;
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   186
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   187
    protected Script mainBodyScript;
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   188
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   189
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * Constructor to construct the HtmlStandardWriter object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     *
47852
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   192
     * @param configuration the configuration for this doclet
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   193
     * @param path the file to be generated.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 43870
diff changeset
   195
    public HtmlDocletWriter(HtmlConfiguration configuration, DocPath path) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        this.configuration = configuration;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   197
        this.contents = configuration.contents;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   198
        this.messages = configuration.messages;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   199
        this.resources = configuration.resources;
53562
0d9dee001667 8215577: Remove javadoc support for HTML 4
pmuthuswamy
parents: 53164
diff changeset
   200
        this.links = new Links(path);
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 24603
diff changeset
   201
        this.utils = configuration.utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        this.path = path;
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   203
        this.pathToRoot = path.parent().invert();
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   204
        this.filename = path.basename();
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
   205
        this.docPaths = configuration.docPaths;
47852
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   206
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   207
        messages.notice("doclet.Generating_0",
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   208
            DocFile.createFileForOutput(configuration, path).getPath());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * Replace {&#064;docRoot} tag used in options that accept HTML text, such
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * as -header, -footer, -top and -bottom, and when converting a relative
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * HREF where commentTagsToString inserts a {&#064;docRoot} where one was
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     * missing.  (Also see DocRootTaglet for {&#064;docRoot} tags in doc
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * comments.)
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * Replace {&#064;docRoot} tag in htmlstr with the relative path to the
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * destination directory from the directory where the file is being
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * written, looping to handle all such tags in htmlstr.
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     * For example, for "-d docs" and -header containing {&#064;docRoot}, when
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * the HTML page for source file p/C1.java is being generated, the
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * {&#064;docRoot} tag would be inserted into the header as "../",
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * the relative path from docs/p/ to docs/ (the document root).
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * Note: This doc comment was written with '&amp;#064;' representing '@'
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * to prevent the inline tag from being interpreted.
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    public String replaceDocRootDir(String htmlstr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        // Return if no inline tags exist
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        int index = htmlstr.indexOf("{@");
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        if (index < 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
            return htmlstr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        }
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   236
        Matcher docrootMatcher = docrootPattern.matcher(htmlstr);
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   237
        if (!docrootMatcher.find()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
            return htmlstr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        }
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 7681
diff changeset
   240
        StringBuilder buf = new StringBuilder();
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   241
        int prevEnd = 0;
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   242
        do {
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   243
            int match = docrootMatcher.start();
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   244
            // append htmlstr up to start of next {@docroot}
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   245
            buf.append(htmlstr.substring(prevEnd, match));
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   246
            prevEnd = docrootMatcher.end();
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   247
            if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) {
22005
4270ada5dcd1 8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents: 21494
diff changeset
   248
                // Insert the absolute link if {@docRoot} is followed by "/..".
9608
385a828ba236 6553182: Need to modify javadoc doclet for GPL
bpatel
parents: 9606
diff changeset
   249
                buf.append(configuration.docrootparent);
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   250
                prevEnd += 3;
9608
385a828ba236 6553182: Need to modify javadoc doclet for GPL
bpatel
parents: 9606
diff changeset
   251
            } else {
385a828ba236 6553182: Need to modify javadoc doclet for GPL
bpatel
parents: 9606
diff changeset
   252
                // Insert relative path where {@docRoot} was located
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   253
                buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath());
22005
4270ada5dcd1 8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents: 21494
diff changeset
   254
            }
4270ada5dcd1 8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents: 21494
diff changeset
   255
            // Append slash if next character is not a slash
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   256
            if (prevEnd < htmlstr.length() && htmlstr.charAt(prevEnd) != '/') {
22005
4270ada5dcd1 8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents: 21494
diff changeset
   257
                buf.append('/');
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
            }
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   259
        } while (docrootMatcher.find());
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   260
        buf.append(htmlstr.substring(prevEnd));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    }
24603
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   263
    //where:
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   264
        // Note: {@docRoot} is not case sensitive when passed in w/command line option:
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   265
        private static final Pattern docrootPattern =
43e7e44d63da 8043186: javac test langtools/tools/javac/util/StringUtilsTest.java fails
jlahoda
parents: 24221
diff changeset
   266
                Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   269
     * Get the script to show or hide the All classes link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   270
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   271
     * @param id id of the element to show or hide
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   272
     * @return a content tree for the script
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   273
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   274
    public Content getAllClassesLinkScript(String id) {
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   275
        Script script = new Script("<!--\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   276
                "  allClassesLink = document.getElementById(")
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   277
                .appendStringLiteral(id)
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   278
                .append(");\n" +
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   279
                "  if(window==top) {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   280
                "    allClassesLink.style.display = \"block\";\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   281
                "  }\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   282
                "  else {\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   283
                "    allClassesLink.style.display = \"none\";\n" +
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   284
                "  }\n" +
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   285
                "  //-->\n");
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
   286
        Content div = HtmlTree.DIV(script.asContent());
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   287
        Content div_noscript = HtmlTree.DIV(contents.noScriptMessage);
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   288
        Content noScript = HtmlTree.NOSCRIPT(div_noscript);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   289
        div.addContent(noScript);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   290
        return div;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   291
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   292
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   293
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   294
     * Add method information.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   295
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   296
     * @param method the method to be documented
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   297
     * @param dl the content tree to which the method information will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   298
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   299
    private void addMethodInfo(ExecutableElement method, Content dl) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   300
        TypeElement enclosing = utils.getEnclosingTypeElement(method);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   301
        List<? extends TypeMirror> intfacs = enclosing.getInterfaces();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   302
        ExecutableElement overriddenMethod = utils.overriddenMethod(method);
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
   303
        VisibleMemberTable vmt = configuration.getVisibleMemberTable(enclosing);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 2086
diff changeset
   304
        // Check whether there is any implementation or overridden info to be
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 2086
diff changeset
   305
        // printed. If no overridden or implementation info needs to be
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 2086
diff changeset
   306
        // printed, do not print this section.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   307
        if ((!intfacs.isEmpty()
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
   308
                && vmt.getImplementedMethods(method).isEmpty() == false)
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   309
                || overriddenMethod != null) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   310
            MethodWriterImpl.addImplementsInfo(this, method, dl);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
            if (overriddenMethod != null) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   312
                MethodWriterImpl.addOverridden(this,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   313
                        utils.overriddenType(method),
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   314
                        overriddenMethod,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   315
                        dl);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   320
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   321
     * Adds the tags information.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   322
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   323
     * @param e the Element for which the tags will be generated
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   324
     * @param htmltree the documentation tree to which the tags will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   325
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   326
    protected void addTagsInfo(Element e, Content htmltree) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   327
        if (configuration.nocomment) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   330
        Content dl = new HtmlTree(HtmlTag.DL);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   331
        if (utils.isExecutableElement(e) && !utils.isConstructor(e)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   332
            addMethodInfo((ExecutableElement)e, dl);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        }
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17573
diff changeset
   334
        Content output = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   335
        TagletWriter.genTagOutput(configuration.tagletManager, e,
50240
b9c483223a91 8202947: Fix minor issues with taglets
jjg
parents: 50116
diff changeset
   336
            configuration.tagletManager.getBlockTaglets(e),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                getTagletWriterInstance(false), output);
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17573
diff changeset
   338
        dl.addContent(output);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   339
        htmltree.addContent(dl);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    /**
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 2086
diff changeset
   343
     * Check whether there are any tags for Serialization Overview
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 2086
diff changeset
   344
     * section to be printed.
2086
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   345
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   346
     * @param field the VariableElement object to check for tags.
2086
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   347
     * @return true if there are tags to be printed else return false.
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   348
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   349
    protected boolean hasSerializationOverviewTags(VariableElement field) {
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17573
diff changeset
   350
        Content output = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   351
        TagletWriter.genTagOutput(configuration.tagletManager, field,
50240
b9c483223a91 8202947: Fix minor issues with taglets
jjg
parents: 50116
diff changeset
   352
                configuration.tagletManager.getBlockTaglets(field),
2086
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   353
                getTagletWriterInstance(false), output);
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17573
diff changeset
   354
        return !output.isEmpty();
2086
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   355
    }
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   356
cca2603eab0b 6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
bpatel
parents: 1789
diff changeset
   357
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * Returns a TagletWriter that knows how to write HTML.
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     *
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   360
     * @param isFirstSentence  true if we want to write the first sentence
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
     * @return a TagletWriter that knows how to write HTML.
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    public TagletWriter getTagletWriterInstance(boolean isFirstSentence) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
        return new TagletWriterImpl(this, isFirstSentence);
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
    /**
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   368
     * Returns a TagletWriter that knows how to write HTML.
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   369
     *
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   370
     * @param isFirstSentence  true if we want to write the first sentence
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   371
     * @param inSummary  true if tags are to be added in a summary section
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   372
     * @return a TagletWriter
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   373
     */
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   374
    public TagletWriter getTagletWriterInstance(boolean isFirstSentence, boolean inSummary) {
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   375
        return new TagletWriterImpl(this, isFirstSentence, inSummary);
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   376
    }
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   377
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
   378
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   379
     * Get Package link, with target frame.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   381
     * @param pkg The link will be to the "package-summary.html" page for this package
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   382
     * @param target name of the target frame
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   383
     * @param label tag for the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   384
     * @return a content for the target package link
10
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 getTargetPackageLink(PackageElement pkg, String target,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   387
            Content label) {
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   388
        return links.createLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY), label, "", target);
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 15035
diff changeset
   389
    }
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 15035
diff changeset
   390
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   391
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   392
     * Get Module Package link, with target frame.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   393
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   394
     * @param pkg the PackageElement
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   395
     * @param target name of the target frame
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   396
     * @param label tag for the link
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   397
     * @param mdle the module being documented
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   398
     * @return a content for the target module packages link
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   399
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   400
    public Content getTargetModulePackageLink(PackageElement pkg, String target,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   401
            Content label, ModuleElement mdle) {
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   402
        return links.createLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   403
                label, "", target);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   404
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   405
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   406
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   407
     * Get Module link, with target frame.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   408
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   409
     * @param target name of the target frame
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   410
     * @param label tag for the link
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   411
     * @param mdle the module being documented
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   412
     * @return a content for the target module link
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   413
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   414
    public Content getTargetModuleLink(String target, Content label, ModuleElement mdle) {
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   415
        return links.createLink(pathToRoot.resolve(
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
   416
                docPaths.moduleSummary(mdle)), label, "", target);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   417
    }
15723
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 15035
diff changeset
   418
58a73dac9ee4 8006124: javadoc/doclet should be updated to support profiles
bpatel
parents: 15035
diff changeset
   419
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   420
     * Generates the HTML document tree and prints it out.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   421
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   422
     * @param metakeywords Array of String keywords for META tag. Each element
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   423
     *                     of the array is assigned to a separate META tag.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   424
     *                     Pass in null for no array
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   425
     * @param description the content for the description META tag.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   426
     * @param body the body htmltree to be included in the document
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40508
diff changeset
   427
     * @throws DocFileIOException if there is a problem writing the file
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   428
     */
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   429
    public void printHtmlDocument(List<String> metakeywords,
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   430
                                  String description,
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   431
                                  Content body)
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   432
            throws DocFileIOException {
53880
3f1e9372557f 8219497: Unused parameter in HtmlDocletWriter::printHtmlDocument
jjg
parents: 53866
diff changeset
   433
        printHtmlDocument(metakeywords, description, new ContentBuilder(), body);
53164
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   434
    }
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   435
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   436
    /**
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   437
     * Generates the HTML document tree and prints it out.
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   438
     *
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   439
     * @param metakeywords Array of String keywords for META tag. Each element
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   440
     *                     of the array is assigned to a separate META tag.
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   441
     *                     Pass in null for no array
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   442
     * @param description the content for the description META tag.
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   443
     * @param extraHeadContent any additional content to be included in the HEAD element
53164
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   444
     * @param body the body htmltree to be included in the document
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   445
     * @throws DocFileIOException if there is a problem writing the file
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   446
     */
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   447
    public void printHtmlDocument(List<String> metakeywords,
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   448
                                  String description,
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   449
                                  Content extraHeadContent,
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   450
                                  Content body)
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   451
            throws DocFileIOException {
47848
6b1311fbbaba 8190819: Merge HtmlWriter into HtmlDocument
jjg
parents: 47847
diff changeset
   452
        Content htmlComment = contents.newPage;
53562
0d9dee001667 8215577: Remove javadoc support for HTML 4
pmuthuswamy
parents: 53164
diff changeset
   453
        Head head = new Head(path, configuration.docletVersion)
47849
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
   454
                .setTimestamp(!configuration.notimestamp)
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   455
                .setDescription(description)
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   456
                .setGenerator(getGenerator(getClass()))
47849
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
   457
                .setTitle(winTitle)
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
   458
                .setCharset(configuration.charset)
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
   459
                .addKeywords(metakeywords)
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
   460
                .setStylesheets(configuration.getMainStylesheet(), configuration.getAdditionalStylesheets())
48991
978c3036fbfc 8198522: Javadoc search broken after output files organization for modules
bpatel
parents: 48759
diff changeset
   461
                .setUseModuleDirectories(configuration.useModuleDirectories)
53164
f2140eebd91b 8214738: javadoc should honor styles in doc-files
pmuthuswamy
parents: 52487
diff changeset
   462
                .setIndex(configuration.createindex, mainBodyScript)
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
   463
                .addContent(extraHeadContent);
47848
6b1311fbbaba 8190819: Merge HtmlWriter into HtmlDocument
jjg
parents: 47847
diff changeset
   464
47849
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
   465
        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head.toContent(), body);
53562
0d9dee001667 8215577: Remove javadoc support for HTML 4
pmuthuswamy
parents: 53164
diff changeset
   466
        HtmlDocument htmlDocument = new HtmlDocument(htmlComment, htmlTree);
47848
6b1311fbbaba 8190819: Merge HtmlWriter into HtmlDocument
jjg
parents: 47847
diff changeset
   467
        htmlDocument.write(DocFile.createFileForOutput(configuration, path));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   468
    }
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
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   471
     * Get the window title.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   472
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   473
     * @param title the title string to construct the complete window title
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   474
     * @return the window title string
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
    public String getWindowTitle(String title) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   477
        if (configuration.windowtitle.length() > 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   478
            title += " (" + configuration.windowtitle  + ")";
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   479
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   480
        return title;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   481
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   482
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   483
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   484
     * Get user specified header and the footer.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   485
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   486
     * @param header if true print the user provided header else print the
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   487
     * user provided footer.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   488
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   489
    public Content getUserHeaderFooter(boolean header) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   490
        String content;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   491
        if (header) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   492
            content = replaceDocRootDir(configuration.header);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   493
        } else {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   494
            if (configuration.footer.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   495
                content = replaceDocRootDir(configuration.footer);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   496
            } else {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   497
                content = replaceDocRootDir(configuration.header);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   498
            }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   499
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   500
        Content rawContent = new RawHtml(content);
19254
0988183c8164 4749567: stddoclet: Add CSS style for setting header/footer to be italic
bpatel
parents: 19253
diff changeset
   501
        return rawContent;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   502
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   503
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
     * Adds the user specified top.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   506
     *
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   507
     * @param htmlTree the content tree to which user specified top will be added
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   508
     */
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   509
    public void addTop(Content htmlTree) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   510
        Content top = new RawHtml(replaceDocRootDir(configuration.top));
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 31943
diff changeset
   511
        fixedNavDiv.addContent(top);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   512
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   513
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   514
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   515
     * Adds the user specified bottom.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   516
     *
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   517
     * @param htmlTree the content tree to which user specified bottom will be added
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   518
     */
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   519
    public void addBottom(Content htmlTree) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   520
        Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   521
        Content small = HtmlTree.SMALL(bottom);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   522
        Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 26900
diff changeset
   523
        htmlTree.addContent(p);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   524
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   525
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   526
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   527
     * Get the overview tree link for the main tree.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   528
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   529
     * @param label the label for the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   530
     * @return a content tree for the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   531
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   532
    protected Content getNavLinkMainTree(String label) {
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   533
        Content mainTreeContent = links.createLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE),
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   534
                new StringContent(label));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   535
        Content li = HtmlTree.LI(mainTreeContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   536
        return li;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   540
     * Get table caption.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   541
     *
47427
251676148c62 8189405: More cleanup in HtmlWriter
jjg
parents: 47395
diff changeset
   542
     * @param title the content for the caption
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   543
     * @return a content tree for the caption
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   544
     */
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   545
    public Content getTableCaption(Content title) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   546
        Content captionSpan = HtmlTree.SPAN(title);
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   547
        Content space = Contents.SPACE;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   548
        Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   549
        Content caption = HtmlTree.CAPTION(captionSpan);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   550
        caption.addContent(tabSpan);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   551
        return caption;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   552
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   553
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   554
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   555
     * Returns a packagename content.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   556
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   557
     * @param packageElement the package to check
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   558
     * @return package name content
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   559
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   560
    public Content getPackageName(PackageElement packageElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   561
        return packageElement == null || packageElement.isUnnamed()
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
   562
                ? contents.defaultPackageLabel
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   563
                : getPackageLabel(packageElement.getQualifiedName());
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   564
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   565
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   566
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   567
     * Returns a package name label.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   568
     *
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 14258
diff changeset
   569
     * @param packageName the package name
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   570
     * @return the package name content
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   571
     */
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   572
    public Content getPackageLabel(CharSequence packageName) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   573
        return new StringContent(packageName);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   574
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   575
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   576
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   577
     * Return the path to the class page for a typeElement.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   579
     * @param te   TypeElement for which the path is requested.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
     * @param name Name of the file(doesn't include path).
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   582
    protected DocPath pathString(TypeElement te, DocPath name) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   583
        return pathString(utils.containingPackage(te), name);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
     * Return path to the given file name in the given package. So if the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
     * passed is "Object.html" and the name of the package is "java.lang", and
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
     * if the relative path is "../.." then returned string will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
     * "../../java/lang/Object.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   592
     * @param packageElement Package in which the file name is assumed to be.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
     * @param name File name, to which path string is.
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   595
    protected DocPath pathString(PackageElement packageElement, DocPath name) {
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
   596
        return pathToRoot.resolve(docPaths.forPackage(packageElement).resolve(name));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
    /**
26900
dccc7a72526d 8048351: tidy errors for attribute href, name for langtools javadoc tests needs investigation
bpatel
parents: 26665
diff changeset
   600
     * Given a package, return the name to be used in HTML anchor tag.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   601
     * @param packageElement the package.
26900
dccc7a72526d 8048351: tidy errors for attribute href, name for langtools javadoc tests needs investigation
bpatel
parents: 26665
diff changeset
   602
     * @return the name to be used in HTML anchor tag.
dccc7a72526d 8048351: tidy errors for attribute href, name for langtools javadoc tests needs investigation
bpatel
parents: 26665
diff changeset
   603
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   604
    public String getPackageAnchorName(PackageElement packageElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   605
        return packageElement == null || packageElement.isUnnamed()
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   606
                ? SectionName.UNNAMED_PACKAGE_ANCHOR.getName()
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   607
                : utils.getPackageName(packageElement);
26900
dccc7a72526d 8048351: tidy errors for attribute href, name for langtools javadoc tests needs investigation
bpatel
parents: 26665
diff changeset
   608
    }
dccc7a72526d 8048351: tidy errors for attribute href, name for langtools javadoc tests needs investigation
bpatel
parents: 26665
diff changeset
   609
dccc7a72526d 8048351: tidy errors for attribute href, name for langtools javadoc tests needs investigation
bpatel
parents: 26665
diff changeset
   610
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
     * Return the link to the given package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   613
     * @param packageElement the package to link to.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
     * @param label the label for the link.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   615
     * @return a content tree for the package link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   616
     */
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   617
    public Content getPackageLink(PackageElement packageElement, CharSequence label) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   618
        return getPackageLink(packageElement, new StringContent(label));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   619
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   620
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   621
    public Content getPackageLink(PackageElement packageElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   622
        StringContent content =  packageElement.isUnnamed()
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   623
                ? new StringContent()
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   624
                : new StringContent(utils.getPackageName(packageElement));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   625
        return getPackageLink(packageElement, content);
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   626
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   627
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   628
    /**
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   629
     * Return the link to the given package.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   630
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   631
     * @param packageElement the package to link to.
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   632
     * @param label the label for the link.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   633
     * @return a content tree for the package link.
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17561
diff changeset
   634
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   635
    public Content getPackageLink(PackageElement packageElement, Content label) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   636
        boolean included = packageElement != null && utils.isIncluded(packageElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   637
        if (!included) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   638
            for (PackageElement p : configuration.packages) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   639
                if (p.equals(packageElement)) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   640
                    included = true;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   641
                    break;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   642
                }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   643
            }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   644
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   645
        if (included || packageElement == null) {
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   646
            return links.createLink(pathString(packageElement, DocPaths.PACKAGE_SUMMARY),
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   647
                    label);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   648
        } else {
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   649
            DocLink crossPkgLink = getCrossPackageLink(packageElement);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   650
            if (crossPkgLink != null) {
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   651
                return links.createLink(crossPkgLink, label);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   652
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   653
                return label;
06bc494ca11e Initial load
duke
parents:
diff changeset
   654
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   655
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   658
    /**
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   659
     * Get Module link.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   660
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   661
     * @param mdle the module being documented
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   662
     * @param label tag for the link
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   663
     * @return a content for the module link
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   664
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   665
    public Content getModuleLink(ModuleElement mdle, Content label) {
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 42816
diff changeset
   666
        boolean included = utils.isIncluded(mdle);
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 42816
diff changeset
   667
        return (included)
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
   668
                ? links.createLink(pathToRoot.resolve(docPaths.moduleSummary(mdle)), label, "", "")
42831
feff6f296019 8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents: 42816
diff changeset
   669
                : label;
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   670
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 36500
diff changeset
   671
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   672
    public Content interfaceName(TypeElement typeElement, boolean qual) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   673
        Content name = new StringContent((qual)
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   674
                ? typeElement.getQualifiedName()
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   675
                : utils.getSimpleName(typeElement));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   676
        return (utils.isInterface(typeElement)) ?  HtmlTree.SPAN(HtmlStyle.interfaceName, name) : name;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   680
     * Add the link to the content tree.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   681
     *
50249
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   682
     * @param element program element for which the link will be added
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   683
     * @param label label for the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   684
     * @param htmltree 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
   685
     */
50249
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   686
    public void addSrcLink(Element element, Content label, Content htmltree) {
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   687
        if (element == null) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   688
            return;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   689
        }
50249
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   690
        TypeElement te = utils.getEnclosingTypeElement(element);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   691
        if (te == null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   692
            // must be a typeElement since in has no containing class.
50249
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   693
            te = (TypeElement) element;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   694
        }
50249
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   695
        if (utils.isIncluded(te)) {
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   696
            DocPath href = pathToRoot
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   697
                    .resolve(DocPaths.SOURCE_OUTPUT)
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   698
                    .resolve(docPaths.forClass(te));
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   699
            Content content = links.createLink(href
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   700
                    .fragment(SourceToHTMLConverter.getAnchorName(utils, element)), label, "", "");
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   701
            htmltree.addContent(content);
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   702
        } else {
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   703
            htmltree.addContent(label);
5715962c8831 8199307: NPE in jdk.javadoc.internal.doclets.toolkit.util.Utils.getLineNumber
pmuthuswamy
parents: 50240
diff changeset
   704
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   705
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   706
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   707
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   708
     * Return the link to the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   709
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   710
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   711
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
     * @return the link for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   714
    public Content getLink(LinkInfoImpl linkInfo) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
        LinkFactoryImpl factory = new LinkFactoryImpl(this);
17564
c329fe11193d 8011288: Erratic/inconsistent indentation of signatures
jjg
parents: 17563
diff changeset
   716
        return factory.getLink(linkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
     * Return the type parameters for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
     * @return the type for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   725
    public Content getTypeParameterLinks(LinkInfoImpl linkInfo) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
        LinkFactoryImpl factory = new LinkFactoryImpl(this);
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   727
        return factory.getTypeParameterLinks(linkInfo, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   728
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   729
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
    /*************************************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
   731
     * Return a class cross link to external class documentation.
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   732
     * The -link option does not allow users to
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   733
     * link to external classes in the "default" package.
06bc494ca11e Initial load
duke
parents:
diff changeset
   734
     *
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   735
     * @param classElement the class element
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   736
     * @param refMemName the name of the member being referenced.  This should
06bc494ca11e Initial load
duke
parents:
diff changeset
   737
     * be null or empty string if no member is being referenced.
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
     * @param label the label for the external link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   739
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   740
     * @param code true if the label should be code font.
47851
6a9bb4f77d50 8190822: Remove dead code that could lead to invalid HTML
jjg
parents: 47850
diff changeset
   741
     * @return the link
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   742
     */
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   743
    public Content getCrossClassLink(TypeElement classElement, String refMemName,
47851
6a9bb4f77d50 8190822: Remove dead code that could lead to invalid HTML
jjg
parents: 47850
diff changeset
   744
                                    Content label, boolean strong, boolean code) {
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   745
        if (classElement != null) {
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   746
            String className = utils.getSimpleName(classElement);
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   747
            PackageElement packageElement = utils.containingPackage(classElement);
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   748
            Content defaultLabel = new StringContent(className);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   749
            if (code)
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   750
                defaultLabel = HtmlTree.CODE(defaultLabel);
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   751
            if (getCrossPackageLink(packageElement) != null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   752
                /*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   753
                The package exists in external documentation, so link to the external
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   754
                class (assuming that it exists).  This is definitely a limitation of
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   755
                the -link option.  There are ways to determine if an external package
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   756
                exists, but no way to determine if the external class exists.  We just
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   757
                have to assume that it does.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   758
                */
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   759
                DocLink link = configuration.extern.getExternalLink(packageElement, pathToRoot,
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   760
                                className + ".html", refMemName);
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
   761
                return links.createLink(link,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   762
                    (label == null) || label.isEmpty() ? defaultLabel : label,
47851
6a9bb4f77d50 8190822: Remove dead code that could lead to invalid HTML
jjg
parents: 47850
diff changeset
   763
                    strong,
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   764
                    resources.getText("doclet.Href_Class_Or_Interface_Title",
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   765
                        utils.getPackageName(packageElement)), "", true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   766
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   767
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   768
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   769
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   770
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   771
    public boolean isClassLinkable(TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   772
        if (utils.isIncluded(typeElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   773
            return configuration.isGeneratedDoc(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   774
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   775
        return configuration.extern.isExternal(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   776
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   777
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   778
    public DocLink getCrossPackageLink(PackageElement element) {
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   779
        return configuration.extern.getExternalLink(element, pathToRoot,
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   780
            DocPaths.PACKAGE_SUMMARY.getPath());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   781
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   782
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   783
    public DocLink getCrossModuleLink(ModuleElement element) {
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   784
        return configuration.extern.getExternalLink(element, pathToRoot,
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
   785
            docPaths.moduleSummary(utils.getModuleName(element)).getPath());
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
   786
    }
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
   787
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   788
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   789
     * Get the class link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   790
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   791
     * @param context the id of the context where the link will be added
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   792
     * @param element to link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   793
     * @return a content tree for the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   794
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   795
    public Content getQualifiedClassLink(LinkInfoImpl.Kind context, Element element) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   796
        LinkInfoImpl linkInfoImpl = new LinkInfoImpl(configuration, context, (TypeElement)element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   797
        return getLink(linkInfoImpl.label(utils.getFullyQualifiedName(element)));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   798
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   799
06bc494ca11e Initial load
duke
parents:
diff changeset
   800
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   801
     * Add the class link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   802
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   803
     * @param context the id of the context where the link will be added
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   804
     * @param typeElement to link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   805
     * @param contentTree the content tree to which the link will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   806
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   807
    public void addPreQualifiedClassLink(LinkInfoImpl.Kind context, TypeElement typeElement, Content contentTree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   808
        addPreQualifiedClassLink(context, typeElement, false, contentTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   809
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   810
06bc494ca11e Initial load
duke
parents:
diff changeset
   811
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   812
     * Retrieve the class link with the package portion of the label in
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   813
     * plain text.  If the qualifier is excluded, it will not be included in the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   814
     * link label.
06bc494ca11e Initial load
duke
parents:
diff changeset
   815
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   816
     * @param typeElement the class to link to.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   817
     * @param isStrong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   818
     * @return the link with the package portion of the label in plain text.
06bc494ca11e Initial load
duke
parents:
diff changeset
   819
     */
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   820
    public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   821
            TypeElement typeElement, boolean isStrong) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   822
        ContentBuilder classlink = new ContentBuilder();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   823
        PackageElement pkg = utils.containingPackage(typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   824
        if (pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   825
            classlink.addContent(getEnclosingPackageName(typeElement));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   826
        }
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   827
        classlink.addContent(getLink(new LinkInfoImpl(configuration,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   828
                context, typeElement).label(utils.getSimpleName(typeElement)).strong(isStrong)));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   829
        return classlink;
06bc494ca11e Initial load
duke
parents:
diff changeset
   830
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   831
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   832
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   833
     * Add the class link with the package portion of the label in
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   834
     * plain text. If the qualifier is excluded, it will not be included in the
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   835
     * link label.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   836
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   837
     * @param context the id of the context where the link will be added
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   838
     * @param typeElement the class to link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   839
     * @param isStrong true if the link should be strong
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   840
     * @param contentTree the content tree to which the link with be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   841
     */
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 17547
diff changeset
   842
    public void addPreQualifiedClassLink(LinkInfoImpl.Kind context,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   843
            TypeElement typeElement, boolean isStrong, Content contentTree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   844
        PackageElement pkg = utils.containingPackage(typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   845
        if(pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   846
            contentTree.addContent(getEnclosingPackageName(typeElement));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   847
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   848
        LinkInfoImpl linkinfo = new LinkInfoImpl(configuration, context, typeElement)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   849
                .label(utils.getSimpleName(typeElement))
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   850
                .strong(isStrong);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   851
        Content link = getLink(linkinfo);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   852
        contentTree.addContent(link);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   853
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   854
06bc494ca11e Initial load
duke
parents:
diff changeset
   855
    /**
47852
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   856
     * Get the enclosed name of the package
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   857
     *
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   858
     * @param te  TypeElement
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   859
     * @return the name
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   860
     */
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   861
    public String getEnclosingPackageName(TypeElement te) {
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   862
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   863
        PackageElement encl = configuration.utils.containingPackage(te);
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   864
        return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   865
    }
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   866
90e0110a05f6 8190824: Eliminate HtmlDocWriter
jjg
parents: 47851
diff changeset
   867
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   868
     * Add the class link, with only class name as the strong link and prefixing
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   869
     * plain package name.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   870
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   871
     * @param context the id of the context where the link will be added
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   872
     * @param typeElement the class to link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   873
     * @param contentTree the content tree to which the link with be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   874
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   875
    public void addPreQualifiedStrongClassLink(LinkInfoImpl.Kind context, TypeElement typeElement, Content contentTree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   876
        addPreQualifiedClassLink(context, typeElement, true, contentTree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   877
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   878
06bc494ca11e Initial load
duke
parents:
diff changeset
   879
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   880
     * Get the link for the given member.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   881
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   882
     * @param context the id of the context where the link will be added
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   883
     * @param element the member being linked to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   884
     * @param label the label for the link
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   885
     * @return a content tree for the element link
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   886
     */
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   887
    public Content getDocLink(LinkInfoImpl.Kind context, Element element, CharSequence label) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   888
        return getDocLink(context, utils.getEnclosingTypeElement(element), element,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   889
                new StringContent(label));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   890
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   891
06bc494ca11e Initial load
duke
parents:
diff changeset
   892
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   893
     * Return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   894
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   895
     * @param context the id of the context where the link will be printed.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   896
     * @param element the member being linked to.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   897
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   898
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   899
     * @return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   900
     */
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   901
    public Content getDocLink(LinkInfoImpl.Kind context, Element element, CharSequence label,
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   902
            boolean strong) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   903
        return getDocLink(context, utils.getEnclosingTypeElement(element), element, label, strong);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   904
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   905
06bc494ca11e Initial load
duke
parents:
diff changeset
   906
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   907
     * Return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   908
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   909
     * @param context the id of the context where the link will be printed.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   910
     * @param typeElement the typeElement that we should link to.  This is not
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   911
                 necessarily equal to element.containingClass().  We may be
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   912
                 inheriting comments.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   913
     * @param element the member being linked to.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   914
     * @param label the label for the link.
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   915
     * @param strong true if the link should be strong.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   916
     * @return the link for the given member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   917
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   918
    public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   919
            CharSequence label, boolean strong) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   920
        return getDocLink(context, typeElement, element, label, strong, false);
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   921
    }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   922
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   923
    public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
17569
ef80738645e2 8012178: Cleanup use of Util.escapeHtmlChars
jjg
parents: 17568
diff changeset
   924
            Content label, boolean strong) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   925
        return getDocLink(context, typeElement, element, label, strong, false);
17569
ef80738645e2 8012178: Cleanup use of Util.escapeHtmlChars
jjg
parents: 17568
diff changeset
   926
    }
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   927
51190
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   928
    /**
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   929
     * Return the link for the given member.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   930
     *
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   931
     * @param context the id of the context where the link will be printed.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   932
     * @param typeElement the typeElement that we should link to.  This is not
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   933
                 necessarily equal to element.containingClass().  We may be
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   934
                 inheriting comments.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   935
     * @param element the member being linked to.
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   936
     * @param label the label for the link.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   937
     * @param strong true if the link should be strong.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   938
     * @param isProperty true if the element parameter is a JavaFX property.
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   939
     * @return the link for the given member.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
   940
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   941
    public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
   942
            CharSequence label, boolean strong, boolean isProperty) {
50612
e10812a82a3b 8204330: Javadoc IllegalArgumentException: HTML special chars in constant value
jjg
parents: 50249
diff changeset
   943
        return getDocLink(context, typeElement, element, new StringContent(label), strong, isProperty);
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   944
    }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   945
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   946
    public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   947
            Content label, boolean strong, boolean isProperty) {
51190
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   948
        if (!utils.isLinkable(typeElement, element)) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   949
            return label;
51190
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   950
        }
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   951
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   952
        if (utils.isExecutableElement(element)) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   953
            ExecutableElement ee = (ExecutableElement)element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   954
            return getLink(new LinkInfoImpl(configuration, context, typeElement)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   955
                .label(label)
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
   956
                .where(links.getName(getAnchor(ee, isProperty)))
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   957
                .strong(strong));
51190
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   958
        }
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   959
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   960
        if (utils.isVariableElement(element) || utils.isTypeElement(element)) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   961
            return getLink(new LinkInfoImpl(configuration, context, typeElement)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   962
                .label(label)
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
   963
                .where(links.getName(element.getSimpleName().toString()))
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   964
                .strong(strong));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   965
        }
51190
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   966
fb4a7b894fac 8207214: Broken links in JDK API serialized-form page
jjg
parents: 50612
diff changeset
   967
        return label;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   968
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   969
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   970
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   971
     * Return the link for the given member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   972
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   973
     * @param context the id of the context where the link will be added
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   974
     * @param typeElement the typeElement that we should link to.  This is not
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   975
                 necessarily equal to element.containingClass().  We may be
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   976
                 inheriting comments
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   977
     * @param element the member being linked to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   978
     * @param label the label for the link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   979
     * @return the link for the given member
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   980
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   981
    public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   982
            Content label) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   983
        if (! (utils.isIncluded(element) || utils.isLinkable(typeElement))) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   984
            return label;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   985
        } else if (utils.isExecutableElement(element)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   986
            ExecutableElement emd = (ExecutableElement) element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   987
            return getLink(new LinkInfoImpl(configuration, context, typeElement)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   988
                .label(label)
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
   989
                .where(links.getName(getAnchor(emd))));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   990
        } else if (utils.isVariableElement(element) || utils.isTypeElement(element)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   991
            return getLink(new LinkInfoImpl(configuration, context, typeElement)
47850
4a28dc8a86c2 8190821: Introduce a new Links builder class
jjg
parents: 47849
diff changeset
   992
                .label(label).where(links.getName(element.getSimpleName().toString())));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   993
        } else {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   994
            return label;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   995
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   996
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   997
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   998
    public String getAnchor(ExecutableElement executableElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   999
        return getAnchor(executableElement, false);
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
  1000
    }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
  1001
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1002
    public String getAnchor(ExecutableElement executableElement, boolean isProperty) {
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
  1003
        if (isProperty) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1004
            return executableElement.getSimpleName().toString();
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 15725
diff changeset
  1005
        }
47328
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1006
        String member = anchorName(executableElement);
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1007
        String erasedSignature = utils.makeSignature(executableElement, true, true);
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1008
        return member + erasedSignature;
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1009
    }
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1010
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1011
    public String anchorName(Element member) {
53562
0d9dee001667 8215577: Remove javadoc support for HTML 4
pmuthuswamy
parents: 53164
diff changeset
  1012
        if (member.getKind() == ElementKind.CONSTRUCTOR) {
47328
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1013
            return "<init>";
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1014
        } else {
d18df41954ba 8187521: In some corner cases the javadoc tool can reuse id attribute
jjg
parents: 47300
diff changeset
  1015
            return utils.getSimpleName(member);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1016
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1017
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1018
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1019
    public Content seeTagToContent(Element element, DocTree see) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1020
        Kind kind = see.getKind();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1021
        if (!(kind == LINK || kind == SEE || kind == LINK_PLAIN)) {
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
  1022
            return new ContentBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1023
        }
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
  1024
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1025
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1026
        String tagName = ch.getTagName(see);
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1027
        String seetext = replaceDocRootDir(utils.normalizeNewlines(ch.getText(see)).toString());
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1028
        // Check if @see is an href or "string"
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1029
        if (seetext.startsWith("<") || seetext.startsWith("\"")) {
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
  1030
            return new RawHtml(seetext);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1031
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1032
        boolean isLinkPlain = kind == LINK_PLAIN;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1033
        Content label = plainOrCode(isLinkPlain, new RawHtml(ch.getLabel(configuration, see)));
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
  1034
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1035
        //The text from the @see tag.  We will output this text when a label is not specified.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1036
        Content text = plainOrCode(kind == LINK_PLAIN, new RawHtml(seetext));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1037
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1038
        TypeElement refClass = ch.getReferencedClass(configuration, see);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1039
        String refClassName =  ch.getReferencedClassName(configuration, see);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1040
        Element refMem =       ch.getReferencedMember(configuration, see);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1041
        String refMemName =    ch.getReferencedMemberName(see);
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
  1042
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1043
        if (refMemName == null && refMem != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1044
            refMemName = refMem.toString();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1045
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1046
        if (refClass == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1047
            //@see is not referencing an included class
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1048
            PackageElement refPackage = ch.getReferencedPackage(configuration, see);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1049
            if (refPackage != null && utils.isIncluded(refPackage)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1050
                //@see is referencing an included package
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
  1051
                if (label.isEmpty())
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1052
                    label = plainOrCode(isLinkPlain,
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1053
                            new StringContent(refPackage.getQualifiedName()));
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
  1054
                return getPackageLink(refPackage, label);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1055
            } else {
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
  1056
                // @see is not referencing an included class, module or package. Check for cross links.
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
  1057
                DocLink elementCrossLink = (configuration.extern.isModule(refClassName))
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
  1058
                        ? getCrossModuleLink(utils.elementUtils.getModuleElement(refClassName)) :
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 51797
diff changeset
  1059
                        (refPackage != null) ? getCrossPackageLink(refPackage) : null;
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
  1060
                if (elementCrossLink != null) {
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
  1061
                    // Element cross link found
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 48295
diff changeset
  1062
                    return links.createLink(elementCrossLink,
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 48029
diff changeset
  1063
                            (label.isEmpty() ? text : label), true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1064
                } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1065
                    // No cross link found so print warning
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
  1066
                    messages.warning(ch.getDocTreePath(see),
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1067
                            "doclet.see.class_or_package_not_found",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1068
                            "@" + tagName,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1069
                            seetext);
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
  1070
                    return (label.isEmpty() ? text: label);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1071
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1072
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1073
        } else if (refMemName == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1074
            // Must be a class reference since refClass is not null and refMemName is null.
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
  1075
            if (label.isEmpty()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1076
                /*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1077
                 * it seems to me this is the right thing to do, but it causes comparator failures.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1078
                 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1079
                if (!configuration.backwardCompatibility) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1080
                    StringContent content = utils.isEnclosingPackageIncluded(refClass)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1081
                            ? new StringContent(utils.getSimpleName(refClass))
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1082
                            : new StringContent(utils.getFullyQualifiedName(refClass));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1083
                    label = plainOrCode(isLinkPlain, content);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1084
                } else {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1085
                    label = plainOrCode(isLinkPlain,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1086
                            new StringContent(utils.getSimpleName(refClass)));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1087
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1088
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1089
            }
17561
9f3505f35da9 8011651: simplify LinkInfoImpl API
jjg
parents: 17560
diff changeset
  1090
            return getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, refClass)
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
  1091
                    .label(label));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1092
        } else if (refMem == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1093
            // Must be a member reference since refClass is not null and refMemName is not null.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1094
            // However, refMem is null, so this referenced member does not exist.
17568
d9691936f5f9 8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents: 17567
diff changeset
  1095
            return (label.isEmpty() ? text: label);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1096
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1097
            // Must be a member reference since refClass is not null and refMemName is not null.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1098
            // refMem is not null, so this @see tag must be referencing a valid member.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1099
            TypeElement containing = utils.getEnclosingTypeElement(refMem);
47395
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1100
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1101
            // Find the enclosing type where the method is actually visible
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1102
            // in the inheritance hierarchy.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1103
            ExecutableElement overriddenMethod = null;
47395
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1104
            if (refMem.getKind() == ElementKind.METHOD) {
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1105
                VisibleMemberTable vmt = configuration.getVisibleMemberTable(containing);
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1106
                overriddenMethod = vmt.getOverriddenMethod((ExecutableElement)refMem);
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1107
47395
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1108
                if (overriddenMethod != null)
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1109
                    containing = utils.getEnclosingTypeElement(overriddenMethod);
2ea4edfdef8e 8157000: Do not generate javadoc for overridden method with no spec change
ksrini
parents: 47328
diff changeset
  1110
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1111
            if (ch.getText(see).trim().startsWith("#") &&
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1112
                ! (utils.isPublic(containing) || utils.isLinkable(containing))) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1113
                // Since the link is relative and the holder is not even being
06bc494ca11e Initial load
duke
parents:
diff changeset
  1114
                // documented, this must be an inherited link.  Redirect it.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1115
                // The current class either overrides the referenced member or
06bc494ca11e Initial load
duke
parents:
diff changeset
  1116
                // inherits it automatically.
3891
69ac41cb327b 5093723: REGRESSION: ClassCastException in SingleIndexWriter
jjg
parents: 2321
diff changeset
  1117
                if (this instanceof ClassWriterImpl) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1118
                    containing = ((ClassWriterImpl) this).getTypeElement();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1119
                } else if (!utils.isPublic(containing)) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
  1120
                    messages.warning(
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1121
                        ch.getDocTreePath(see), "doclet.see.class_or_package_not_accessible",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1122
                        tagName, utils.getFullyQualifiedName(containing));
3891
69ac41cb327b 5093723: REGRESSION: ClassCastException in SingleIndexWriter
jjg
parents: 2321
diff changeset
  1123
                } else {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
  1124
                    messages.warning(
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1125
                        ch.getDocTreePath(see), "doclet.see.class_or_package_not_found",
3891
69ac41cb327b 5093723: REGRESSION: ClassCastException in SingleIndexWriter
jjg
parents: 2321
diff changeset
  1126
                        tagName, seetext);
69ac41cb327b 5093723: REGRESSION: ClassCastException in SingleIndexWriter
jjg
parents: 2321
diff changeset
  1127
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1128
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1129
            if (configuration.currentTypeElement != containing) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1130
                refMemName = (utils.isConstructor(refMem))
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1131
                        ? refMemName
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1132
                        : utils.getSimpleName(containing) + "." + refMemName;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1133
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1134
            if (utils.isExecutableElement(refMem)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1135
                if (refMemName.indexOf('(') < 0) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1136
                    refMemName += utils.makeSignature((ExecutableElement)refMem, true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1137
                }
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1138
                if (overriddenMethod != null) {
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1139
                    // The method to actually link.
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1140
                    refMem = overriddenMethod;
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1141
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1142
            }
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
  1143
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1144
            text = plainOrCode(kind == LINK_PLAIN, new StringContent(refMemName));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1145
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 17547
diff changeset
  1146
            return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1147
                    refMem, (label.isEmpty() ? text: label), false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1148
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1149
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1150
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
  1151
    private Content plainOrCode(boolean plain, Content body) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
  1152
        return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
  1153
    }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
  1154
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1155
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1156
     * Add the inline comment.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1157
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1158
     * @param element the Element for which the inline comment will be added
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1159
     * @param tag the inline tag to be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1160
     * @param htmltree the content tree to which the comment will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1161
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1162
    public void addInlineComment(Element element, DocTree tag, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1163
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1164
        List<? extends DocTree> description = ch.getDescription(configuration, tag);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1165
        addCommentTags(element, tag, description, false, false, false, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1166
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1167
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1168
    /**
42816
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1169
     * Get the deprecated phrase as content.
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1170
     *
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1171
     * @param e the Element for which the inline deprecated comment will be added
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1172
     * @return a content tree for the deprecated phrase.
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1173
     */
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1174
    public Content getDeprecatedPhrase(Element e) {
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1175
        return (utils.isDeprecatedForRemoval(e))
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1176
                ? contents.deprecatedForRemovalPhrase
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1177
                : contents.deprecatedPhrase;
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1178
    }
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1179
3638773ff1b0 8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents: 42408
diff changeset
  1180
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1181
     * Add the inline deprecated comment.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1182
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1183
     * @param e the Element for which the inline deprecated comment will be added
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1184
     * @param tag the inline tag to be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1185
     * @param htmltree the content tree to which the comment will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1186
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1187
    public void addInlineDeprecatedComment(Element e, DocTree tag, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1188
        CommentHelper ch = utils.getCommentHelper(e);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1189
        addCommentTags(e, ch.getBody(configuration, tag), true, false, false, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1190
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1191
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1192
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1193
     * Adds the summary content.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1194
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1195
     * @param element the Element for which the summary will be generated
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1196
     * @param htmltree the documentation tree to which the summary will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1197
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1198
    public void addSummaryComment(Element element, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1199
        addSummaryComment(element, utils.getFirstSentenceTrees(element), htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1200
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1201
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1202
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1203
     * Adds the summary content.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1204
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1205
     * @param element the Element for which the summary will be generated
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1206
     * @param firstSentenceTags the first sentence tags for the doc
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1207
     * @param htmltree the documentation tree to which the summary will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1208
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1209
    public void addSummaryComment(Element element, List<? extends DocTree> firstSentenceTags, Content htmltree) {
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1210
        addCommentTags(element, firstSentenceTags, false, true, true, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1211
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1212
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1213
    public void addSummaryDeprecatedComment(Element element, DocTree tag, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1214
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1215
        List<? extends DocTree> body = ch.getBody(configuration, tag);
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1216
        addCommentTags(element, ch.getFirstSentenceTrees(configuration, body), true, true, true, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1217
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1218
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1219
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1220
     * Adds the inline comment.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1221
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1222
     * @param element the Element for which the inline comments will be generated
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1223
     * @param htmltree the documentation tree to which the inline comments will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1224
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1225
    public void addInlineComment(Element element, Content htmltree) {
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1226
        addCommentTags(element, utils.getFullBody(element), false, false, false, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1227
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1228
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1229
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1230
     * Adds the comment tags.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1231
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1232
     * @param element the Element for which the comment tags will be generated
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1233
     * @param tags the first sentence tags for the doc
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1234
     * @param depr true if it is deprecated
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
  1235
     * @param first true if the first sentence tags should be added
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1236
     * @param inSummary true if the comment tags are added into the summary section
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1237
     * @param htmltree the documentation tree to which the comment tags will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1238
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1239
    private void addCommentTags(Element element, List<? extends DocTree> tags, boolean depr,
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1240
            boolean first, boolean inSummary, Content htmltree) {
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1241
        addCommentTags(element, null, tags, depr, first, inSummary, htmltree);
17547
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1242
    }
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1243
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1244
    /**
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1245
     * Adds the comment tags.
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1246
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1247
     * @param element for which the comment tags will be generated
17547
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1248
     * @param holderTag the block tag context for the inline tags
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1249
     * @param tags the first sentence tags for the doc
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1250
     * @param depr true if it is deprecated
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1251
     * @param first true if the first sentence tags should be added
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1252
     * @param inSummary true if the comment tags are added into the summary section
17547
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1253
     * @param htmltree the documentation tree to which the comment tags will be added
40f2f9a5a445 8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents: 16964
diff changeset
  1254
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1255
    private void addCommentTags(Element element, DocTree holderTag, List<? extends DocTree> tags, boolean depr,
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1256
            boolean first, boolean inSummary, Content htmltree) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1257
        if(configuration.nocomment){
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1258
            return;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1259
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1260
        Content div;
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1261
        Content result = commentTagsToContent(null, element, tags, first, inSummary);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1262
        if (depr) {
47300
a905ce398074 8074407: javadoc: using <pre> after @deprecated tag causes warnings
bpatel
parents: 47216
diff changeset
  1263
            div = HtmlTree.DIV(HtmlStyle.deprecationComment, result);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1264
            htmltree.addContent(div);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1265
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1266
        else {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1267
            div = HtmlTree.DIV(HtmlStyle.block, result);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1268
            htmltree.addContent(div);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1269
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1270
        if (tags.isEmpty()) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
  1271
            htmltree.addContent(Contents.SPACE);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1272
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1273
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1274
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1275
    boolean ignoreNonInlineTag(DocTree dtree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1276
        Name name = null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1277
        if (dtree.getKind() == Kind.START_ELEMENT) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1278
            StartElementTree setree = (StartElementTree)dtree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1279
            name = setree.getName();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1280
        } else if (dtree.getKind() == Kind.END_ELEMENT) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1281
            EndElementTree eetree = (EndElementTree)dtree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1282
            name = eetree.getName();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1283
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1284
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1285
        if (name != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1286
            com.sun.tools.doclint.HtmlTag htmlTag = com.sun.tools.doclint.HtmlTag.get(name);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1287
            if (htmlTag != null &&
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1288
                    htmlTag.blockType != com.sun.tools.doclint.HtmlTag.BlockType.INLINE) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1289
                return true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1290
            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1291
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1292
        return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1293
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1294
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1295
    boolean isAllWhiteSpace(String body) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1296
        for (int i = 0 ; i < body.length(); i++) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1297
            if (!Character.isWhitespace(body.charAt(i)))
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1298
                return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1299
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1300
        return true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1301
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1302
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1303
    // Notify the next DocTree handler to take necessary action
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1304
    private boolean commentRemoved = false;
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1305
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1306
    /**
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1307
     * Converts inline tags and text to Content, expanding the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1308
     * inline tags along the way.  Called wherever text can contain
06bc494ca11e Initial load
duke
parents:
diff changeset
  1309
     * an inline tag, such as in comments or in free-form text arguments
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1310
     * to block tags.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1311
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1312
     * @param holderTag    specific tag where comment resides
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1313
     * @param element    specific element where comment resides
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1314
     * @param tags   array of text tags and inline tags (often alternating)
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1315
               present in the text of interest for this element
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1316
     * @param isFirstSentence  true if text is first sentence
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1317
     * @return a Content object
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1318
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1319
    public Content commentTagsToContent(DocTree holderTag, Element element,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1320
            List<? extends DocTree> tags, boolean isFirstSentence) {
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1321
        return commentTagsToContent(holderTag, element, tags, isFirstSentence, false);
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1322
    }
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1323
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1324
    /**
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1325
     * Converts inline tags and text to text strings, expanding the
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1326
     * inline tags along the way.  Called wherever text can contain
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1327
     * an inline tag, such as in comments or in free-form text arguments
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1328
     * to block tags.
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1329
     *
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1330
     * @param holderTag    specific tag where comment resides
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1331
     * @param element    specific element where comment resides
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1332
     * @param tags   array of text tags and inline tags (often alternating)
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1333
    present in the text of interest for this element
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1334
     * @param isFirstSentence  true if text is first sentence
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1335
     * @param inSummary   if the comment tags are added into the summary section
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1336
     * @return a Content object
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1337
     */
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1338
    public Content commentTagsToContent(DocTree holderTag, Element element,
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1339
            List<? extends DocTree> tags, boolean isFirstSentence, boolean inSummary) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1340
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1341
        final Content result = new ContentBuilder() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1342
            @Override
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1343
            public void addContent(CharSequence text) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1344
                super.addContent(utils.normalizeNewlines(text));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1345
            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1346
        };
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1347
        CommentHelper ch = utils.getCommentHelper(element);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1348
        // Array of all possible inline tags for this javadoc run
50240
b9c483223a91 8202947: Fix minor issues with taglets
jjg
parents: 50116
diff changeset
  1349
        configuration.tagletManager.checkTags(element, tags, true);
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1350
        commentRemoved = false;
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1351
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1352
        for (ListIterator<? extends DocTree> iterator = tags.listIterator(); iterator.hasNext();) {
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1353
            boolean isFirstNode = !iterator.hasPrevious();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1354
            DocTree tag = iterator.next();
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1355
            boolean isLastNode  = !iterator.hasNext();
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1356
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1357
            if (isFirstSentence) {
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1358
                // Ignore block tags
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1359
                if (ignoreNonInlineTag(tag))
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1360
                    continue;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1361
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1362
                // Ignore any trailing whitespace OR whitespace after removed html comment
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1363
                if ((isLastNode || commentRemoved)
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1364
                        && tag.getKind() == TEXT
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1365
                        && isAllWhiteSpace(ch.getText(tag)))
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1366
                    continue;
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1367
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1368
                // Ignore any leading html comments
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1369
                if ((isFirstNode || commentRemoved) && tag.getKind() == COMMENT) {
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1370
                    commentRemoved = true;
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1371
                    continue;
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1372
                }
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1373
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1374
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1375
            boolean allDone = new SimpleDocTreeVisitor<Boolean, Content>() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1376
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1377
                private boolean inAnAtag() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1378
                    if (utils.isStartElement(tag)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1379
                        StartElementTree st = (StartElementTree)tag;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1380
                        Name name = st.getName();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1381
                        if (name != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1382
                            com.sun.tools.doclint.HtmlTag htag =
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1383
                                    com.sun.tools.doclint.HtmlTag.get(name);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1384
                            return htag != null && htag.equals(com.sun.tools.doclint.HtmlTag.A);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1385
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1386
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1387
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1388
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1389
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1390
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1391
                public Boolean visitAttribute(AttributeTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1392
                    StringBuilder sb = new StringBuilder(SPACER).append(node.getName());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1393
                    if (node.getValueKind() == ValueKind.EMPTY) {
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1394
                        result.addContent(sb);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1395
                        return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1396
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1397
                    sb.append("=");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1398
                    String quote;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1399
                    switch (node.getValueKind()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1400
                        case DOUBLE:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1401
                            quote = "\"";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1402
                            break;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1403
                        case SINGLE:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1404
                            quote = "\'";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1405
                            break;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1406
                        default:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1407
                            quote = "";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1408
                            break;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1409
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1410
                    sb.append(quote);
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1411
                    result.addContent(sb);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1412
                    Content docRootContent = new ContentBuilder();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1413
48655
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 48654
diff changeset
  1414
                    boolean isHRef = inAnAtag() && node.getName().toString().equalsIgnoreCase("href");
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1415
                    for (DocTree dt : node.getValue()) {
48655
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 48654
diff changeset
  1416
                        if (utils.isText(dt) && isHRef) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1417
                            String text = ((TextTree) dt).getBody();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1418
                            if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1419
                                result.addContent(configuration.docrootparent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1420
                                docRootContent = new ContentBuilder();
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1421
                                result.addContent(textCleanup(text.substring(3), isLastNode));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1422
                            } else {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1423
                                if (!docRootContent.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1424
                                    docRootContent = copyDocRootContent(docRootContent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1425
                                } else {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1426
                                    text = redirectRelativeLinks(element, (TextTree) dt);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1427
                                }
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1428
                                result.addContent(textCleanup(text, isLastNode));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1429
                            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1430
                        } else {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1431
                            docRootContent = copyDocRootContent(docRootContent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1432
                            dt.accept(this, docRootContent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1433
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1434
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1435
                    copyDocRootContent(docRootContent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1436
                    result.addContent(quote);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1437
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1438
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1439
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1440
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1441
                public Boolean visitComment(CommentTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1442
                    result.addContent(new RawHtml(node.getBody()));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1443
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1444
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1445
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1446
                private Content copyDocRootContent(Content content) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1447
                    if (!content.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1448
                        result.addContent(content);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1449
                        return new ContentBuilder();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1450
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1451
                    return content;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1452
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1453
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1454
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1455
                public Boolean visitDocRoot(DocRootTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1456
                    Content docRootContent = TagletWriter.getInlineTagOutput(element,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1457
                            configuration.tagletManager,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1458
                            holderTag,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1459
                            node,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1460
                            getTagletWriterInstance(isFirstSentence));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1461
                    if (c != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1462
                        c.addContent(docRootContent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1463
                    } else {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1464
                        result.addContent(docRootContent);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1465
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1466
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1467
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1468
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1469
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1470
                public Boolean visitEndElement(EndElementTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1471
                    RawHtml rawHtml = new RawHtml("</" + node.getName() + ">");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1472
                    result.addContent(rawHtml);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1473
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1474
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1475
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1476
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1477
                public Boolean visitEntity(EntityTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1478
                    result.addContent(new RawHtml(node.toString()));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1479
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1480
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1481
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1482
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1483
                public Boolean visitErroneous(ErroneousTree node, Content c) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39670
diff changeset
  1484
                    messages.warning(ch.getDocTreePath(node),
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1485
                            "doclet.tag.invalid_usage", node);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1486
                    result.addContent(new RawHtml(node.toString()));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1487
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1488
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1489
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1490
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1491
                public Boolean visitInheritDoc(InheritDocTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1492
                    Content output = TagletWriter.getInlineTagOutput(element,
22005
4270ada5dcd1 8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents: 21494
diff changeset
  1493
                            configuration.tagletManager, holderTag,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1494
                            tag, getTagletWriterInstance(isFirstSentence));
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17573
diff changeset
  1495
                    result.addContent(output);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1496
                    // if we obtained the first sentence successfully, nothing more to do
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1497
                    return (isFirstSentence && !output.isEmpty());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1498
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1499
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1500
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1501
                public Boolean visitIndex(IndexTree node, Content p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1502
                    Content output = TagletWriter.getInlineTagOutput(element,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1503
                            configuration.tagletManager, holderTag, tag,
51862
c319db69099c 8202462: {@index} may cause duplicate labels
pmuthuswamy
parents: 51861
diff changeset
  1504
                            getTagletWriterInstance(isFirstSentence, inSummary));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1505
                    if (output != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1506
                        result.addContent(output);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1507
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1508
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1509
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1510
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1511
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1512
                public Boolean visitLink(LinkTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1513
                    // we need to pass the DocTreeImpl here, so ignore node
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1514
                    result.addContent(seeTagToContent(element, tag));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1515
                    return false;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1516
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1517
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1518
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1519
                public Boolean visitLiteral(LiteralTree node, Content c) {
50116
cebd0673feeb 8203176: javadoc handles non-ASCII characters incorrectly.
jjg
parents: 49879
diff changeset
  1520
                    String s = node.getBody().getBody();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1521
                    Content content = new StringContent(utils.normalizeNewlines(s));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1522
                    if (node.getKind() == CODE)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1523
                        content = HtmlTree.CODE(content);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1524
                    result.addContent(content);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1525
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1526
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1527
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1528
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1529
                public Boolean visitSee(SeeTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1530
                    // we need to pass the DocTreeImpl here, so ignore node
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1531
                    result.addContent(seeTagToContent(element, tag));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1532
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1533
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1534
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1535
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1536
                public Boolean visitStartElement(StartElementTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1537
                    String text = "<" + node.getName();
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1538
                    RawHtml rawHtml = new RawHtml(utils.normalizeNewlines(text));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1539
                    result.addContent(rawHtml);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1540
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1541
                    for (DocTree dt : node.getAttributes()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1542
                        dt.accept(this, null);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1543
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1544
                    result.addContent(new RawHtml(node.isSelfClosing() ? "/>" : ">"));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1545
                    return false;
9608
385a828ba236 6553182: Need to modify javadoc doclet for GPL
bpatel
parents: 9606
diff changeset
  1546
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1547
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1548
                @Override
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1549
                public Boolean visitSummary(SummaryTree node, Content c) {
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1550
                    Content output = TagletWriter.getInlineTagOutput(element,
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1551
                            configuration.tagletManager, holderTag, tag,
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1552
                            getTagletWriterInstance(isFirstSentence));
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1553
                    result.addContent(output);
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1554
                    return false;
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1555
                }
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 46080
diff changeset
  1556
52487
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1557
                @Override
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1558
                public Boolean visitSystemProperty(SystemPropertyTree node, Content p) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1559
                    Content output = TagletWriter.getInlineTagOutput(element,
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1560
                            configuration.tagletManager, holderTag, tag,
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1561
                            getTagletWriterInstance(isFirstSentence, inSummary));
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1562
                    if (output != null) {
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1563
                        result.addContent(output);
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1564
                    }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1565
                    return false;
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1566
                }
5d1d07b72f15 5076751: System properties documentation needed in javadocs
pmuthuswamy
parents: 51862
diff changeset
  1567
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1568
                private CharSequence textCleanup(String text, boolean isLast) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1569
                    return textCleanup(text, isLast, false);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1570
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1571
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1572
                private CharSequence textCleanup(String text, boolean isLast, boolean trimLeader) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1573
                    if (trimLeader) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1574
                        text = removeLeadingWhitespace(text);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1575
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1576
                    if (isFirstSentence && isLast) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1577
                        text = removeTrailingWhitespace(text);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1578
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1579
                    text = utils.replaceTabs(text);
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1580
                    return utils.normalizeNewlines(text);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1581
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1582
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1583
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1584
                public Boolean visitText(TextTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1585
                    String text = node.getBody();
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1586
                    result.addContent(new RawHtml(textCleanup(text, isLastNode, commentRemoved)));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1587
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1588
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1589
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1590
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1591
                protected Boolean defaultAction(DocTree node, Content c) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1592
                    Content output = TagletWriter.getInlineTagOutput(element,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1593
                            configuration.tagletManager, holderTag, tag,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1594
                            getTagletWriterInstance(isFirstSentence));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1595
                    if (output != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1596
                        result.addContent(output);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1597
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1598
                    return false;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1599
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1600
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1601
            }.visit(tag, null);
45860
0952e2c6545a 8179704: doclet crashes with an empty package.html
ksrini
parents: 45417
diff changeset
  1602
            commentRemoved = false;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1603
            if (allDone)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1604
                break;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1605
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1606
        return result;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1607
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1608
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1609
    private String removeTrailingWhitespace(String text) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1610
        char[] buf = text.toCharArray();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1611
        for (int i = buf.length - 1; i > 0 ; i--) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1612
            if (!Character.isWhitespace(buf[i]))
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1613
                return text.substring(0, i + 1);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1614
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1615
        return text;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1616
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1617
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1618
    private String removeLeadingWhitespace(String text) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1619
        char[] buf = text.toCharArray();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1620
        for (int i = 0; i < buf.length; i++) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1621
            if (!Character.isWhitespace(buf[i])) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1622
                return text.substring(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1623
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1624
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1625
        return text;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1626
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1627
06bc494ca11e Initial load
duke
parents:
diff changeset
  1628
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1629
     * Return true if relative links should not be redirected.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1630
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1631
     * @return Return true if a relative link should not be redirected.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1632
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1633
    private boolean shouldNotRedirectRelativeLinks() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1634
        return  this instanceof AnnotationTypeWriter ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1635
                this instanceof ClassWriter ||
06bc494ca11e Initial load
duke
parents:
diff changeset
  1636
                this instanceof PackageSummaryWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1637
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1638
06bc494ca11e Initial load
duke
parents:
diff changeset
  1639
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1640
     * Suppose a piece of documentation has a relative link.  When you copy
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
  1641
     * that documentation to another place such as the index or class-use page,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1642
     * that relative link will no longer work.  We should redirect those links
06bc494ca11e Initial load
duke
parents:
diff changeset
  1643
     * so that they will work again.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1644
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
  1645
     * Here is the algorithm used to fix the link:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1646
     * <p>
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 9608
diff changeset
  1647
     * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1648
     * <p>
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1649
     * For example, suppose DocletEnvironment has this link:
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 9608
diff changeset
  1650
     * {@literal <a href="package-summary.html">The package Page</a> }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1651
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
  1652
     * If this link appeared in the index, we would redirect
06bc494ca11e Initial load
duke
parents:
diff changeset
  1653
     * the link like this:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1654
     *
53885
e03bbe023e50 8215584: Remove support for the "old" doclet API in com/sun/javadoc
pmuthuswamy
parents: 53880
diff changeset
  1655
     * {@literal <a href="./jdk/javadoc/doclet/package-summary.html">The package Page</a>}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1656
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1657
     * @param element the Element object whose documentation is being written.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1658
     * @param tt the text being written.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1659
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1660
     * @return the text, with all the relative links redirected to work.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1661
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1662
    private String redirectRelativeLinks(Element element, TextTree tt) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1663
        String text = tt.getBody();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1664
        if (element == null || utils.isOverviewElement(element) || shouldNotRedirectRelativeLinks()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1665
            return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1666
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1667
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1668
        DocPath redirectPathFromRoot = new SimpleElementVisitor9<DocPath, Void>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1669
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1670
            public DocPath visitType(TypeElement e, Void p) {
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
  1671
                return docPaths.forPackage(utils.containingPackage(e));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1672
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1673
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1674
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1675
            public DocPath visitPackage(PackageElement e, Void p) {
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
  1676
                return docPaths.forPackage(e);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1677
            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1678
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1679
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1680
            public DocPath visitVariable(VariableElement e, Void p) {
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
  1681
                return docPaths.forPackage(utils.containingPackage(e));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1682
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1683
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1684
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1685
            public DocPath visitExecutable(ExecutableElement e, Void p) {
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents: 48756
diff changeset
  1686
                return docPaths.forPackage(utils.containingPackage(e));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1687
            }
23123
fd8ad69ac7fe 6457406: javadoc doesn't handle <a href='http://...'> properly in producing index pages
yan
parents: 22163
diff changeset
  1688
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1689
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1690
            protected DocPath defaultAction(Element e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1691
                return null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1692
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1693
        }.visit(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1694
        if (redirectPathFromRoot == null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1695
            return text;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1696
        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1697
        String lower = Utils.toLowerCase(text);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1698
        if (!(lower.startsWith("mailto:")
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1699
                || lower.startsWith("http:")
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1700
                || lower.startsWith("https:")
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1701
                || lower.startsWith("file:"))) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1702
            text = "{@" + (new DocRootTaglet()).getName() + "}/"
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1703
                    + redirectPathFromRoot.resolve(text).getPath();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1704
            text = replaceDocRootDir(text);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1705
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1706
        return text;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1707
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1708
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
  1709
    /**
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8631
diff changeset
  1710
     * According to
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8631
diff changeset
  1711
     * <cite>The Java&trade; Language Specification</cite>,
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8631
diff changeset
  1712
     * all the outer classes and static nested classes are core classes.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1713
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1714
    public boolean isCoreClass(TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1715
        return utils.getEnclosingTypeElement(typeElement) == null || utils.isStatic(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1716
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1717
06bc494ca11e Initial load
duke
parents:
diff changeset
  1718
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1719
     * Adds the annotation types for the given packageElement.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1720
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1721
     * @param packageElement the package to write annotations for.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1722
     * @param htmltree the documentation tree to which the annotation info will be
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1723
     *        added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1724
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1725
    public void addAnnotationInfo(PackageElement packageElement, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1726
        addAnnotationInfo(packageElement, packageElement.getAnnotationMirrors(), htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1727
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1728
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1729
    /**
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1730
     * Add the annotation types of the executable receiver.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1731
     *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1732
     * @param method the executable to write the receiver annotations for.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1733
     * @param descList a list of annotation mirrors.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1734
     * @param htmltree the documentation tree to which the annotation info will be
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1735
     *        added
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1736
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1737
    public void addReceiverAnnotationInfo(ExecutableElement method, List<AnnotationMirror> descList,
16964
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16319
diff changeset
  1738
            Content htmltree) {
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16319
diff changeset
  1739
        addAnnotationInfo(0, method, descList, false, htmltree);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1740
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1741
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1742
    /*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1743
     * this is a hack to delay dealing with Annotations in the writers, the assumption
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1744
     * is that all necessary checks have been made to get here.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1745
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1746
    public void addReceiverAnnotationInfo(ExecutableElement method, TypeMirror rcvrTypeMirror,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1747
            List<? extends AnnotationMirror> annotationMirrors, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1748
        TypeMirror rcvrType = method.getReceiverType();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1749
        List<? extends AnnotationMirror> annotationMirrors1 = rcvrType.getAnnotationMirrors();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1750
        addAnnotationInfo(0, method, annotationMirrors1, false, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1751
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1752
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1753
    /**
47849
0e38db7cf1cc 8190820: Introduce a new Head builder class
jjg
parents: 47848
diff changeset
  1754
     * Adds the annotation types for the given element.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1755
     *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1756
     * @param element the package to write annotations for
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1757
     * @param htmltree the content tree to which the annotation types will be added
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1758
     */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1759
    public void addAnnotationInfo(Element element, Content htmltree) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1760
        addAnnotationInfo(element, element.getAnnotationMirrors(), htmltree);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1761
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1762
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1763
    /**
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1764
     * Add the annotatation types for the given element and parameter.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1765
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1766
     * @param indent the number of spaces to indent the parameters.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1767
     * @param element the element to write annotations for.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1768
     * @param param the parameter to write annotations for.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1769
     * @param tree the content tree to which the annotation types will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1770
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1771
    public boolean addAnnotationInfo(int indent, Element element, VariableElement param,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1772
            Content tree) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1773
        return addAnnotationInfo(indent, element, param.getAnnotationMirrors(), false, tree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1774
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1775
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1776
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1777
     * Adds the annotatation types for the given Element.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1778
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1779
     * @param element the element to write annotations for.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1780
     * @param descList a list of annotation mirrors.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1781
     * @param htmltree the documentation tree to which the annotation info will be
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1782
     *        added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1783
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1784
    private void addAnnotationInfo(Element element, List<? extends AnnotationMirror> descList,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1785
            Content htmltree) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1786
        addAnnotationInfo(0, element, descList, true, htmltree);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1787
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1788
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1789
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1790
     * Adds the annotation types for the given element.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1791
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1792
     * @param indent the number of extra spaces to indent the annotations.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1793
     * @param element the element to write annotations for.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1794
     * @param descList a list of annotation mirrors.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1795
     * @param htmltree the documentation tree to which the annotation info will be
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1796
     *        added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1797
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1798
    private boolean addAnnotationInfo(int indent, Element element,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1799
            List<? extends AnnotationMirror> descList, boolean lineBreak, Content htmltree) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1800
        List<Content> annotations = getAnnotations(indent, descList, lineBreak);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1801
        String sep = "";
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1802
        if (annotations.isEmpty()) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1803
            return false;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1804
        }
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1805
        for (Content annotation: annotations) {
16964
096de5815398 8005091: javadoc should be able to return the receiver type
bpatel
parents: 16319
diff changeset
  1806
            htmltree.addContent(sep);
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1807
            htmltree.addContent(annotation);
31943
72b69ab429c9 8062647: Wrong indentation of arguments of annotated methods
igerasim
parents: 31297
diff changeset
  1808
            if (!lineBreak) {
72b69ab429c9 8062647: Wrong indentation of arguments of annotated methods
igerasim
parents: 31297
diff changeset
  1809
                sep = " ";
72b69ab429c9 8062647: Wrong indentation of arguments of annotated methods
igerasim
parents: 31297
diff changeset
  1810
            }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1811
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1812
        return true;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1813
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1814
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
  1815
   /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1816
     * Return the string representations of the annotation types for
06bc494ca11e Initial load
duke
parents:
diff changeset
  1817
     * the given doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1818
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
  1819
     * @param indent the number of extra spaces to indent the annotations.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1820
     * @param descList a list of annotation mirrors.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1821
     * @param linkBreak if true, add new line between each member value.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1822
     * @return a list of strings representing the annotations being
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1823
     *         documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1824
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1825
    private List<Content> getAnnotations(int indent, List<? extends AnnotationMirror> descList, boolean linkBreak) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1826
        return getAnnotations(indent, descList, linkBreak, true);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1827
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1828
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1829
    private List<Content> getAnnotations(int indent, AnnotationMirror amirror, boolean linkBreak) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1830
        List<AnnotationMirror> descList = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1831
        descList.add(amirror);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1832
        return getAnnotations(indent, descList, linkBreak, true);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1833
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1834
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1835
    /**
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1836
     * Return the string representations of the annotation types for
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1837
     * the given doc.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1838
     *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1839
     * A {@code null} {@code elementType} indicates that all the
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1840
     * annotations should be returned without any filtering.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1841
     *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1842
     * @param indent the number of extra spaces to indent the annotations.
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1843
     * @param descList a list of annotation mirrors.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1844
     * @param linkBreak if true, add new line between each member value.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1845
     * @param isJava5DeclarationLocation
49879
601277b1d582 8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents: 49551
diff changeset
  1846
     * @return a list of strings representing the annotations being
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1847
     *         documented.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1848
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1849
    public List<Content> getAnnotations(int indent, List<? extends AnnotationMirror> descList,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1850
            boolean linkBreak, boolean isJava5DeclarationLocation) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22160
diff changeset
  1851
        List<Content> results = new ArrayList<>();
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1852
        ContentBuilder annotation;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1853
        for (AnnotationMirror aDesc : descList) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1854
            TypeElement annotationElement = (TypeElement)aDesc.getAnnotationType().asElement();
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1855
            // If an annotation is not documented, do not add it to the list. If
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1856
            // the annotation is of a repeatable type, and if it is not documented
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1857
            // and also if its container annotation is not documented, do not add it
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1858
            // to the list. If an annotation of a repeatable type is not documented
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1859
            // but its container is documented, it will be added to the list.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1860
            if (!utils.isDocumentedAnnotation(annotationElement) &&
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
  1861
                (!isAnnotationDocumented && !isContainerDocumented)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1862
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1863
            }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1864
            /* TODO: check logic here to correctly handle declaration
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1865
             * and type annotations.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1866
            if  (utils.isDeclarationAnnotation(annotationElement, isJava5DeclarationLocation)) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1867
                continue;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 15035
diff changeset
  1868
            }*/
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1869
            annotation = new ContentBuilder();
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1870
            isAnnotationDocumented = false;
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
  1871
            LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1872
                                                     LinkInfoImpl.Kind.ANNOTATION, annotationElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1873
            Map<? extends ExecutableElement, ? extends AnnotationValue> pairs = aDesc.getElementValues();
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1874
            // If the annotation is synthesized, do not print the container.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1875
            if (utils.configuration.workArounds.isSynthesized(aDesc)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1876
                for (ExecutableElement ee : pairs.keySet()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1877
                    AnnotationValue annotationValue = pairs.get(ee);
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22160
diff changeset
  1878
                    List<AnnotationValue> annotationTypeValues = new ArrayList<>();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1879
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1880
                    new SimpleAnnotationValueVisitor9<Void, List<AnnotationValue>>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1881
                        @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1882
                        public Void visitArray(List<? extends AnnotationValue> vals, List<AnnotationValue> p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1883
                            p.addAll(vals);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1884
                            return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1885
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1886
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1887
                        @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1888
                        protected Void defaultAction(Object o, List<AnnotationValue> p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1889
                            p.add(annotationValue);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1890
                            return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1891
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1892
                    }.visit(annotationValue, annotationTypeValues);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1893
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1894
                    String sep = "";
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1895
                    for (AnnotationValue av : annotationTypeValues) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1896
                        annotation.addContent(sep);
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1897
                        annotation.addContent(annotationValueToContent(av));
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1898
                        sep = " ";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1899
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1900
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1901
            } else if (isAnnotationArray(pairs)) {
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1902
                // If the container has 1 or more value defined and if the
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1903
                // repeatable type annotation is not documented, do not print
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1904
                // the container.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1905
                if (pairs.size() == 1 && isAnnotationDocumented) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22160
diff changeset
  1906
                    List<AnnotationValue> annotationTypeValues = new ArrayList<>();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1907
                    for (AnnotationValue a :  pairs.values()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1908
                        new SimpleAnnotationValueVisitor9<Void, List<AnnotationValue>>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1909
                            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1910
                            public Void visitArray(List<? extends AnnotationValue> vals, List<AnnotationValue> annotationTypeValues) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1911
                               for (AnnotationValue av : vals) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1912
                                   annotationTypeValues.add(av);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1913
                               }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1914
                               return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1915
                            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1916
                        }.visit(a, annotationTypeValues);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1917
                    }
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1918
                    String sep = "";
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1919
                    for (AnnotationValue av : annotationTypeValues) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1920
                        annotation.addContent(sep);
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1921
                        annotation.addContent(annotationValueToContent(av));
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1922
                        sep = " ";
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1923
                    }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1924
                }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1925
                // If the container has 1 or more value defined and if the
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1926
                // repeatable type annotation is not documented, print the container.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1927
                else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1928
                    addAnnotations(annotationElement, linkInfo, annotation, pairs,
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
  1929
                                   indent, false);
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1930
                }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1931
            }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1932
            else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1933
                addAnnotations(annotationElement, linkInfo, annotation, pairs,
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
  1934
                               indent, linkBreak);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1935
            }
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1936
            annotation.addContent(linkBreak ? DocletConstants.NL : "");
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1937
            results.add(annotation);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1938
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1939
        return results;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1940
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1941
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1942
    /**
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1943
     * Add annotation to the annotation string.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1944
     *
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1945
     * @param annotationDoc the annotation being documented
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1946
     * @param linkInfo the information about the link
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1947
     * @param annotation the annotation string to which the annotation will be added
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents: 47852
diff changeset
  1948
     * @param map annotation type element to annotation value pairs
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1949
     * @param indent the number of extra spaces to indent the annotations.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1950
     * @param linkBreak if true, add new line between each member value
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1951
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1952
    private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo,
48029
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents: 47852
diff changeset
  1953
                                ContentBuilder annotation,
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents: 47852
diff changeset
  1954
                                Map<? extends ExecutableElement, ? extends AnnotationValue> map,
e9dab2492924 8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents: 47852
diff changeset
  1955
                                int indent, boolean linkBreak) {
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1956
        linkInfo.label = new StringContent("@");
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1957
        linkInfo.label.addContent(annotationDoc.getSimpleName());
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1958
        annotation.addContent(getLink(linkInfo));
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1959
        if (!map.isEmpty()) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1960
            annotation.addContent("(");
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1961
            boolean isFirst = true;
36038
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1962
            Set<? extends ExecutableElement> keys = map.keySet();
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1963
            boolean multipleValues = keys.size() > 1;
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1964
            for (ExecutableElement element : keys) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1965
                if (isFirst) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1966
                    isFirst = false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1967
                } else {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1968
                    annotation.addContent(",");
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1969
                    if (linkBreak) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1970
                        annotation.addContent(DocletConstants.NL);
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  1971
                        int spaces = annotationDoc.getSimpleName().length() + 2;
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1972
                        for (int k = 0; k < (spaces + indent); k++) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1973
                            annotation.addContent(" ");
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1974
                        }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1975
                    }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1976
                }
36038
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1977
                String simpleName = element.getSimpleName().toString();
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1978
                if (multipleValues || !"value".equals(simpleName)) { // Omit "value=" where unnecessary
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1979
                    annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION,
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1980
                                                     element, simpleName, false));
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1981
                    annotation.addContent("=");
39c5445924b9 6469561: javadoc for annotation types should not display "public abstract" modifiers on methods
darcy
parents: 35426
diff changeset
  1982
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1983
                AnnotationValue annotationValue = map.get(element);
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22160
diff changeset
  1984
                List<AnnotationValue> annotationTypeValues = new ArrayList<>();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1985
                new SimpleAnnotationValueVisitor9<Void, AnnotationValue>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1986
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1987
                    public Void visitArray(List<? extends AnnotationValue> vals, AnnotationValue p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1988
                        annotationTypeValues.addAll(vals);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1989
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1990
                    }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  1991
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1992
                    protected Void defaultAction(Object o, AnnotationValue p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1993
                        annotationTypeValues.add(p);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1994
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1995
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  1996
                }.visit(annotationValue, annotationValue);
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  1997
                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "{");
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1998
                String sep = "";
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  1999
                for (AnnotationValue av : annotationTypeValues) {
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  2000
                    annotation.addContent(sep);
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  2001
                    annotation.addContent(annotationValueToContent(av));
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2002
                    sep = ",";
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2003
                }
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  2004
                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "}");
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2005
                isContainerDocumented = false;
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2006
            }
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  2007
            annotation.addContent(")");
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2008
        }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2009
    }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2010
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2011
    /**
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2012
     * Check if the annotation contains an array of annotation as a value. This
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2013
     * check is to verify if a repeatable type annotation is present or not.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2014
     *
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2015
     * @param pairs annotation type element and value pairs
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2016
     *
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2017
     * @return true if the annotation contains an array of annotation as a value.
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2018
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2019
    private boolean isAnnotationArray(Map<? extends ExecutableElement, ? extends AnnotationValue> pairs) {
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2020
        AnnotationValue annotationValue;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2021
        for (ExecutableElement ee : pairs.keySet()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2022
            annotationValue = pairs.get(ee);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2023
            boolean rvalue = new SimpleAnnotationValueVisitor9<Boolean, Void>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2024
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2025
                public Boolean visitArray(List<? extends AnnotationValue> vals, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2026
                    if (vals.size() > 1) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2027
                        if (vals.get(0) instanceof AnnotationMirror) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2028
                            isContainerDocumented = true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2029
                            return new SimpleAnnotationValueVisitor9<Boolean, Void>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2030
                                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2031
                                public Boolean visitAnnotation(AnnotationMirror a, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2032
                                    isContainerDocumented = true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2033
                                    Element asElement = a.getAnnotationType().asElement();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2034
                                    if (utils.isDocumentedAnnotation((TypeElement)asElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2035
                                        isAnnotationDocumented = true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2036
                                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2037
                                    return true;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2038
                                }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2039
                                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2040
                                protected Boolean defaultAction(Object o, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2041
                                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2042
                                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2043
                            }.visit(vals.get(0));
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2044
                        }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2045
                    }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2046
                    return false;
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2047
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2048
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2049
                @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2050
                protected Boolean defaultAction(Object o, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2051
                    return false;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2052
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2053
            }.visit(annotationValue);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2054
            if (rvalue) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2055
                return true;
15035
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2056
            }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2057
        }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2058
        return false;
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2059
    }
d03c311f44e6 8005092: javadoc should check for synthesized bit on an annotation
bpatel
parents: 14549
diff changeset
  2060
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
  2061
    private Content annotationValueToContent(AnnotationValue annotationValue) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2062
        return new SimpleAnnotationValueVisitor9<Content, Void>() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2063
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2064
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2065
            public Content visitType(TypeMirror t, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2066
                return new SimpleTypeVisitor9<Content, Void>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2067
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2068
                    public Content visitDeclared(DeclaredType t, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2069
                        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2070
                                LinkInfoImpl.Kind.ANNOTATION, t);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2071
                        String name = utils.isIncluded(t.asElement())
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2072
                                ? t.asElement().getSimpleName().toString()
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2073
                                : utils.getFullyQualifiedName(t.asElement());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2074
                        linkInfo.label = new StringContent(name + utils.getDimension(t) + ".class");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2075
                        return getLink(linkInfo);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2076
                    }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2077
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2078
                    protected Content defaultAction(TypeMirror e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2079
                        return new StringContent(t + utils.getDimension(t) + ".class");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2080
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2081
                }.visit(t);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2082
            }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2083
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2084
            public Content visitAnnotation(AnnotationMirror a, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2085
                List<Content> list = getAnnotations(0, a, false);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2086
                ContentBuilder buf = new ContentBuilder();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2087
                for (Content c : list) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2088
                    buf.addContent(c);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2089
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2090
                return buf;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2091
            }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2092
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2093
            public Content visitEnumConstant(VariableElement c, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2094
                return getDocLink(LinkInfoImpl.Kind.ANNOTATION,
36500
d31e4986dc8b 8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents: 36038
diff changeset
  2095
                        c, c.getSimpleName(), false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2096
            }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2097
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2098
            public Content visitArray(List<? extends AnnotationValue> vals, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2099
                ContentBuilder buf = new ContentBuilder();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2100
                String sep = "";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2101
                for (AnnotationValue av : vals) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2102
                    buf.addContent(sep);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2103
                    buf.addContent(visit(av));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2104
                    sep = " ";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2105
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2106
                return buf;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2107
            }
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40587
diff changeset
  2108
            @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2109
            protected Content defaultAction(Object o, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2110
                return new StringContent(annotationValue.toString());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2111
            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
  2112
        }.visit(annotationValue);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2113
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2114
47427
251676148c62 8189405: More cleanup in HtmlWriter
jjg
parents: 47395
diff changeset
  2115
    protected TableHeader getPackageTableHeader() {
251676148c62 8189405: More cleanup in HtmlWriter
jjg
parents: 47395
diff changeset
  2116
        return new TableHeader(contents.packageLabel, contents.descriptionLabel);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2117
    }
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47748
diff changeset
  2118
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2119
    /**
53863
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2120
     * Generates a string for use in a description meta element,
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2121
     * based on an element and its enclosing elements
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2122
     * @param prefix a prefix for the string
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2123
     * @param elem the element
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2124
     * @return the description
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2125
     */
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2126
    static String getDescription(String prefix, Element elem) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2127
        LinkedList<Element> chain = new LinkedList<>();
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2128
        for (Element e = elem; e != null; e = e.getEnclosingElement()) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2129
            // ignore unnamed enclosing elements
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2130
            if (e.getSimpleName().length() == 0 && e != elem) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2131
                break;
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2132
            }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2133
            chain.addFirst(e);
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2134
        }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2135
        StringBuilder sb = new StringBuilder();
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2136
        for (Element e: chain) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2137
            CharSequence name;
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2138
            switch (e.getKind()) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2139
                case MODULE:
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2140
                case PACKAGE:
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2141
                    name = ((QualifiedNameable) e).getQualifiedName();
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2142
                    if (name.length() == 0) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2143
                        name = "<unnamed>";
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2144
                    }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2145
                    break;
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2146
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2147
                default:
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2148
                    name = e.getSimpleName();
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2149
                    break;
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2150
            }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2151
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2152
            if (sb.length() == 0) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2153
                sb.append(prefix).append(": ");
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2154
            } else {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2155
                sb.append(", ");
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2156
            }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2157
            sb.append(e.getKind().toString().toLowerCase(Locale.US).replace("_", " "))
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2158
                    .append(": ")
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2159
                    .append(name);
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2160
        }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2161
        return sb.toString();
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2162
    }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2163
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2164
    static String getGenerator(Class<?> clazz) {
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2165
        return "javadoc/" + clazz.getSimpleName();
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2166
    }
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2167
d001808c57e8 8218998: Add metadata to generated API documentation files
jjg
parents: 53562
diff changeset
  2168
    /**
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2169
     * Returns an HtmlTree for the SCRIPT tag.
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2170
     *
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2171
     * @return an HtmlTree for the SCRIPT tag
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2172
     */
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2173
    protected Script getWinTitleScript() {
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2174
        Script script = new Script();
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2175
        if (winTitle != null && winTitle.length() > 0) {
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2176
            script.append("<!--\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2177
                    "    try {\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2178
                    "        if (location.href.indexOf('is-external=true') == -1) {\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2179
                    "            parent.document.title=")
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2180
                    .appendStringLiteral(winTitle)
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2181
                    .append(";\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2182
                    "        }\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2183
                    "    }\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2184
                    "    catch(err) {\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2185
                    "    }\n" +
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2186
                    "//-->\n");
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2187
        }
47846
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47748
diff changeset
  2188
        return script;
4e78aba768f0 8190295: Introduce a new Table builder class
jjg
parents: 47748
diff changeset
  2189
    }
47847
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2190
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2191
    /**
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2192
     * Returns an HtmlTree for the BODY tag.
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2193
     *
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2194
     * @param includeScript  set true if printing windowtitle script
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2195
     * @param title title for the window
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2196
     * @return an HtmlTree for the BODY tag
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2197
     */
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2198
    public HtmlTree getBody(boolean includeScript, String title) {
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2199
        HtmlTree body = new HtmlTree(HtmlTag.BODY);
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2200
        // Set window title string which is later printed
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2201
        this.winTitle = title;
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2202
        // Don't print windowtitle script for overview-frame, allclasses-frame
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2203
        // and package-frame
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2204
        if (includeScript) {
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2205
            this.mainBodyScript = getWinTitleScript();
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2206
            body.addContent(mainBodyScript.asContent());
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2207
            Content noScript = HtmlTree.NOSCRIPT(HtmlTree.DIV(contents.noScriptMessage));
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2208
            body.addContent(noScript);
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2209
        }
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2210
        return body;
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2211
    }
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2212
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2213
    Script getMainBodyScript() {
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2214
        return mainBodyScript;
7640bc1eb94f 8190818: Introduce a new Script builder class
jjg
parents: 47846
diff changeset
  2215
    }
53866
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2216
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2217
    Content getLocalStylesheetContent(Element element) throws DocFileIOException {
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2218
        Content stylesheetContent = new ContentBuilder();
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2219
        List<DocPath> localStylesheets = configuration.localStylesheetMap.get(element);
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2220
        if (localStylesheets == null) {
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2221
            DocFilesHandlerImpl docFilesHandler = (DocFilesHandlerImpl)configuration
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2222
                    .getWriterFactory().getDocFilesHandler(element);
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2223
            localStylesheets = docFilesHandler.getStylesheets();
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2224
            configuration.localStylesheetMap.put(element, localStylesheets);
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2225
        }
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2226
        for (DocPath stylesheet : localStylesheets) {
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2227
            stylesheetContent.addContent(HtmlTree.LINK("stylesheet",
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2228
                    "text/css", stylesheet.getPath(), "Style"));
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2229
        }
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2230
        return stylesheetContent;
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2231
    }
880baf6db17b 8213354: Support package-specific stylesheets
pmuthuswamy
parents: 53863
diff changeset
  2232
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2233
}