1 /* |
1 /* |
2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
41 import javax.lang.model.element.Element; |
41 import javax.lang.model.element.Element; |
42 import javax.lang.model.element.TypeElement; |
42 import javax.lang.model.element.TypeElement; |
43 import javax.lang.model.type.TypeMirror; |
43 import javax.lang.model.type.TypeMirror; |
44 |
44 |
45 import jdk.javadoc.doclet.DocletEnvironment; |
45 import jdk.javadoc.doclet.DocletEnvironment; |
46 import jdk.javadoc.internal.doclets.toolkit.Configuration; |
46 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
47 import jdk.javadoc.internal.doclets.toolkit.Messages; |
47 import jdk.javadoc.internal.doclets.toolkit.Messages; |
48 |
48 |
49 /** |
49 /** |
50 * Build Class Hierarchy for all the Classes. This class builds the Class |
50 * Build Class Hierarchy for all the Classes. This class builds the Class |
51 * Tree and the Interface Tree separately. |
51 * Tree and the Interface Tree separately. |
92 /** |
92 /** |
93 * Mapping for each Interface with classes who implement it. |
93 * Mapping for each Interface with classes who implement it. |
94 */ |
94 */ |
95 private final Map<TypeElement, SortedSet<TypeElement>> implementingClasses = new HashMap<>(); |
95 private final Map<TypeElement, SortedSet<TypeElement>> implementingClasses = new HashMap<>(); |
96 |
96 |
97 private final Configuration configuration; |
97 private final BaseConfiguration configuration; |
98 private final Utils utils; |
98 private final Utils utils; |
99 private final Comparator<Element> comparator; |
99 private final Comparator<Element> comparator; |
100 |
100 |
101 /** |
101 /** |
102 * Constructor. Build the Tree using the Root of this Javadoc run. |
102 * Constructor. Build the Tree using the Root of this Javadoc run. |
103 * |
103 * |
104 * @param configuration the configuration of the doclet. |
104 * @param configuration the configuration of the doclet. |
105 * @param noDeprecated Don't add deprecated classes in the class tree, if |
105 * @param noDeprecated Don't add deprecated classes in the class tree, if |
106 * true. |
106 * true. |
107 */ |
107 */ |
108 public ClassTree(Configuration configuration, boolean noDeprecated) { |
108 public ClassTree(BaseConfiguration configuration, boolean noDeprecated) { |
109 this.configuration = configuration; |
109 this.configuration = configuration; |
110 this.utils = configuration.utils; |
110 this.utils = configuration.utils; |
111 |
111 |
112 Messages messages = configuration.getMessages(); |
112 Messages messages = configuration.getMessages(); |
113 messages.notice("doclet.Building_Tree"); |
113 messages.notice("doclet.Building_Tree"); |
124 * Constructor. Build the Tree using the Root of this Javadoc run. |
124 * Constructor. Build the Tree using the Root of this Javadoc run. |
125 * |
125 * |
126 * @param docEnv the DocletEnvironment. |
126 * @param docEnv the DocletEnvironment. |
127 * @param configuration The current configuration of the doclet. |
127 * @param configuration The current configuration of the doclet. |
128 */ |
128 */ |
129 public ClassTree(DocletEnvironment docEnv, Configuration configuration) { |
129 public ClassTree(DocletEnvironment docEnv, BaseConfiguration configuration) { |
130 this.configuration = configuration; |
130 this.configuration = configuration; |
131 this.utils = configuration.utils; |
131 this.utils = configuration.utils; |
132 comparator = utils.makeClassUseComparator(); |
132 comparator = utils.makeClassUseComparator(); |
133 baseAnnotationTypes = new TreeSet<>(comparator); |
133 baseAnnotationTypes = new TreeSet<>(comparator); |
134 baseEnums = new TreeSet<>(comparator); |
134 baseEnums = new TreeSet<>(comparator); |
141 * Constructor. Build the tree for the given array of classes. |
141 * Constructor. Build the tree for the given array of classes. |
142 * |
142 * |
143 * @param classesSet a set of classes |
143 * @param classesSet a set of classes |
144 * @param configuration The current configuration of the doclet. |
144 * @param configuration The current configuration of the doclet. |
145 */ |
145 */ |
146 public ClassTree(SortedSet<TypeElement>classesSet, Configuration configuration) { |
146 public ClassTree(SortedSet<TypeElement>classesSet, BaseConfiguration configuration) { |
147 this.configuration = configuration; |
147 this.configuration = configuration; |
148 this.utils = configuration.utils; |
148 this.utils = configuration.utils; |
149 comparator = utils.makeClassUseComparator(); |
149 comparator = utils.makeClassUseComparator(); |
150 baseAnnotationTypes = new TreeSet<>(comparator); |
150 baseAnnotationTypes = new TreeSet<>(comparator); |
151 baseEnums = new TreeSet<>(comparator); |
151 baseEnums = new TreeSet<>(comparator); |
201 * Recurse till hits java.lang.Object Null SuperClass. |
201 * Recurse till hits java.lang.Object Null SuperClass. |
202 * |
202 * |
203 * @param typeElement for which sub class mapping is to be generated. |
203 * @param typeElement for which sub class mapping is to be generated. |
204 * @param configuration the current configuration of the doclet. |
204 * @param configuration the current configuration of the doclet. |
205 */ |
205 */ |
206 private void processType(TypeElement typeElement, Configuration configuration, |
206 private void processType(TypeElement typeElement, BaseConfiguration configuration, |
207 Collection<TypeElement> bases, Map<TypeElement, SortedSet<TypeElement>> subs) { |
207 Collection<TypeElement> bases, Map<TypeElement, SortedSet<TypeElement>> subs) { |
208 TypeElement superclass = utils.getFirstVisibleSuperClassAsTypeElement(typeElement); |
208 TypeElement superclass = utils.getFirstVisibleSuperClassAsTypeElement(typeElement); |
209 if (superclass != null) { |
209 if (superclass != null) { |
210 if (!add(subs, superclass, typeElement)) { |
210 if (!add(subs, superclass, typeElement)) { |
211 return; |
211 return; |