langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java
author ksrini
Tue, 15 Aug 2017 13:16:32 -0700
changeset 46184 f1325703ea85
parent 45417 f7479ee8de69
permissions -rw-r--r--
8173425: Javadoc needs a new tag to specify the summary. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
     2
 * Copyright (c) 2001, 2017, 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: 1789
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: 1789
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: 1789
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
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.toolkit.taglets;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.*;
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    29
import java.lang.reflect.InvocationTargetException;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    32
import javax.lang.model.element.Element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    33
import javax.lang.model.element.ExecutableElement;
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
    34
import javax.lang.model.element.ModuleElement;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    35
import javax.lang.model.element.PackageElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    36
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    37
import javax.lang.model.element.VariableElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    38
import javax.lang.model.util.SimpleElementVisitor9;
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    39
import javax.tools.JavaFileManager;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    40
import javax.tools.StandardJavaFileManager;
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    41
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    42
import com.sun.source.doctree.DocTree;
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    43
import jdk.javadoc.doclet.Doclet;
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
    44
import jdk.javadoc.doclet.DocletEnvironment;
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44388
diff changeset
    45
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
    46
import jdk.javadoc.internal.doclets.toolkit.Messages;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
    47
import jdk.javadoc.internal.doclets.toolkit.Resources;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    48
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    49
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    50
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    51
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    52
import static javax.tools.DocumentationTool.Location.*;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    53
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    54
import static com.sun.source.doctree.DocTree.Kind.*;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14049
diff changeset
    55
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
/**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    57
 * Manages the {@code Taglet}s used by doclets.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    59
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    60
 *  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: 14258
diff changeset
    61
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    62
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
public class TagletManager {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    70
     * The default separator for the simple tag option.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    72
    public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':';
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    75
     * The alternate separator for simple tag options.  Use this
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    76
     * when you want the default separator to be in the name of the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    79
    public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * The map of custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    84
    private final LinkedHashMap<String,Taglet> customTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /**
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
    87
     * The array of custom tags that can appear in modules.
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
    88
     */
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
    89
    private List<Taglet> moduleTags;
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
    90
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
    91
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * The array of custom tags that can appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    94
    private List<Taglet> packageTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * The array of custom tags that can appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    99
    private List<Taglet> typeTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * The array of custom tags that can appear in fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   104
    private List<Taglet> fieldTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * The array of custom tags that can appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   109
    private List<Taglet> constructorTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * The array of custom tags that can appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   114
    private List<Taglet> methodTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * The array of custom tags that can appear in the overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   119
    private List<Taglet> overviewTags;
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
     * The array of custom tags that can appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   124
    private List<Taglet> inlineTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * The array of custom tags that can appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   129
    private List<Taglet> serializedFormTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   131
    private final DocletEnvironment docEnv;
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   132
    private final Doclet doclet;
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   133
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   134
    private final Messages messages;
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   135
    private final Resources resources;
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
     * Keep track of standard tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   140
    private final Set<String> standardTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * Keep track of standard tags in lowercase to compare for better
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * error messages when a tag like @docRoot is mistakenly spelled
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * lowercase @docroot.
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   147
    private final Set<String> standardTagsLowercase;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * Keep track of overriden standard tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   152
    private final Set<String> overridenStandardTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * Keep track of the tags that may conflict
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * with standard tags in the future (any custom tag without
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * a period in its name).
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   159
    private final Set<String> potentiallyConflictingTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * The set of unseen custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   164
    private final Set<String> unseenCustomTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * True if we do not want to use @since tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   169
    private final boolean nosince;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * True if we want to use @version tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   174
    private final boolean showversion;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     * True if we want to use @author tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   179
    private final boolean showauthor;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    /**
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   182
     * True if we want to use JavaFX-related tags (@propertyGetter,
17572
1081a023532f 8012295: Cleanup JavaFX features in standard doclet
jjg
parents: 17565
diff changeset
   183
     * @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate).
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   184
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   185
    private final boolean javafx;
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   186
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   187
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * Construct a new <code>TagletManager</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * @param nosince true if we do not want to use @since tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * @param showversion true if we want to use @version tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * @param showauthor true if we want to use @author tags.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   192
     * @param javafx indicates whether javafx is active.
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   193
     * @param configuration the configuration for this taglet manager
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    public TagletManager(boolean nosince, boolean showversion,
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   196
                         boolean showauthor, boolean javafx,
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 44388
diff changeset
   197
                         BaseConfiguration configuration) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   198
        overridenStandardTags = new HashSet<>();
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   199
        potentiallyConflictingTags = new HashSet<>();
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   200
        standardTags = new HashSet<>();
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   201
        standardTagsLowercase = new HashSet<>();
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   202
        unseenCustomTags = new HashSet<>();
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   203
        customTags = new LinkedHashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        this.nosince = nosince;
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        this.showversion = showversion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        this.showauthor = showauthor;
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   207
        this.javafx = javafx;
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   208
        this.docEnv = configuration.docEnv;
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   209
        this.doclet = configuration.doclet;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   210
        this.messages = configuration.getMessages();
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   211
        this.resources = configuration.getResources();
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   212
        initStandardTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        initStandardTagsLowercase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * Add a new <code>CustomTag</code>.  This is used to add a Taglet from within
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * a Doclet.  No message is printed to indicate that the Taglet is properly
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * registered because these Taglets are typically added for every execution of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * Doclet.  We don't want to see this type of error message every time.
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * @param customTag the new <code>CustomTag</code> to add.
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    public void addCustomTag(Taglet customTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        if (customTag != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            String name = customTag.getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            if (customTags.containsKey(name)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                customTags.remove(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
            customTags.put(name, customTag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
            checkTagName(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
21500
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 18659
diff changeset
   234
    public Set<String> getCustomTagNames() {
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 18659
diff changeset
   235
        return customTags.keySet();
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 18659
diff changeset
   236
    }
475e59d3b40c 8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents: 18659
diff changeset
   237
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * Add a new <code>Taglet</code>.  Print a message to indicate whether or not
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * the Taglet was registered properly.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * @param classname  the name of the class representing the custom tag.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   242
     * @param fileManager the filemanager to load classes and resources.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * @param tagletPath  the path to the class representing the custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     */
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   245
    public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        try {
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   247
            ClassLoader tagClassLoader;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   248
            if (!fileManager.hasLocation(TAGLET_PATH)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   249
                List<File> paths = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   250
                if (tagletPath != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   251
                    for (String pathname : tagletPath.split(File.pathSeparator)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   252
                        paths.add(new File(pathname));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   253
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   254
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   255
                if (fileManager instanceof StandardJavaFileManager) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   256
                    ((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, paths);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   259
            tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
44388
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   260
            Class<? extends jdk.javadoc.doclet.Taglet> customTagClass =
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   261
                    tagClassLoader.loadClass(classname).asSubclass(jdk.javadoc.doclet.Taglet.class);
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   262
            jdk.javadoc.doclet.Taglet instance = customTagClass.getConstructor().newInstance();
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   263
            instance.init(docEnv, doclet);
4d0903f1f311 8176836: Provide Taglet with context
jjg
parents: 44189
diff changeset
   264
            Taglet newLegacy = new UserTaglet(instance);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   265
            String tname = newLegacy.getName();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   266
            Taglet t = customTags.get(tname);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   267
            if (t != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   268
                customTags.remove(tname);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   269
            }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   270
            customTags.put(tname, newLegacy);
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   271
            messages.notice("doclet.Notice_taglet_registered", classname);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        } catch (Exception exc) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   273
            messages.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * Add a new <code>SimpleTaglet</code>.  If this tag already exists
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * and the header passed as an argument is null, move tag to the back of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * list. If this tag already exists and the header passed as an argument is
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * not null, overwrite previous tag with new one.  Otherwise, add new
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * SimpleTaglet to list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * @param tagName the name of this tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     * @param header the header to output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     * @param locations the possible locations that this tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * can appear in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    public void addNewSimpleCustomTag(String tagName, String header, String locations) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
        if (tagName == null || locations == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   292
        Taglet tag = customTags.get(tagName);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   293
        locations = Utils.toLowerCase(locations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        if (tag == null || header != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            customTags.remove(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
            customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            if (locations != null && locations.indexOf('x') == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
                checkTagName(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
            //Move to back
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
            customTags.remove(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            customTags.put(tagName, tag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
     * Given a tag name, add it to the set of tags it belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
    private void checkTagName(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        if (standardTags.contains(name)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
            overridenStandardTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
            if (name.indexOf('.') == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                potentiallyConflictingTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
            unseenCustomTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
     * Check the taglet to see if it is a legacy taglet.  Also
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
     * check its name for errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
    private void checkTaglet(Object taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        if (taglet instanceof Taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
            checkTagName(((Taglet) taglet).getName());
44189
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 40606
diff changeset
   328
        } else if (taglet instanceof jdk.javadoc.doclet.Taglet) {
dd311cfb920b 8176331: Simplify new doclet packages
jjg
parents: 40606
diff changeset
   329
            jdk.javadoc.doclet.Taglet legacyTaglet = (jdk.javadoc.doclet.Taglet) taglet;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            customTags.remove(legacyTaglet.getName());
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   331
            customTags.put(legacyTaglet.getName(), new UserTaglet(legacyTaglet));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
            checkTagName(legacyTaglet.getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
            throw new IllegalArgumentException("Given object is not a taglet.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
     * Given a name of a seen custom tag, remove it from the set of unseen
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
     * custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
     * @param name the name of the seen custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
    public void seenCustomTag(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        unseenCustomTags.remove(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
     * Given an array of <code>Tag</code>s, check for spelling mistakes.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   349
     * @param utils the utility class to use
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   350
     * @param element the tags holder
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   351
     * @param trees the trees containing the comments
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
     * @param areInlineTags true if the array of tags are inline and false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   354
    public void checkTags(final Utils utils, Element element,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   355
                          Iterable<? extends DocTree> trees, boolean areInlineTags) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   356
        if (trees == null) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   359
        CommentHelper ch = utils.getCommentHelper(element);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   360
        for (DocTree tag : trees) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   361
            String name = tag.getKind().tagName;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   362
            if (name == null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   363
                continue;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   364
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
            if (name.length() > 0 && name.charAt(0) == '@') {
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
                name = name.substring(1, name.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
            if (! (standardTags.contains(name) || customTags.containsKey(name))) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   369
                if (standardTagsLowercase.contains(Utils.toLowerCase(name))) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   370
                    messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
                } else {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   373
                    messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   377
            final Taglet taglet = customTags.get(name);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   378
            // Check and verify tag usage
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   379
            if (taglet != null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   380
                if (areInlineTags && !taglet.isInlineTag()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   381
                    printTagMisuseWarn(ch, taglet, tag, "inline");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   382
                }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   383
                // nothing more to do
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   384
                if (element == null) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   385
                    return;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   387
                new SimpleElementVisitor9<Void, Void>() {
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   388
                    @Override
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   389
                    public Void visitModule(ModuleElement e, Void p) {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   390
                        if (!taglet.inModule()) {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   391
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "module");
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   392
                        }
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   393
                        return null;
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   394
                    }
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   395
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   396
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   397
                    public Void visitPackage(PackageElement e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   398
                        if (!taglet.inPackage()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   399
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "package");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   400
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   401
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   402
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   403
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   404
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   405
                    public Void visitType(TypeElement e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   406
                        if (!taglet.inType()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   407
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "class");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   408
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   409
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   410
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   411
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   412
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   413
                    public Void visitExecutable(ExecutableElement e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   414
                        if (utils.isConstructor(e) && !taglet.inConstructor()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   415
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "constructor");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   416
                        } else if (!taglet.inMethod()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   417
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "method");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   418
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   419
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   420
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   421
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   422
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   423
                    public Void visitVariable(VariableElement e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   424
                        if (utils.isField(e) && !taglet.inField()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   425
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "field");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   426
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   427
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   428
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   429
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   430
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   431
                    public Void visitUnknown(Element e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   432
                        if (utils.isOverviewElement(e) && !taglet.inOverview()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   433
                            printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "overview");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   434
                        }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   435
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   436
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   437
40606
eb2c81860c86 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents: 40303
diff changeset
   438
                    @Override
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   439
                    protected Void defaultAction(Element e, Void p) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   440
                        return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   441
                    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   442
                }.visit(element);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
     * Given the taglet, the tag and the type of documentation that the tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
     * was found in, print a tag misuse warning.
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
     * @param taglet the taglet representing the misused tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
     * @param tag the misused tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
     * @param holderType the type of documentation that the misused tag was found in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   454
    private void printTagMisuseWarn(CommentHelper ch, Taglet taglet, DocTree tag, String holderType) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   455
        Set<String> locationsSet = new LinkedHashSet<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        if (taglet.inOverview()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
            locationsSet.add("overview");
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
        }
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   459
        if (taglet.inModule()) {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   460
            locationsSet.add("module");
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   461
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
        if (taglet.inPackage()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
            locationsSet.add("package");
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
        if (taglet.inType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
            locationsSet.add("class/interface");
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
        if (taglet.inConstructor())  {
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
            locationsSet.add("constructor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
        if (taglet.inField()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
            locationsSet.add("field");
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
        if (taglet.inMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
            locationsSet.add("method");
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
        if (taglet.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
            locationsSet.add("inline text");
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   480
        String[] locations = locationsSet.toArray(new String[]{});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
        if (locations == null || locations.length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
            //This known tag is excluded.
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
        }
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14260
diff changeset
   485
        StringBuilder combined_locations = new StringBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
        for (int i = 0; i < locations.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
            if (i > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
                combined_locations.append(", ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
            combined_locations.append(locations[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
        }
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   492
        messages.warning(ch.getDocTreePath(tag), "doclet.tag_misuse",
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
            "@" + taglet.getName(), holderType, combined_locations.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
     * Return the array of <code>Taglet</code>s that can
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   498
     * appear in modules.
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   499
     * @return the array of <code>Taglet</code>s that can
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   500
     * appear in modules.
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   501
     */
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   502
    public List<Taglet> getModuleCustomTaglets() {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   503
        if (moduleTags == null) {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   504
            initCustomTaglets();
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   505
        }
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   506
        return moduleTags;
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   507
    }
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   508
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   509
    /**
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   510
     * Return the array of <code>Taglet</code>s that can
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
     * appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
     * appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   515
    public List<Taglet> getPackageCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
        if (packageTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   517
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
        return packageTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
     * appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
     * appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   528
    public List<Taglet> getTypeCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
        if (typeTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   530
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
        return typeTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
     * Return the array of inline <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
     * appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
     * appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   541
    public List<Taglet> getInlineCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
        if (inlineTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   543
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
        return inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
     * appear in fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
     * appear in field.
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   554
    public List<Taglet> getFieldCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
        if (fieldTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   556
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
        return fieldTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
     * appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
     * appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   567
    public List<Taglet> getSerializedFormTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
        if (serializedFormTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   569
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
        return serializedFormTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   575
     * Returns the custom tags for a given element.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   576
     *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   577
     * @param e the element to get custom tags for
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
     * @return the array of <code>Taglet</code>s that can
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   579
     * appear in the given element.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   581
    public List<Taglet> getCustomTaglets(Element e) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   582
        switch (e.getKind()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   583
            case CONSTRUCTOR:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   584
                return getConstructorCustomTaglets();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   585
            case METHOD:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   586
                return getMethodCustomTaglets();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   587
            case ENUM_CONSTANT:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   588
            case FIELD:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   589
                return getFieldCustomTaglets();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   590
            case ANNOTATION_TYPE:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   591
            case INTERFACE:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   592
            case CLASS:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   593
            case ENUM:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   594
                return getTypeCustomTaglets();
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   595
            case MODULE:
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   596
                return getModuleCustomTaglets();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   597
            case PACKAGE:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   598
                return getPackageCustomTaglets();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   599
            case OTHER:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   600
                return getOverviewCustomTaglets();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   601
            default:
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   602
                throw new AssertionError("unknown element: " + e + " ,kind: " + e.getKind());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   605
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   607
     * Return a List of <code>Taglet</code>s that can
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
     * appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
     * appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   612
    public List<Taglet> getConstructorCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
        if (constructorTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   614
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
        return constructorTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   620
     * Return a List of <code>Taglet</code>s that can
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
     * appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
     * appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   625
    public List<Taglet> getMethodCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
        if (methodTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   627
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   629
        return methodTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   630
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   631
06bc494ca11e Initial load
duke
parents:
diff changeset
   632
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   633
     * Return a List of <code>Taglet</code>s that can
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   634
     * appear in an overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   635
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
     * appear in overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   638
    public List<Taglet> getOverviewCustomTaglets() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   639
        if (overviewTags == null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   640
            initCustomTaglets();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   641
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
        return overviewTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
06bc494ca11e Initial load
duke
parents:
diff changeset
   645
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   646
     * Initialize the custom tag Lists.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   647
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   648
    private void initCustomTaglets() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   649
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   650
        moduleTags = new ArrayList<>();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   651
        packageTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   652
        typeTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   653
        fieldTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   654
        constructorTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   655
        methodTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   656
        inlineTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   657
        overviewTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   658
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   659
        for (Taglet current : customTags.values()) {
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   660
            if (current.inModule() && !current.isInlineTag()) {
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   661
                moduleTags.add(current);
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   662
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
            if (current.inPackage() && !current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   664
                packageTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   665
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   666
            if (current.inType() && !current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   667
                typeTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   668
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   669
            if (current.inField() && !current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   670
                fieldTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   671
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
            if (current.inConstructor() && !current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   673
                constructorTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
            if (current.inMethod() && !current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   676
                methodTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
            if (current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   679
                inlineTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   680
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
            if (current.inOverview() && !current.isInlineTag()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   682
                overviewTags.add(current);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
        //Init the serialized form tags
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   687
        serializedFormTags = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   688
        serializedFormTags.add(customTags.get(SERIAL_DATA.tagName));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   689
        serializedFormTags.add(customTags.get(THROWS.tagName));
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   690
        if (!nosince)
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   691
            serializedFormTags.add(customTags.get(SINCE.tagName));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   692
        serializedFormTags.add(customTags.get(SEE.tagName));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
     * Initialize standard Javadoc tags for ordering purposes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
     */
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   698
    private void initStandardTaglets() {
18659
5fe5650da7f9 8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents: 17573
diff changeset
   699
        if (javafx) {
5fe5650da7f9 8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents: 17573
diff changeset
   700
            initJavaFXTaglets();
5fe5650da7f9 8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents: 17573
diff changeset
   701
        }
5fe5650da7f9 8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents: 17573
diff changeset
   702
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
        Taglet temp;
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   704
        addStandardTaglet(new ParamTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   705
        addStandardTaglet(new ReturnTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   706
        addStandardTaglet(new ThrowsTaglet());
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   707
        addStandardTaglet(new SimpleTaglet(EXCEPTION.tagName, null,
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   708
                SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   709
        addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, resources.getText("doclet.Since"),
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36526
diff changeset
   710
                SimpleTaglet.ALL));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   711
        addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, resources.getText("doclet.Version"),
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   712
                SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   713
        addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, resources.getText("doclet.Author"),
38911
48a00b5ee366 8156077: Support javadoc tags in module documentation
bpatel
parents: 37759
diff changeset
   714
                SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   715
        addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, resources.getText("doclet.SerialData"),
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36526
diff changeset
   716
                SimpleTaglet.EXCLUDED));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   717
        addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, resources.getText("doclet.Hidden"),
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36526
diff changeset
   718
                SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   719
        customTags.put((temp = new SimpleTaglet("factory", resources.getText("doclet.Factory"),
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 36526
diff changeset
   720
                SimpleTaglet.METHOD)).getName(), temp);
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   721
        addStandardTaglet(new SeeTaglet());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
        //Standard inline tags
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   723
        addStandardTaglet(new DocRootTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   724
        addStandardTaglet(new InheritDocTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   725
        addStandardTaglet(new ValueTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   726
        addStandardTaglet(new LiteralTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   727
        addStandardTaglet(new CodeTaglet());
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 25874
diff changeset
   728
        addStandardTaglet(new IndexTaglet());
46184
f1325703ea85 8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents: 45417
diff changeset
   729
        addStandardTaglet(new SummaryTaglet());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   731
        // Keep track of the names of standard tags for error
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   732
        // checking purposes. The following are not handled above.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   733
        standardTags.add(DEPRECATED.tagName);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   734
        standardTags.add(LINK.tagName);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   735
        standardTags.add(LINK_PLAIN.tagName);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   736
        standardTags.add(SERIAL.tagName);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   737
        standardTags.add(SERIAL_FIELD.tagName);
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   738
    }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   739
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   740
    /**
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   741
     * Initialize JavaFX-related tags.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   742
     */
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   743
    private void initJavaFXTaglets() {
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   744
        addStandardTaglet(new PropertyGetterTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   745
        addStandardTaglet(new PropertySetterTaglet());
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   746
        addStandardTaglet(new SimpleTaglet("propertyDescription",
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   747
                resources.getText("doclet.PropertyDescription"),
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   748
                SimpleTaglet.FIELD + SimpleTaglet.METHOD));
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   749
        addStandardTaglet(new SimpleTaglet("defaultValue", resources.getText("doclet.DefaultValue"),
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   750
            SimpleTaglet.FIELD + SimpleTaglet.METHOD));
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   751
        addStandardTaglet(new SimpleTaglet("treatAsPrivate", null,
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   752
                SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE));
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   753
    }
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14545
diff changeset
   754
17573
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   755
    void addStandardTaglet(Taglet taglet) {
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   756
        String name = taglet.getName();
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   757
        customTags.put(name, taglet);
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   758
        standardTags.add(name);
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   759
    }
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   760
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   761
    void addStandardTaglet(boolean enable, Taglet taglet) {
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   762
        String name = taglet.getName();
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   763
        if (enable)
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   764
            customTags.put(name, taglet);
0e20dec17c87 8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents: 17572
diff changeset
   765
        standardTags.add(name);
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   769
     * Initialize lowercase version of standard Javadoc tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   770
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   771
    private void initStandardTagsLowercase() {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 22153
diff changeset
   772
        for (String standardTag : standardTags) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   773
            standardTagsLowercase.add(Utils.toLowerCase(standardTag));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   774
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   775
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   776
06bc494ca11e Initial load
duke
parents:
diff changeset
   777
    public boolean isKnownCustomTag(String tagName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   778
        return customTags.containsKey(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   779
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   780
06bc494ca11e Initial load
duke
parents:
diff changeset
   781
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   782
     * Print a list of {@link Taglet}s that might conflict with
06bc494ca11e Initial load
duke
parents:
diff changeset
   783
     * standard tags in the future and a list of standard tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   784
     * that have been overriden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   785
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   786
    public void printReport() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   787
        printReportHelper("doclet.Notice_taglet_conflict_warn", potentiallyConflictingTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   788
        printReportHelper("doclet.Notice_taglet_overriden", overridenStandardTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   789
        printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   790
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   791
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   792
    private void printReportHelper(String noticeKey, Set<String> names) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   793
        if (names.size() > 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   794
            String[] namesArray = names.toArray(new String[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   795
            String result = " ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   796
            for (int i = 0; i < namesArray.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   797
                result += "@" + namesArray[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   798
                if (i + 1 < namesArray.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   799
                    result += ", ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   800
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   801
            }
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 38918
diff changeset
   802
            messages.notice(noticeKey, result);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   803
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   804
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   805
06bc494ca11e Initial load
duke
parents:
diff changeset
   806
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   807
     * Given the name of a tag, return the corresponding taglet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   808
     * Return null if the tag is unknown.
06bc494ca11e Initial load
duke
parents:
diff changeset
   809
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   810
     * @param name the name of the taglet to retrieve.
06bc494ca11e Initial load
duke
parents:
diff changeset
   811
     * @return return the corresponding taglet. Return null if the tag is
06bc494ca11e Initial load
duke
parents:
diff changeset
   812
     *         unknown.
06bc494ca11e Initial load
duke
parents:
diff changeset
   813
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   814
    public Taglet getTaglet(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   815
        if (name.indexOf("@") == 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   816
            return customTags.get(name.substring(1));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   817
        } else {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   818
            return customTags.get(name);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   819
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   820
06bc494ca11e Initial load
duke
parents:
diff changeset
   821
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   822
}