langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java
author ksrini
Mon, 05 Jun 2017 13:45:34 -0700
changeset 45417 f7479ee8de69
parent 42277 2668b0bc7ad7
permissions -rw-r--r--
8177848: Rename Configuration(Impl) classes Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
     2
 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    26
package jdk.javadoc.internal.doclets.toolkit.util;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    27
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    29
import java.util.ArrayList;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    30
import java.util.Collection;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    31
import java.util.Collections;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    32
import java.util.Comparator;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    33
import java.util.HashMap;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    34
import java.util.Iterator;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    35
import java.util.List;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    36
import java.util.Map;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    37
import java.util.Set;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    38
import java.util.SortedSet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    39
import java.util.TreeSet;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9606
diff changeset
    40
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    41
import javax.lang.model.element.Element;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    42
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    43
import javax.lang.model.type.TypeMirror;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    44
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    45
import jdk.javadoc.doclet.DocletEnvironment;
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
    46
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
    47
import jdk.javadoc.internal.doclets.toolkit.Messages;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * Build Class Hierarchy for all the Classes. This class builds the Class
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * Tree and the Interface Tree separately.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    53
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    54
 *  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
    55
 *  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
    56
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * @see java.util.HashMap
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * @see java.util.List
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
public class ClassTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    65
     * List of base classes. Used to get the mapped listing of sub-classes.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    67
    private final SortedSet<TypeElement> baseClasses;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    70
     * Mapping for each Class with their sub classes
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    71
     */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    72
    private final Map<TypeElement, SortedSet<TypeElement>> subClasses = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    75
     * List of base-interfaces. Contains set of all the interfaces who do not
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * have super-interfaces. Can be used to get the mapped listing of
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * sub-interfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    79
    private final SortedSet<TypeElement> baseInterfaces;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    81
   /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    * Mapping for each Interface with their SubInterfaces
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    84
    private final Map<TypeElement, SortedSet<TypeElement>> subInterfaces = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    86
    private final SortedSet<TypeElement> baseEnums;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    87
    private final Map<TypeElement, SortedSet<TypeElement>> subEnums = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    89
    private final SortedSet<TypeElement> baseAnnotationTypes;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    90
    private final Map<TypeElement, SortedSet<TypeElement>> subAnnotationTypes = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    92
   /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    * Mapping for each Interface with classes who implement it.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    95
    private final Map<TypeElement, SortedSet<TypeElement>> implementingClasses = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
    97
    private final BaseConfiguration configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
    98
    private final Utils utils;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
    99
    private final Comparator<Element> comparator;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   100
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * Constructor. Build the Tree using the Root of this Javadoc run.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @param configuration the configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * @param noDeprecated Don't add deprecated classes in the class tree, if
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
   108
    public ClassTree(BaseConfiguration configuration, boolean noDeprecated) {
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   109
        this.configuration = configuration;
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   110
        this.utils = configuration.utils;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   111
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   112
        Messages messages = configuration.getMessages();
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   113
        messages.notice("doclet.Building_Tree");
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 39364
diff changeset
   114
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   115
        comparator = utils.makeClassUseComparator();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   116
        baseAnnotationTypes = new TreeSet<>(comparator);
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   117
        baseEnums = new TreeSet<>(comparator);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   118
        baseClasses = new TreeSet<>(comparator);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   119
        baseInterfaces = new TreeSet<>(comparator);
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 40508
diff changeset
   120
        buildTree(configuration.getIncludedTypeElements());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * Constructor. Build the Tree using the Root of this Javadoc run.
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     *
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40303
diff changeset
   126
     * @param docEnv the DocletEnvironment.
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   127
     * @param configuration The current configuration of the doclet.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
   129
    public ClassTree(DocletEnvironment docEnv, BaseConfiguration configuration) {
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   130
        this.configuration = configuration;
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   131
        this.utils = configuration.utils;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   132
        comparator = utils.makeClassUseComparator();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   133
        baseAnnotationTypes = new TreeSet<>(comparator);
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   134
        baseEnums = new TreeSet<>(comparator);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   135
        baseClasses = new TreeSet<>(comparator);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   136
        baseInterfaces = new TreeSet<>(comparator);
42277
2668b0bc7ad7 8164316: Refine the Doclet APIs
ksrini
parents: 40508
diff changeset
   137
        buildTree(configuration.getIncludedTypeElements());
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * Constructor. Build the tree for the given array of classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   143
     * @param classesSet a set of classes
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   144
     * @param configuration The current configuration of the doclet.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
   146
    public ClassTree(SortedSet<TypeElement>classesSet, BaseConfiguration configuration) {
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   147
        this.configuration = configuration;
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   148
        this.utils = configuration.utils;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   149
        comparator = utils.makeClassUseComparator();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   150
        baseAnnotationTypes = new TreeSet<>(comparator);
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   151
        baseEnums = new TreeSet<>(comparator);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   152
        baseClasses = new TreeSet<>(comparator);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   153
        baseInterfaces = new TreeSet<>(comparator);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   154
        buildTree(classesSet);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     * Generate mapping for the sub-classes for every class in this run.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   159
     * Return the sub-class set for java.lang.Object which will be having
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * sub-class listing for itself and also for each sub-class itself will
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * have their own sub-class lists.
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     * @param classes all the classes in this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   166
    private void buildTree(Iterable<TypeElement> classes) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   167
        for (TypeElement aClass : classes) {
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   168
            // In the tree page (e.g overview-tree.html) do not include
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   169
            // information of classes which are deprecated or are a part of a
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 5520
diff changeset
   170
            // deprecated package.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
            if (configuration.nodeprecated &&
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22163
diff changeset
   172
                    (utils.isDeprecated(aClass) ||
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   173
                    utils.isDeprecated(utils.containingPackage(aClass)))) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            }
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   176
37009
476d8d615222 8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents: 35426
diff changeset
   177
            if (utils.isHidden(aClass)) {
16319
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   178
                continue;
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   179
            }
e586bfeb39c5 7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents: 14260
diff changeset
   180
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   181
            if (utils.isEnum(aClass)) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   182
                processType(aClass, configuration, baseEnums, subEnums);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   183
            } else if (utils.isClass(aClass)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   184
                processType(aClass, configuration, baseClasses, subClasses);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   185
            } else if (utils.isInterface(aClass)) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   186
                processInterface(aClass);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   187
            } else if (utils.isAnnotationType(aClass)) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 16319
diff changeset
   188
                processType(aClass, configuration, baseAnnotationTypes,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                    subAnnotationTypes);
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   195
     * For the class passed map it to its own sub-class listing.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * For the Class passed, get the super class,
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * if superclass is non null, (it is not "java.lang.Object")
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   198
     * get the "value" from the hashmap for this key Class
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   199
     * if entry not found create one and get that.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   200
     * add this Class as a sub class in the set
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   201
     * Recurse till hits java.lang.Object Null SuperClass.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   203
     * @param typeElement for which sub class mapping is to be generated.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   204
     * @param configuration the current configuration of the doclet.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     */
45417
f7479ee8de69 8177848: Rename Configuration(Impl) classes
ksrini
parents: 42277
diff changeset
   206
    private void processType(TypeElement typeElement, BaseConfiguration configuration,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   207
            Collection<TypeElement> bases, Map<TypeElement, SortedSet<TypeElement>> subs) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   208
        TypeElement superclass = utils.getFirstVisibleSuperClassAsTypeElement(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        if (superclass != null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   210
            if (!add(subs, superclass, typeElement)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
                return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
                processType(superclass, configuration, bases, subs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   215
        } else {     // typeElement is java.lang.Object, add it once to the set
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   216
            if (!bases.contains(typeElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   217
                bases.add(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   220
        Set<TypeMirror> intfacs = utils.getAllInterfaces(typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   221
        for (TypeMirror intfac : intfacs) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   222
            add(implementingClasses, utils.asTypeElement(intfac), typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * For the interface passed get the interfaces which it extends, and then
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   228
     * put this interface in the sub-interface set of those interfaces. Do it
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * recursively. If a interface doesn't have super-interface just attach
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   230
     * that interface in the set of all the baseInterfaces.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   232
     * @param typeElement Interface under consideration.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   234
    private void processInterface(TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   235
        List<? extends TypeMirror> intfacs = typeElement.getInterfaces();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   236
        if (!intfacs.isEmpty()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   237
            for (TypeMirror intfac : intfacs) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   238
                if (!add(subInterfaces, utils.asTypeElement(intfac), typeElement)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
                    return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
                } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   241
                    processInterface(utils.asTypeElement(intfac));   // Recurse
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            // we need to add all the interfaces who do not have
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   246
            // super-interfaces to baseInterfaces set to traverse them
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   247
            if (!baseInterfaces.contains(typeElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   248
                baseInterfaces.add(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   254
     * Adjust the Class Tree. Add the class interface  in to it's super classes
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   255
     * or super interface's sub-interface set.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     * @param map the entire map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * @param superclass java.lang.Object or the super-interface.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   259
     * @param typeElement sub-interface to be mapped.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * @returns boolean true if class added, false if class already processed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   262
    private boolean add(Map<TypeElement, SortedSet<TypeElement>> map, TypeElement superclass, TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   263
        SortedSet<TypeElement> sset = map.computeIfAbsent(superclass, s ->  new TreeSet<>(comparator));
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   264
        if (sset.contains(typeElement)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   267
            sset.add(typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   273
     * From the map return the set of sub-classes or sub-interfaces. If set
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * is null create a new one and return it.
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * @param map The entire map.
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   277
     * @param typeElement class for which the sub-class set is requested.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   278
     * @returns a list of sub classes.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   280
    private SortedSet<TypeElement> get(Map<TypeElement, SortedSet<TypeElement>> map, TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   281
        return map.computeIfAbsent(typeElement, t ->  new TreeSet<>(comparator));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   285
     *  Return the sub-class set for the class passed.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   287
     * @param typeElement class whose sub-class set is required.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   289
    public SortedSet<TypeElement> subClasses(TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   290
        return get(subClasses, typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   294
     *  Return the sub-interface set for the interface passed.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   296
     * @param typeElement interface whose sub-interface set is required.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   298
    public SortedSet<TypeElement> subInterfaces(TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   299
        return get(subInterfaces, typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   303
     *  Return the set of classes which implement the interface passed.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   305
     * @param typeElement interface whose implementing-classes set is required.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   307
    public SortedSet<TypeElement> implementingClasses(TypeElement typeElement) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   308
        SortedSet<TypeElement> result = get(implementingClasses, typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   309
        SortedSet<TypeElement> intfcs = allSubClasses(typeElement, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   311
        // If class x implements a subinterface of typeElement, then it follows
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   312
        // that class x implements typeElement.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   313
        Iterator<TypeElement> subInterfacesIter = intfcs.iterator();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   314
        while (subInterfacesIter.hasNext()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   315
            Iterator<TypeElement> implementingClassesIter
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   316
                    = implementingClasses(subInterfacesIter.next()).iterator();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   317
            while (implementingClassesIter.hasNext()) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   318
                TypeElement c = implementingClassesIter.next();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   319
                if (!result.contains(c)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                    result.add(c);
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
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   328
     *  Return the sub-class/interface set for the class/interface passed.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   330
     * @param typeElement class/interface whose sub-class/interface set is required.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   331
     * @param isEnum true if the subClasses should be forced to come from the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
     * enum tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   334
    public SortedSet<TypeElement> directSubClasses(TypeElement typeElement, boolean isEnum) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   335
        return directSubClasses0(typeElement, isEnum);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   336
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   337
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   338
    private SortedSet<TypeElement> directSubClasses0(TypeElement typeElement, boolean isEnum) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        if (isEnum) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   340
            return get(subEnums, typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   341
        } else if (utils.isAnnotationType(typeElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   342
            return get(subAnnotationTypes, typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   343
        } else if (utils.isInterface(typeElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   344
            return get(subInterfaces, typeElement);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   345
        } else if (utils.isClass(typeElement)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   346
            return get(subClasses, typeElement);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
        } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   348
            return Collections.emptySortedSet();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   353
     * Return a set of all direct or indirect, sub-classes and subInterfaces
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   354
     * of the TypeElement argument.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   356
     * @param typeElement TypeElement whose sub-classes or sub-interfaces are requested.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   357
     * @param isEnum true if the subClasses should be forced to come from the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
     * enum tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   360
    public SortedSet<TypeElement> allSubClasses(TypeElement typeElement, boolean isEnum) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   361
        // new entries added to the set are searched as well, this is
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   362
        // really a work queue.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   363
        List<TypeElement> list = new ArrayList<>(directSubClasses(typeElement, isEnum));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
        for (int i = 0; i < list.size(); i++) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   365
            TypeElement te = list.get(i);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   366
            SortedSet<TypeElement> tset = directSubClasses0(te, isEnum);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   367
            for (TypeElement tte : tset) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   368
                if (!list.contains(tte)) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   369
                    list.add(tte);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   373
        SortedSet<TypeElement> out = new TreeSet<>(comparator);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   374
        out.addAll(list);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   375
        return out;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   379
     *  Return a set of base classes. This will have only one element namely
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   380
     *  the TypeElement for java.lang.Object, since this is the base class for all
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
     *  classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   383
    public SortedSet<TypeElement> baseClasses() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   384
        return baseClasses;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   388
     *  Return the set of base interfaces. This is the set of interfaces
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   389
     * which do not have super-interface.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   391
    public SortedSet<TypeElement> baseInterfaces() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   392
        return baseInterfaces;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   396
     *  Return the set of base enums. This is the set of enums
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
     *  which do not have super-enums.
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   399
    public SortedSet<TypeElement> baseEnums() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        return baseEnums;
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   404
     * Return the set of base annotation types. This is the set
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   405
     * of annotation types which do not have super-annotation types.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26270
diff changeset
   407
    public SortedSet<TypeElement> baseAnnotationTypes() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
        return baseAnnotationTypes;
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
}