author | briangoetz |
Wed, 18 Dec 2013 16:05:18 -0500 | |
changeset 22163 | 3651128c74eb |
parent 22159 | 682da512ec17 |
child 22165 | ec53c8946fc2 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
14258 | 2 |
* Copyright (c) 1998, 2012, 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 |
||
14258 | 28 |
import java.util.*; |
29 |
||
10 | 30 |
import com.sun.javadoc.*; |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.tools.doclets.internal.toolkit.Configuration; |
10 | 32 |
|
33 |
/** |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
34 |
* Build list of all the deprecated packages, classes, constructors, fields and methods. |
10 | 35 |
* |
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
36 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
37 |
* 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:
14259
diff
changeset
|
38 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
39 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
40 |
* |
10 | 41 |
* @author Atul M Dambalkar |
42 |
*/ |
|
43 |
public class DeprecatedAPIListBuilder { |
|
44 |
||
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
45 |
public static final int NUM_TYPES = 12; |
10 | 46 |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
47 |
public static final int PACKAGE = 0; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
48 |
public static final int INTERFACE = 1; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
49 |
public static final int CLASS = 2; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
50 |
public static final int ENUM = 3; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
51 |
public static final int EXCEPTION = 4; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
52 |
public static final int ERROR = 5; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
53 |
public static final int ANNOTATION_TYPE = 6; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
54 |
public static final int FIELD = 7; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
55 |
public static final int METHOD = 8; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
56 |
public static final int CONSTRUCTOR = 9; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
57 |
public static final int ENUM_CONSTANT = 10; |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
58 |
public static final int ANNOTATION_TYPE_MEMBER = 11; |
10 | 59 |
|
60 |
/** |
|
61 |
* List of deprecated type Lists. |
|
62 |
*/ |
|
868 | 63 |
private List<List<Doc>> deprecatedLists; |
10 | 64 |
|
65 |
||
66 |
/** |
|
67 |
* Constructor. |
|
68 |
* |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
69 |
* @param configuration the current configuration of the doclet |
10 | 70 |
*/ |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
71 |
public DeprecatedAPIListBuilder(Configuration configuration) { |
22163 | 72 |
deprecatedLists = new ArrayList<>(); |
10 | 73 |
for (int i = 0; i < NUM_TYPES; i++) { |
22163 | 74 |
deprecatedLists.add(i, new ArrayList<>()); |
10 | 75 |
} |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
76 |
buildDeprecatedAPIInfo(configuration); |
10 | 77 |
} |
78 |
||
79 |
/** |
|
80 |
* 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
|
81 |
* Build separate lists for deprecated packages, classes, constructors, |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
82 |
* methods and fields. |
10 | 83 |
* |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
84 |
* @param configuration the current configuration of the doclet. |
10 | 85 |
*/ |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
86 |
private void buildDeprecatedAPIInfo(Configuration configuration) { |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
87 |
PackageDoc[] packages = configuration.packages; |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14260
diff
changeset
|
88 |
for (PackageDoc pkg : packages) { |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
89 |
if (Util.isDeprecated(pkg)) { |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
90 |
getList(PACKAGE).add(pkg); |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
91 |
} |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
92 |
} |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14260
diff
changeset
|
93 |
for (ClassDoc cd : configuration.root.classes()) { |
10 | 94 |
if (Util.isDeprecated(cd)) { |
95 |
if (cd.isOrdinaryClass()) { |
|
96 |
getList(CLASS).add(cd); |
|
97 |
} else if (cd.isInterface()) { |
|
98 |
getList(INTERFACE).add(cd); |
|
99 |
} else if (cd.isException()) { |
|
100 |
getList(EXCEPTION).add(cd); |
|
101 |
} else if (cd.isEnum()) { |
|
102 |
getList(ENUM).add(cd); |
|
103 |
} else if (cd.isError()) { |
|
104 |
getList(ERROR).add(cd); |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
105 |
} else if (cd.isAnnotationType()) { |
10 | 106 |
getList(ANNOTATION_TYPE).add(cd); |
107 |
} |
|
108 |
} |
|
109 |
composeDeprecatedList(getList(FIELD), cd.fields()); |
|
110 |
composeDeprecatedList(getList(METHOD), cd.methods()); |
|
111 |
composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors()); |
|
112 |
if (cd.isEnum()) { |
|
113 |
composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants()); |
|
114 |
} |
|
115 |
if (cd.isAnnotationType()) { |
|
116 |
composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER), |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14260
diff
changeset
|
117 |
((AnnotationTypeDoc) cd).elements()); |
10 | 118 |
} |
119 |
} |
|
120 |
sortDeprecatedLists(); |
|
121 |
} |
|
122 |
||
123 |
/** |
|
124 |
* Add the members into a single list of deprecated members. |
|
125 |
* |
|
126 |
* @param list List of all the particular deprecated members, e.g. methods. |
|
127 |
* @param members members to be added in the list. |
|
128 |
*/ |
|
868 | 129 |
private void composeDeprecatedList(List<Doc> list, MemberDoc[] members) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14260
diff
changeset
|
130 |
for (MemberDoc member : members) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14260
diff
changeset
|
131 |
if (Util.isDeprecated(member)) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
14260
diff
changeset
|
132 |
list.add(member); |
10 | 133 |
} |
134 |
} |
|
135 |
} |
|
136 |
||
137 |
/** |
|
138 |
* Sort the deprecated lists for class kinds, fields, methods and |
|
139 |
* constructors. |
|
140 |
*/ |
|
141 |
private void sortDeprecatedLists() { |
|
142 |
for (int i = 0; i < NUM_TYPES; i++) { |
|
143 |
Collections.sort(getList(i)); |
|
144 |
} |
|
145 |
} |
|
146 |
||
147 |
/** |
|
148 |
* Return the list of deprecated Doc objects of a given type. |
|
149 |
* |
|
14259 | 150 |
* @param type the constant representing the type of list being returned. |
10 | 151 |
*/ |
868 | 152 |
public List<Doc> getList(int type) { |
153 |
return deprecatedLists.get(type); |
|
10 | 154 |
} |
155 |
||
156 |
/** |
|
157 |
* Return true if the list of a given type has size greater than 0. |
|
158 |
* |
|
159 |
* @param type the type of list being checked. |
|
160 |
*/ |
|
161 |
public boolean hasDocumentation(int type) { |
|
868 | 162 |
return (deprecatedLists.get(type)).size() > 0; |
10 | 163 |
} |
164 |
} |