25
25
26
26
package jdk .javadoc .internal .doclets .formats .html ;
27
27
28
- import java .util .*;
29
-
30
- import javax .lang .model .element .TypeElement ;
31
-
32
28
import jdk .javadoc .internal .doclets .formats .html .markup .HtmlStyle ;
33
- import jdk .javadoc .internal .doclets .formats .html .markup .TagName ;
34
29
import jdk .javadoc .internal .doclets .formats .html .markup .HtmlTree ;
30
+ import jdk .javadoc .internal .doclets .formats .html .markup .TagName ;
35
31
import jdk .javadoc .internal .doclets .toolkit .Content ;
36
32
import jdk .javadoc .internal .doclets .toolkit .util .ClassTree ;
33
+ import jdk .javadoc .internal .doclets .toolkit .util .ClassTree .Hierarchy ;
37
34
import jdk .javadoc .internal .doclets .toolkit .util .DocPath ;
38
35
36
+ import javax .lang .model .element .TypeElement ;
37
+ import java .util .Collection ;
38
+ import java .util .SortedSet ;
39
+ import java .util .TreeSet ;
40
+
39
41
40
42
/**
41
43
* Abstract class to print the class hierarchy page for all the Classes. This
@@ -48,20 +50,19 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
48
50
/**
49
51
* The class and interface tree built by using {@link ClassTree}
50
52
*/
51
- protected final ClassTree classtree ;
53
+ protected final ClassTree classTree ;
52
54
53
55
/**
54
- * Constructor initializes classtree variable. This constructor will be used
55
- * while generating global tree file "overview-tree.html".
56
+ * Constructor. This constructor will be used while generating global tree file "overview-tree.html".
56
57
*
57
58
* @param configuration The current configuration
58
59
* @param filename File to be generated.
59
- * @param classtree Tree built by {@link ClassTree}.
60
+ * @param classTree Tree built by {@link ClassTree}.
60
61
*/
61
62
protected AbstractTreeWriter (HtmlConfiguration configuration ,
62
- DocPath filename , ClassTree classtree ) {
63
+ DocPath filename , ClassTree classTree ) {
63
64
super (configuration , filename );
64
- this .classtree = classtree ;
65
+ this .classTree = classTree ;
65
66
}
66
67
67
68
/**
@@ -71,56 +72,48 @@ protected AbstractTreeWriter(HtmlConfiguration configuration,
71
72
*
72
73
* @param parent the superclass or superinterface of the sset
73
74
* @param collection a collection of the sub-classes at this level
74
- * @param isEnum true if we are generating a tree for enums
75
+ * @param hierarchy the hierarchy for which we are generating a tree
75
76
* @param content the content to which the level information will be added
76
77
*/
77
78
protected void addLevelInfo (TypeElement parent , Collection <TypeElement > collection ,
78
- boolean isEnum , Content content ) {
79
+ Hierarchy hierarchy , Content content ) {
79
80
if (!collection .isEmpty ()) {
80
81
var ul = new HtmlTree (TagName .UL );
81
82
for (TypeElement local : collection ) {
82
83
var li = new HtmlTree (TagName .LI );
83
84
li .setStyle (HtmlStyle .circle );
84
85
addPartialInfo (local , li );
85
86
addExtendsImplements (parent , local , li );
86
- addLevelInfo (local , classtree .directSubClasses (local , isEnum ),
87
- isEnum , li ); // Recurse
87
+ addLevelInfo (local , hierarchy .subtypes (local ), hierarchy , li ); // Recurse
88
88
ul .add (li );
89
89
}
90
90
content .add (ul );
91
91
}
92
92
}
93
93
94
94
/**
95
- * Add the heading for the tree depending upon tree type if it's a
96
- * Class Tree or Interface tree.
95
+ * Adds a class or interface hierarchy with a given heading to given content.
97
96
*
98
- * @param sset classes which are at the most base level, all the
99
- * other classes in this run will derive from these classes
100
- * @param heading heading for the tree
101
- * @param content the content to which the tree will be added
97
+ * @param hierarchy the hierarchy to add
98
+ * @param heading the heading
99
+ * @param content the content to which to add the hierarchy
102
100
*/
103
- protected void addTree (SortedSet <TypeElement > sset , String heading , Content content ) {
104
- addTree (sset , heading , content , false );
105
- }
106
-
107
- protected void addTree (SortedSet <TypeElement > sset , String heading ,
108
- Content content , boolean isEnums ) {
109
- if (!sset .isEmpty ()) {
110
- TypeElement firstTypeElement = sset .first ();
101
+ protected void addTree (Hierarchy hierarchy , String heading , Content content ) {
102
+ SortedSet <TypeElement > roots = hierarchy .roots ();
103
+ if (!roots .isEmpty ()) {
104
+ TypeElement firstTypeElement = roots .first ();
111
105
Content headingContent = contents .getContent (heading );
112
106
var sectionHeading = HtmlTree .HEADING_TITLE (Headings .CONTENT_HEADING ,
113
107
headingContent );
114
108
var section = HtmlTree .SECTION (HtmlStyle .hierarchy , sectionHeading );
115
109
addLevelInfo (!utils .isPlainInterface (firstTypeElement ) ? firstTypeElement : null ,
116
- sset , isEnums , section );
110
+ roots , hierarchy , section );
117
111
content .add (section );
118
112
}
119
113
}
120
114
121
115
/**
122
- * Add information regarding the classes which this class extends or
123
- * implements.
116
+ * Add information regarding the classes which this class extends or implements.
124
117
*
125
118
* @param parent the parent class of the class being documented
126
119
* @param typeElement the TypeElement under consideration
1 commit comments
openjdk-notifier[bot] commentedon May 31, 2022
Review
Issues