langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java
author ksrini
Thu, 18 Aug 2016 05:48:35 -0700
changeset 40508 74ef30d16fb9
parent 40303 96a1226aca18
child 40511 1b3c502e0bdc
permissions -rw-r--r--
8159305: Enhance the javadoc tool to support module related options Reviewed-by: bpatel, jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
     2
 * Copyright (c) 1998, 2016, 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: 25874
diff changeset
    26
package jdk.javadoc.internal.doclets.toolkit.util;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9606
diff changeset
    28
import java.util.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9606
diff changeset
    29
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    30
import javax.lang.model.element.Element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    31
import javax.lang.model.element.PackageElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    32
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    33
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    34
import jdk.javadoc.doclet.DocletEnvironment;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    35
import jdk.javadoc.internal.doclets.toolkit.Configuration;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
    36
import jdk.javadoc.internal.doclets.toolkit.Messages;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * Build the mapping of each Unicode character with it's member lists
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * containing members names starting with it. Also build a list for all the
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * Unicode characters which start a member name. Member name is
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * classkind or field or method or constructor name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    44
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    45
 *  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
    46
 *  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
    47
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * @see java.lang.Character
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
public class IndexBuilder {
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * Mapping of each Unicode Character with the member list containing
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * members with names starting with it.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    58
    private final Map<Character, SortedSet<Element>> indexmap;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Don't generate deprecated information if true.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    private boolean noDeprecated;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Build this Index only for classes?
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    private boolean classesOnly;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
    70
    /**
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
    71
     * Indicates javafx mode.
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
    72
     */
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
    73
    private boolean javafx;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
    74
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    75
    private final Configuration configuration;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
    76
    private final Utils utils;
37752
4243173b58db 8155061: javadoc incorrectly sorted items in All Classes list and Index files
ksrini
parents: 37009
diff changeset
    77
    private final Comparator<Element> comparator;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * Constructor. Build the index map.
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * @param noDeprecated  true if -nodeprecated option is used,
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     *                      false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    public IndexBuilder(Configuration configuration, boolean noDeprecated) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        this(configuration, noDeprecated, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Constructor. Build the index map.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * @param noDeprecated  true if -nodeprecated option is used,
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     *                      false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * @param classesOnly   Include only classes in index.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    public IndexBuilder(Configuration configuration, boolean noDeprecated,
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                        boolean classesOnly) {
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 24297
diff changeset
   100
        this.configuration  = configuration;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   101
        this.utils = configuration.utils;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   102
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   103
        Messages messages = configuration.getMessages();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        if (classesOnly) {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   105
            messages.notice("doclet.Building_Index_For_All_Classes");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        } else {
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   107
            messages.notice("doclet.Building_Index");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        }
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   109
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        this.noDeprecated = noDeprecated;
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        this.classesOnly = classesOnly;
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   112
        this.javafx = configuration.javafx;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   113
        this.indexmap = new TreeMap<>();
37752
4243173b58db 8155061: javadoc incorrectly sorted items in All Classes list and Index files
ksrini
parents: 37009
diff changeset
   114
        comparator = classesOnly
4243173b58db 8155061: javadoc incorrectly sorted items in All Classes list and Index files
ksrini
parents: 37009
diff changeset
   115
                ? utils.makeAllClassesComparator()
4243173b58db 8155061: javadoc incorrectly sorted items in All Classes list and Index files
ksrini
parents: 37009
diff changeset
   116
                : utils.makeIndexUseComparator();
39364
bd6d4a7936b4 8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents: 37752
diff changeset
   117
        buildIndexMap(configuration.docEnv);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * Get all the members in all the Packages and all the Classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * given on the command line. Form separate list of those members depending
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * upon their names.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     *
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40303
diff changeset
   125
     * @param docEnv the doclet environment
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     */
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40303
diff changeset
   127
    protected void buildIndexMap(DocletEnvironment docEnv)  {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40303
diff changeset
   128
        Set<PackageElement> packages = configuration.getSpecifiedPackages();
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40303
diff changeset
   129
        Set<TypeElement> classes = docEnv.getIncludedTypeElements();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        if (!classesOnly) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   131
            if (packages.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   132
                Set<PackageElement> set = new HashSet<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   133
                for (TypeElement aClass : classes) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   134
                    PackageElement pkg = utils.containingPackage(aClass);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   135
                    if (pkg != null && !pkg.isUnnamed()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   136
                        set.add(pkg);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
                }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   139
                adjustIndexMap(set);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
                adjustIndexMap(packages);
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        adjustIndexMap(classes);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        if (!classesOnly) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   146
            for (TypeElement aClass : classes) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   147
                if (shouldAddToIndexMap(aClass)) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   148
                    putMembersInIndexMap(aClass);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   155
     * Put all the members(fields, methods and constructors) in the te
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * to the indexmap.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   158
     * @param te TypeElement whose members will be added to the indexmap.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   160
    protected void putMembersInIndexMap(TypeElement te) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   161
        adjustIndexMap(utils.getAnnotationFields(te));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   162
        adjustIndexMap(utils.getFields(te));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   163
        adjustIndexMap(utils.getMethods(te));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   164
        adjustIndexMap(utils.getConstructors(te));
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
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * Adjust list of members according to their names. Check the first
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * character in a member name, and then add the member to a list of members
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * for that particular unicode character.
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * @param elements Array of members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   175
    protected void adjustIndexMap(Iterable<? extends Element> elements) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   176
        for (Element element : elements) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   177
            if (shouldAddToIndexMap(element)) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   178
                String name = utils.isPackage(element)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   179
                        ? utils.getPackageName((PackageElement)element)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   180
                        : utils.getSimpleName(element);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   181
                char ch = (name.length() == 0) ?
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   182
                          '*' :
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   183
                          Character.toUpperCase(name.charAt(0));
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   184
                Character unicode = ch;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   185
                SortedSet<Element> list = indexmap.computeIfAbsent(unicode,
37752
4243173b58db 8155061: javadoc incorrectly sorted items in All Classes list and Index files
ksrini
parents: 37009
diff changeset
   186
                        c -> new TreeSet<>(comparator));
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   187
                list.add(element);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   193
     * Should this element be added to the index map?
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   195
    protected boolean shouldAddToIndexMap(Element element) {
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 35426
diff changeset
   196
        if (utils.isHidden(element)) {
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 35426
diff changeset
   197
            return false;
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   198
        }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   199
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   200
        if (utils.isPackage(element))
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   201
            // Do not add to index map if -nodeprecated option is set and the
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   202
            // package is marked as deprecated.
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 24297
diff changeset
   203
            return !(noDeprecated && configuration.utils.isDeprecated(element));
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   204
        else
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   205
            // Do not add to index map if -nodeprecated option is set and if the
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   206
            // element is marked as deprecated or the containing package is marked as
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   207
            // deprecated.
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   208
            return !(noDeprecated &&
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 24297
diff changeset
   209
                    (configuration.utils.isDeprecated(element) ||
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   210
                    configuration.utils.isDeprecated(utils.containingPackage(element))));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * Return a map of all the individual member lists with Unicode character.
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * @return Map index map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   218
    public Map<Character, SortedSet<Element>> getIndexMap() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        return indexmap;
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * Return the sorted list of members, for passed Unicode Character.
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * @param index index Unicode character.
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * @return List member list for specific Unicode character.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   228
    public List<? extends Element> getMemberList(Character index) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   229
        SortedSet<Element> set = indexmap.get(index);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   230
        if (set == null)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   231
            return null;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   232
        List<Element> out = new ArrayList<>();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   233
        out.addAll(set);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   234
        return out;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * Array of IndexMap keys, Unicode characters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   240
    public List<Character> index() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 25874
diff changeset
   241
        return new ArrayList<>(indexmap.keySet());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
}