langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
author jjg
Thu, 15 Nov 2012 23:07:24 -0800
changeset 14545 2e7bab0639b8
parent 14368 6f4c62de6985
child 16319 e586bfeb39c5
permissions -rw-r--r--
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
     2
 * Copyright (c) 2001, 2012, 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
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.internal.toolkit.taglets;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.lang.reflect.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.net.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    33
import javax.tools.DocumentationTool;
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    34
import javax.tools.JavaFileManager;
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    35
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14049
diff changeset
    36
import com.sun.javadoc.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14049
diff changeset
    37
import com.sun.tools.doclets.internal.toolkit.util.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 14049
diff changeset
    38
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * Manages the<code>Taglet</code>s used by doclets.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    42
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    43
 *  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
    44
 *  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
    45
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
public class TagletManager {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    54
     * The default separator for the simple tag option.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    56
    public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':';
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    59
     * 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
    60
     * when you want the default separator to be in the name of the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
    63
    public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * The map of custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    68
    private LinkedHashMap<String,Taglet> customTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * The array of custom tags that can appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    private Taglet[] packageTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * The array of custom tags that can appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    private Taglet[] typeTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * The array of custom tags that can appear in fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    private Taglet[] fieldTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * The array of custom tags that can appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    private Taglet[] constructorTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * The array of custom tags that can appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    private Taglet[] methodTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * The array of custom tags that can appear in the overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    private Taglet[] overviewTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * The array of custom tags that can appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    private Taglet[] inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * The array of custom tags that can appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    private Taglet[] serializedFormTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * The message retriever that will be used to print error messages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    private MessageRetriever message;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * Keep track of standard tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   118
    private Set<String> standardTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * Keep track of standard tags in lowercase to compare for better
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * error messages when a tag like @docRoot is mistakenly spelled
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * lowercase @docroot.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   125
    private Set<String> standardTagsLowercase;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * Keep track of overriden standard tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   130
    private Set<String> overridenStandardTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * Keep track of the tags that may conflict
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * with standard tags in the future (any custom tag without
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * a period in its name).
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   137
    private Set<String> potentiallyConflictingTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * The set of unseen custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   142
    private Set<String> unseenCustomTags;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     * True if we do not want to use @since tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    private boolean nosince;
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * True if we want to use @version tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    private boolean showversion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * True if we want to use @author tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    private boolean showauthor;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * Construct a new <code>TagletManager</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * @param nosince true if we do not want to use @since tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * @param showversion true if we want to use @version tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     * @param showauthor true if we want to use @author tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * @param message the message retriever to print warnings.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    public TagletManager(boolean nosince, boolean showversion,
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   167
                         boolean showauthor, MessageRetriever message) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   168
        overridenStandardTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   169
        potentiallyConflictingTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   170
        standardTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   171
        standardTagsLowercase = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   172
        unseenCustomTags = new HashSet<String>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   173
        customTags = new LinkedHashMap<String,Taglet>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        this.nosince = nosince;
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        this.showversion = showversion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        this.showauthor = showauthor;
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        this.message = message;
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        initStandardTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        initStandardTagsLowercase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * Add a new <code>CustomTag</code>.  This is used to add a Taglet from within
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     * a Doclet.  No message is printed to indicate that the Taglet is properly
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     * registered because these Taglets are typically added for every execution of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * Doclet.  We don't want to see this type of error message every time.
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * @param customTag the new <code>CustomTag</code> to add.
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    public void addCustomTag(Taglet customTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        if (customTag != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            String name = customTag.getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
            if (customTags.containsKey(name)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
                customTags.remove(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
            customTags.put(name, customTag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
            checkTagName(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * Add a new <code>Taglet</code>.  Print a message to indicate whether or not
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     * the Taglet was registered properly.
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     * @param classname  the name of the class representing the custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * @param tagletPath  the path to the class representing the custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     */
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   206
    public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        try {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   208
            Class<?> customTagClass = null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
            // construct class loader
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
            String cpString = null;   // make sure env.class.path defaults to dot
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
14545
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   212
            ClassLoader tagClassLoader;
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   213
            if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.TAGLET_PATH)) {
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   214
                tagClassLoader = fileManager.getClassLoader(DocumentationTool.Location.TAGLET_PATH);
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   215
            } else {
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   216
                // do prepends to get correct ordering
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   217
                cpString = appendPath(System.getProperty("env.class.path"), cpString);
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   218
                cpString = appendPath(System.getProperty("java.class.path"), cpString);
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   219
                cpString = appendPath(tagletPath, cpString);
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   220
                tagClassLoader = new URLClassLoader(pathToURLs(cpString));
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   221
            }
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   222
2e7bab0639b8 6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents: 14368
diff changeset
   223
            customTagClass = tagClassLoader.loadClass(classname);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
            Method meth = customTagClass.getMethod("register",
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   225
                                                   new Class<?>[] {java.util.Map.class});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            Object[] list = customTags.values().toArray();
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
            Taglet lastTag = (list != null && list.length > 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                ? (Taglet) list[list.length-1] : null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
            meth.invoke(null, new Object[] {customTags});
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
            list = customTags.values().toArray();
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
            Object newLastTag = (list != null&& list.length > 0)
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   232
                ? list[list.length-1] : null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            if (lastTag != newLastTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
                //New taglets must always be added to the end of the LinkedHashMap.
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
                //If the current and previous last taglet are not equal, that
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
                //means a new Taglet has been added.
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
                message.notice("doclet.Notice_taglet_registered", classname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
                if (newLastTag != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
                    checkTaglet(newLastTag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        } catch (Exception exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
            message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    private String appendPath(String path1, String path2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        if (path1 == null || path1.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
            return path2 == null ? "." : path2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
        } else if (path2 == null || path2.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
            return path1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
            return path1  + File.pathSeparator + path2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     * Utility method for converting a search path string to an array
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * of directory and JAR file URLs.
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * @param path the search path string
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * @return the resulting array of directory and JAR file URLs
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     */
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   265
    private URL[] pathToURLs(String path) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   266
        Set<URL> urls = new LinkedHashSet<URL>();
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   267
        for (String s: path.split(File.pathSeparator)) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   268
            if (s.isEmpty()) continue;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   269
            try {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   270
                urls.add(new File(s).getAbsoluteFile().toURI().toURL());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   271
            } catch (MalformedURLException e) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   272
                message.error("doclet.MalformedURL", s);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        }
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14263
diff changeset
   275
        return urls.toArray(new URL[urls.size()]);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * Add a new <code>SimpleTaglet</code>.  If this tag already exists
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * and the header passed as an argument is null, move tag to the back of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     * list. If this tag already exists and the header passed as an argument is
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * not null, overwrite previous tag with new one.  Otherwise, add new
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     * SimpleTaglet to list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     * @param tagName the name of this tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     * @param header the header to output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     * @param locations the possible locations that this tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     * can appear in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
    public void addNewSimpleCustomTag(String tagName, String header, String locations) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        if (tagName == null || locations == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   294
        Taglet tag = customTags.get(tagName);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        locations = locations.toLowerCase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        if (tag == null || header != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            customTags.remove(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
            customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
            if (locations != null && locations.indexOf('x') == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
                checkTagName(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            //Move to back
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            customTags.remove(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            customTags.put(tagName, tag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     * Given a tag name, add it to the set of tags it belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    private void checkTagName(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
        if (standardTags.contains(name)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
            overridenStandardTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            if (name.indexOf('.') == -1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
                potentiallyConflictingTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
            unseenCustomTags.add(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     * Check the taglet to see if it is a legacy taglet.  Also
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
     * check its name for errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
    private void checkTaglet(Object taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        if (taglet instanceof Taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
            checkTagName(((Taglet) taglet).getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
        } else if (taglet instanceof com.sun.tools.doclets.Taglet) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
            com.sun.tools.doclets.Taglet legacyTaglet = (com.sun.tools.doclets.Taglet) taglet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
            customTags.remove(legacyTaglet.getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
            customTags.put(legacyTaglet.getName(), new LegacyTaglet(legacyTaglet));
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
            checkTagName(legacyTaglet.getName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
            throw new IllegalArgumentException("Given object is not a taglet.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
     * Given a name of a seen custom tag, remove it from the set of unseen
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
     * custom tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
     * @param name the name of the seen custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    public void seenCustomTag(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
        unseenCustomTags.remove(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
     * Given an array of <code>Tag</code>s, check for spelling mistakes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
     * @param doc the Doc object that holds the tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
     * @param tags the list of <code>Tag</code>s to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
     * @param areInlineTags true if the array of tags are inline and false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    public void checkTags(Doc doc, Tag[] tags, boolean areInlineTags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
        if (tags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
        Taglet taglet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
        for (int i = 0; i < tags.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
            String name = tags[i].name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
            if (name.length() > 0 && name.charAt(0) == '@') {
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
                name = name.substring(1, name.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
            if (! (standardTags.contains(name) || customTags.containsKey(name))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
                if (standardTagsLowercase.contains(name.toLowerCase())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
                    message.warning(tags[i].position(), "doclet.UnknownTagLowercase", tags[i].name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
                    message.warning(tags[i].position(), "doclet.UnknownTag", tags[i].name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
            //Check if this tag is being used in the wrong location.
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   375
            if ((taglet = customTags.get(name)) != null) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
                if (areInlineTags && ! taglet.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
                    printTagMisuseWarn(taglet, tags[i], "inline");
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
                if ((doc instanceof RootDoc) && ! taglet.inOverview()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
                    printTagMisuseWarn(taglet, tags[i], "overview");
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
                } else if ((doc instanceof PackageDoc) && ! taglet.inPackage()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
                    printTagMisuseWarn(taglet, tags[i], "package");
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
                } else if ((doc instanceof ClassDoc) && ! taglet.inType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
                    printTagMisuseWarn(taglet, tags[i], "class");
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
                } else if ((doc instanceof ConstructorDoc) && ! taglet.inConstructor()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
                    printTagMisuseWarn(taglet, tags[i], "constructor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
                } else if ((doc instanceof FieldDoc) && ! taglet.inField()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
                    printTagMisuseWarn(taglet, tags[i], "field");
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
                } else if ((doc instanceof MethodDoc) && ! taglet.inMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
                    printTagMisuseWarn(taglet, tags[i], "method");
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
     * Given the taglet, the tag and the type of documentation that the tag
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
     * was found in, print a tag misuse warning.
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
     * @param taglet the taglet representing the misused tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
     * @param tag the misused tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
     * @param holderType the type of documentation that the misused tag was found in.
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   404
        Set<String> locationsSet = new LinkedHashSet<String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
        if (taglet.inOverview()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            locationsSet.add("overview");
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
        if (taglet.inPackage()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
            locationsSet.add("package");
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
        if (taglet.inType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
            locationsSet.add("class/interface");
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
        if (taglet.inConstructor())  {
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
            locationsSet.add("constructor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
        if (taglet.inField()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
            locationsSet.add("field");
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
        if (taglet.inMethod()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
            locationsSet.add("method");
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
        if (taglet.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
            locationsSet.add("inline text");
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   426
        String[] locations = locationsSet.toArray(new String[]{});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
        if (locations == null || locations.length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
            //This known tag is excluded.
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
        }
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14260
diff changeset
   431
        StringBuilder combined_locations = new StringBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
        for (int i = 0; i < locations.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
            if (i > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
                combined_locations.append(", ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
            combined_locations.append(locations[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
        message.warning(tag.position(), "doclet.tag_misuse",
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
            "@" + taglet.getName(), holderType, combined_locations.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
     * appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
     * appear in packages.
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
    public Taglet[] getPackageCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        if (packageTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
        return packageTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
     * appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
     * appear in classes or interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
    public Taglet[] getTypeCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
        if (typeTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
        return typeTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
     * Return the array of inline <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
     * appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
     * appear in comments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
    public Taglet[] getInlineCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
        if (inlineTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
        return inlineTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
     * appear in fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
     * appear in field.
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
    public Taglet[] getFieldCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
        if (fieldTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
        return fieldTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
     * appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
     * appear in the serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
    public Taglet[] getSerializedFormTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
        if (serializedFormTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
        return serializedFormTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
     * appear in the given Doc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
    public Taglet[] getCustomTags(Doc doc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        if (doc instanceof ConstructorDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
            return getConstructorCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        } else if (doc instanceof MethodDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
            return getMethodCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
        } else if (doc instanceof FieldDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   517
            return getFieldCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
        } else if (doc instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
            return getTypeCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
        } else if (doc instanceof PackageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
            return getPackageCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
        } else if (doc instanceof RootDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
            return getOverviewCustomTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
     * appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
     * appear in constructors.
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
    public Taglet[] getConstructorCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
        if (constructorTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
        return constructorTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
     * appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
     * appear in methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
    public Taglet[] getMethodCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
        if (methodTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
        return methodTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
     * Return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
     * appear in an overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
     * @return the array of <code>Taglet</code>s that can
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
     * appear in overview.
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
    public Taglet[] getOverviewCustomTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
        if (overviewTags == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
            initCustomTagArrays();
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
        return overviewTags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
     * Initialize the custom tag arrays.
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
    private void initCustomTagArrays() {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   571
        Iterator<Taglet> it = customTags.values().iterator();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   572
        ArrayList<Taglet> pTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   573
        ArrayList<Taglet> tTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   574
        ArrayList<Taglet> fTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   575
        ArrayList<Taglet> cTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   576
        ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   577
        ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   578
        ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size());
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   579
        ArrayList<Taglet> sTags = new ArrayList<Taglet>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
        Taglet current;
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
        while (it.hasNext()) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   582
            current = it.next();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
            if (current.inPackage() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
                pTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
            if (current.inType() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
                tTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
            if (current.inField() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
                fTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
            if (current.inConstructor() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
                cTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   595
            if (current.inMethod() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
                mTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
            if (current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
                iTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   600
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
            if (current.inOverview() && !current.isInlineTag()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   602
                oTags.add(current);
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   605
        packageTags = pTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   606
        typeTags = tTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   607
        fieldTags = fTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   608
        constructorTags = cTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   609
        methodTags = mTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   610
        overviewTags = oTags.toArray(new Taglet[] {});
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   611
        inlineTags = iTags.toArray(new Taglet[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
        //Init the serialized form tags
13842
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   614
        sTags.add(customTags.get("serialData"));
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   615
        sTags.add(customTags.get("throws"));
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   616
        if (!nosince)
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   617
            sTags.add(customTags.get("since"));
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   618
        sTags.add(customTags.get("see"));
6908f6badce4 7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents: 5520
diff changeset
   619
        serializedFormTags = sTags.toArray(new Taglet[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
     * Initialize standard Javadoc tags for ordering purposes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   625
    private void initStandardTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
        Taglet temp;
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
        customTags.put((temp = new ParamTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
        customTags.put((temp = new ReturnTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   629
        customTags.put((temp = new ThrowsTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   630
        customTags.put((temp = new SimpleTaglet("exception",
06bc494ca11e Initial load
duke
parents:
diff changeset
   631
            null, SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   632
        if (!nosince) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   633
            customTags.put((temp = new SimpleTaglet("since", message.getText("doclet.Since"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   634
               SimpleTaglet.ALL)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   635
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
        if (showversion) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
            customTags.put((temp = new SimpleTaglet("version", message.getText("doclet.Version"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   638
                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   639
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   640
        if (showauthor) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   641
            customTags.put((temp = new SimpleTaglet("author", message.getText("doclet.Author"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
                SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
        customTags.put((temp = new SimpleTaglet("serialData", message.getText("doclet.SerialData"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   645
            SimpleTaglet.EXCLUDED)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   646
        customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   647
            SimpleTaglet.METHOD)).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   648
        customTags.put((temp = new SeeTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   649
        //Standard inline tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   650
        customTags.put((temp = new DocRootTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   651
        customTags.put((temp = new InheritDocTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   652
        customTags.put((temp = new ValueTaglet()).getName(), temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   653
        customTags.put((temp = new LegacyTaglet(new LiteralTaglet())).getName(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   654
            temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   655
        customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
            temp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
06bc494ca11e Initial load
duke
parents:
diff changeset
   658
        //Keep track of the names of standard tags for error
06bc494ca11e Initial load
duke
parents:
diff changeset
   659
        //checking purposes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   660
        standardTags.add("param");
06bc494ca11e Initial load
duke
parents:
diff changeset
   661
        standardTags.add("return");
06bc494ca11e Initial load
duke
parents:
diff changeset
   662
        standardTags.add("throws");
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
        standardTags.add("exception");
06bc494ca11e Initial load
duke
parents:
diff changeset
   664
        standardTags.add("since");
06bc494ca11e Initial load
duke
parents:
diff changeset
   665
        standardTags.add("version");
06bc494ca11e Initial load
duke
parents:
diff changeset
   666
        standardTags.add("author");
06bc494ca11e Initial load
duke
parents:
diff changeset
   667
        standardTags.add("see");
06bc494ca11e Initial load
duke
parents:
diff changeset
   668
        standardTags.add("deprecated");
06bc494ca11e Initial load
duke
parents:
diff changeset
   669
        standardTags.add("link");
06bc494ca11e Initial load
duke
parents:
diff changeset
   670
        standardTags.add("linkplain");
06bc494ca11e Initial load
duke
parents:
diff changeset
   671
        standardTags.add("inheritDoc");
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
        standardTags.add("docRoot");
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
        standardTags.add("value");
06bc494ca11e Initial load
duke
parents:
diff changeset
   674
        standardTags.add("serial");
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
        standardTags.add("serialData");
06bc494ca11e Initial load
duke
parents:
diff changeset
   676
        standardTags.add("serialField");
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
        standardTags.add("Text");
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
        standardTags.add("literal");
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
        standardTags.add("code");
06bc494ca11e Initial load
duke
parents:
diff changeset
   680
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
06bc494ca11e Initial load
duke
parents:
diff changeset
   682
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
     * Initialize lowercase version of standard Javadoc tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
    private void initStandardTagsLowercase() {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   686
        Iterator<String> it = standardTags.iterator();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
        while (it.hasNext()) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   688
            standardTagsLowercase.add(it.next().toLowerCase());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
06bc494ca11e Initial load
duke
parents:
diff changeset
   692
    public boolean isKnownCustomTag(String tagName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
        return customTags.containsKey(tagName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
     * Print a list of {@link Taglet}s that might conflict with
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
     * standard tags in the future and a list of standard tags
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
     * that have been overriden.
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
    public void printReport() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
        printReportHelper("doclet.Notice_taglet_conflict_warn", potentiallyConflictingTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
        printReportHelper("doclet.Notice_taglet_overriden", overridenStandardTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   704
        printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   706
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   707
    private void printReportHelper(String noticeKey, Set<String> names) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   708
        if (names.size() > 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   709
            String[] namesArray = names.toArray(new String[] {});
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   710
            String result = " ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   711
            for (int i = 0; i < namesArray.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
                result += "@" + namesArray[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
                if (i + 1 < namesArray.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   714
                    result += ", ";
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
            message.notice(noticeKey, result);
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
     * Given the name of a tag, return the corresponding taglet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
     * Return null if the tag is unknown.
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   725
     * @param name the name of the taglet to retrieve.
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
     * @return return the corresponding taglet. Return null if the tag is
06bc494ca11e Initial load
duke
parents:
diff changeset
   727
     *         unknown.
06bc494ca11e Initial load
duke
parents:
diff changeset
   728
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   729
    public Taglet getTaglet(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
        if (name.indexOf("@") == 0) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   731
            return customTags.get(name.substring(1));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   732
        } else {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   733
            return customTags.get(name);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   734
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   735
06bc494ca11e Initial load
duke
parents:
diff changeset
   736
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   737
}