author | bpatel |
Mon, 02 May 2011 02:13:02 -0700 | |
changeset 9606 | e5a619cb5dd3 |
parent 5520 | 86e4b9a9da40 |
child 14258 | 8d2148961366 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.internal.toolkit.util; |
|
27 |
||
28 |
import com.sun.javadoc.*; |
|
29 |
import java.util.*; |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
30 |
import com.sun.tools.doclets.internal.toolkit.Configuration; |
10 | 31 |
|
32 |
/** |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
33 |
* Build list of all the deprecated packages, classes, constructors, fields and methods. |
10 | 34 |
* |
35 |
* @author Atul M Dambalkar |
|
36 |
*/ |
|
37 |
public class DeprecatedAPIListBuilder { |
|
38 |
||
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
39 |
public static final int NUM_TYPES = 12; |
10 | 40 |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
41 |
public static final int PACKAGE = 0; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
42 |
public static final int INTERFACE = 1; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
43 |
public static final int CLASS = 2; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
44 |
public static final int ENUM = 3; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
45 |
public static final int EXCEPTION = 4; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
46 |
public static final int ERROR = 5; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
47 |
public static final int ANNOTATION_TYPE = 6; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
48 |
public static final int FIELD = 7; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
49 |
public static final int METHOD = 8; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
50 |
public static final int CONSTRUCTOR = 9; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
51 |
public static final int ENUM_CONSTANT = 10; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
52 |
public static final int ANNOTATION_TYPE_MEMBER = 11; |
10 | 53 |
|
54 |
/** |
|
55 |
* List of deprecated type Lists. |
|
56 |
*/ |
|
868 | 57 |
private List<List<Doc>> deprecatedLists; |
10 | 58 |
|
59 |
||
60 |
/** |
|
61 |
* Constructor. |
|
62 |
* |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
63 |
* @param configuration the current configuration of the doclet |
10 | 64 |
*/ |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
65 |
public DeprecatedAPIListBuilder(Configuration configuration) { |
868 | 66 |
deprecatedLists = new ArrayList<List<Doc>>(); |
10 | 67 |
for (int i = 0; i < NUM_TYPES; i++) { |
868 | 68 |
deprecatedLists.add(i, new ArrayList<Doc>()); |
10 | 69 |
} |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
70 |
buildDeprecatedAPIInfo(configuration); |
10 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
* Build the sorted list of all the deprecated APIs in this run. |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
75 |
* Build separate lists for deprecated packages, classes, constructors, |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
76 |
* methods and fields. |
10 | 77 |
* |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
78 |
* @param configuration the current configuration of the doclet. |
10 | 79 |
*/ |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
80 |
private void buildDeprecatedAPIInfo(Configuration configuration) { |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
81 |
PackageDoc[] packages = configuration.packages; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
82 |
PackageDoc pkg; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
83 |
for (int c = 0; c < packages.length; c++) { |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
84 |
pkg = packages[c]; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
85 |
if (Util.isDeprecated(pkg)) { |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
86 |
getList(PACKAGE).add(pkg); |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
87 |
} |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
88 |
} |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
89 |
ClassDoc[] classes = configuration.root.classes(); |
10 | 90 |
for (int i = 0; i < classes.length; i++) { |
91 |
ClassDoc cd = classes[i]; |
|
92 |
if (Util.isDeprecated(cd)) { |
|
93 |
if (cd.isOrdinaryClass()) { |
|
94 |
getList(CLASS).add(cd); |
|
95 |
} else if (cd.isInterface()) { |
|
96 |
getList(INTERFACE).add(cd); |
|
97 |
} else if (cd.isException()) { |
|
98 |
getList(EXCEPTION).add(cd); |
|
99 |
} else if (cd.isEnum()) { |
|
100 |
getList(ENUM).add(cd); |
|
101 |
} else if (cd.isError()) { |
|
102 |
getList(ERROR).add(cd); |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
103 |
} else if (cd.isAnnotationType()) { |
10 | 104 |
getList(ANNOTATION_TYPE).add(cd); |
105 |
} |
|
106 |
} |
|
107 |
composeDeprecatedList(getList(FIELD), cd.fields()); |
|
108 |
composeDeprecatedList(getList(METHOD), cd.methods()); |
|
109 |
composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors()); |
|
110 |
if (cd.isEnum()) { |
|
111 |
composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants()); |
|
112 |
} |
|
113 |
if (cd.isAnnotationType()) { |
|
114 |
composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER), |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
115 |
((AnnotationTypeDoc) cd).elements()); |
10 | 116 |
} |
117 |
} |
|
118 |
sortDeprecatedLists(); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Add the members into a single list of deprecated members. |
|
123 |
* |
|
124 |
* @param list List of all the particular deprecated members, e.g. methods. |
|
125 |
* @param members members to be added in the list. |
|
126 |
*/ |
|
868 | 127 |
private void composeDeprecatedList(List<Doc> list, MemberDoc[] members) { |
10 | 128 |
for (int i = 0; i < members.length; i++) { |
129 |
if (Util.isDeprecated(members[i])) { |
|
130 |
list.add(members[i]); |
|
131 |
} |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* Sort the deprecated lists for class kinds, fields, methods and |
|
137 |
* constructors. |
|
138 |
*/ |
|
139 |
private void sortDeprecatedLists() { |
|
140 |
for (int i = 0; i < NUM_TYPES; i++) { |
|
141 |
Collections.sort(getList(i)); |
|
142 |
} |
|
143 |
} |
|
144 |
||
145 |
/** |
|
146 |
* Return the list of deprecated Doc objects of a given type. |
|
147 |
* |
|
148 |
* @param the constant representing the type of list being returned. |
|
149 |
*/ |
|
868 | 150 |
public List<Doc> getList(int type) { |
151 |
return deprecatedLists.get(type); |
|
10 | 152 |
} |
153 |
||
154 |
/** |
|
155 |
* Return true if the list of a given type has size greater than 0. |
|
156 |
* |
|
157 |
* @param type the type of list being checked. |
|
158 |
*/ |
|
159 |
public boolean hasDocumentation(int type) { |
|
868 | 160 |
return (deprecatedLists.get(type)).size() > 0; |
10 | 161 |
} |
162 |
} |