author | vromero |
Thu, 19 Dec 2013 20:16:44 +0000 | |
changeset 22165 | ec53c8946fc2 |
parent 22163 | 3651128c74eb |
child 22442 | 8fd30fc4e3a3 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15385 | 2 |
* Copyright (c) 1997, 2013, 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.javadoc; |
|
27 |
||
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
28 |
import java.io.File; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
29 |
import java.io.IOException; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
30 |
import java.lang.reflect.Modifier; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
31 |
import java.net.URI; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
32 |
import java.util.HashSet; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
33 |
import java.util.Set; |
14802 | 34 |
|
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
35 |
import javax.tools.FileObject; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
36 |
import javax.tools.JavaFileManager.Location; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
37 |
import javax.tools.StandardJavaFileManager; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
38 |
import javax.tools.StandardLocation; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
39 |
|
10 | 40 |
import com.sun.javadoc.*; |
14802 | 41 |
import com.sun.source.util.TreePath; |
10 | 42 |
import com.sun.tools.javac.code.Flags; |
43 |
import com.sun.tools.javac.code.Kinds; |
|
44 |
import com.sun.tools.javac.code.Scope; |
|
45 |
import com.sun.tools.javac.code.Symbol; |
|
46 |
import com.sun.tools.javac.code.Symbol.*; |
|
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
47 |
import com.sun.tools.javac.code.Type; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
48 |
import com.sun.tools.javac.code.Type.ClassType; |
18915
dcc9c8265f65
8016640: compiler hangs if the generics arity of a base class is wrong
mcimadamore
parents:
17275
diff
changeset
|
49 |
import com.sun.tools.javac.code.TypeTag; |
10 | 50 |
import com.sun.tools.javac.comp.AttrContext; |
51 |
import com.sun.tools.javac.comp.Env; |
|
52 |
import com.sun.tools.javac.tree.JCTree; |
|
53 |
import com.sun.tools.javac.tree.JCTree.JCFieldAccess; |
|
54 |
import com.sun.tools.javac.tree.JCTree.JCImport; |
|
55 |
import com.sun.tools.javac.tree.TreeInfo; |
|
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
56 |
import com.sun.tools.javac.util.List; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
57 |
import com.sun.tools.javac.util.ListBuffer; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
58 |
import com.sun.tools.javac.util.Name; |
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
59 |
import com.sun.tools.javac.util.Names; |
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
60 |
import com.sun.tools.javac.util.Position; |
10 | 61 |
import static com.sun.tools.javac.code.Kinds.*; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14260
diff
changeset
|
62 |
import static com.sun.tools.javac.code.TypeTag.CLASS; |
10950 | 63 |
import static com.sun.tools.javac.tree.JCTree.Tag.*; |
10 | 64 |
|
65 |
/** |
|
66 |
* Represents a java class and provides access to information |
|
67 |
* about the class, the class' comment and tags, and the |
|
68 |
* members of the class. A ClassDocImpl only exists if it was |
|
69 |
* processed in this run of javadoc. References to classes |
|
70 |
* which may or may not have been processed in this run are |
|
71 |
* referred to using Type (which can be converted to ClassDocImpl, |
|
72 |
* if possible). |
|
73 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
74 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
75 |
* 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
|
76 |
* 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
|
77 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
78 |
* |
10 | 79 |
* @see Type |
80 |
* |
|
81 |
* @since 1.2 |
|
82 |
* @author Robert Field |
|
83 |
* @author Neal Gafter (rewrite) |
|
84 |
* @author Scott Seligman (generics, enums, annotations) |
|
85 |
*/ |
|
86 |
||
87 |
public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { |
|
88 |
||
89 |
public final ClassType type; // protected->public for debugging |
|
90 |
protected final ClassSymbol tsym; |
|
91 |
||
92 |
boolean isIncluded = false; // Set in RootDocImpl |
|
93 |
||
94 |
private SerializedForm serializedForm; |
|
95 |
||
96 |
/** |
|
97 |
* Constructor |
|
98 |
*/ |
|
99 |
public ClassDocImpl(DocEnv env, ClassSymbol sym) { |
|
14802 | 100 |
this(env, sym, null); |
10 | 101 |
} |
102 |
||
103 |
/** |
|
104 |
* Constructor |
|
105 |
*/ |
|
14802 | 106 |
public ClassDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) { |
107 |
super(env, sym, treePath); |
|
10 | 108 |
this.type = (ClassType)sym.type; |
109 |
this.tsym = sym; |
|
110 |
} |
|
111 |
||
16969
b58d8a70d921
8009686: Generated javadoc documentation should be able to display type annotation on an array
bpatel
parents:
15385
diff
changeset
|
112 |
public com.sun.javadoc.Type getElementType() { |
b58d8a70d921
8009686: Generated javadoc documentation should be able to display type annotation on an array
bpatel
parents:
15385
diff
changeset
|
113 |
return null; |
b58d8a70d921
8009686: Generated javadoc documentation should be able to display type annotation on an array
bpatel
parents:
15385
diff
changeset
|
114 |
} |
b58d8a70d921
8009686: Generated javadoc documentation should be able to display type annotation on an array
bpatel
parents:
15385
diff
changeset
|
115 |
|
10 | 116 |
/** |
117 |
* Returns the flags in terms of javac's flags |
|
118 |
*/ |
|
119 |
protected long getFlags() { |
|
120 |
return getFlags(tsym); |
|
121 |
} |
|
122 |
||
123 |
/** |
|
124 |
* Returns the flags of a ClassSymbol in terms of javac's flags |
|
125 |
*/ |
|
126 |
static long getFlags(ClassSymbol clazz) { |
|
127 |
while (true) { |
|
128 |
try { |
|
129 |
return clazz.flags(); |
|
130 |
} catch (CompletionFailure ex) { |
|
19669 | 131 |
/* Quietly ignore completion failures. |
132 |
* Note that a CompletionFailure can only |
|
133 |
* occur as a result of calling complete(), |
|
134 |
* which will always remove the current |
|
135 |
* completer, leaving it to be null or |
|
136 |
* follow-up completer. Thus the loop |
|
137 |
* is guaranteed to eventually terminate. |
|
138 |
*/ |
|
10 | 139 |
} |
140 |
} |
|
141 |
} |
|
142 |
||
143 |
/** |
|
144 |
* Is a ClassSymbol an annotation type? |
|
145 |
*/ |
|
146 |
static boolean isAnnotationType(ClassSymbol clazz) { |
|
147 |
return (getFlags(clazz) & Flags.ANNOTATION) != 0; |
|
148 |
} |
|
149 |
||
150 |
/** |
|
151 |
* Identify the containing class |
|
152 |
*/ |
|
153 |
protected ClassSymbol getContainingClass() { |
|
154 |
return tsym.owner.enclClass(); |
|
155 |
} |
|
156 |
||
157 |
/** |
|
158 |
* Return true if this is a class, not an interface. |
|
159 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
160 |
@Override |
10 | 161 |
public boolean isClass() { |
162 |
return !Modifier.isInterface(getModifiers()); |
|
163 |
} |
|
164 |
||
165 |
/** |
|
166 |
* Return true if this is a ordinary class, |
|
167 |
* not an enumeration, exception, an error, or an interface. |
|
168 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
169 |
@Override |
10 | 170 |
public boolean isOrdinaryClass() { |
171 |
if (isEnum() || isInterface() || isAnnotationType()) { |
|
172 |
return false; |
|
173 |
} |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14260
diff
changeset
|
174 |
for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { |
10 | 175 |
if (t.tsym == env.syms.errorType.tsym || |
176 |
t.tsym == env.syms.exceptionType.tsym) { |
|
177 |
return false; |
|
178 |
} |
|
179 |
} |
|
180 |
return true; |
|
181 |
} |
|
182 |
||
183 |
/** |
|
184 |
* Return true if this is an enumeration. |
|
185 |
* (For legacy doclets, return false.) |
|
186 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
187 |
@Override |
10 | 188 |
public boolean isEnum() { |
189 |
return (getFlags() & Flags.ENUM) != 0 |
|
190 |
&& |
|
191 |
!env.legacyDoclet; |
|
192 |
} |
|
193 |
||
194 |
/** |
|
195 |
* Return true if this is an interface, but not an annotation type. |
|
196 |
* Overridden by AnnotationTypeDocImpl. |
|
197 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
198 |
@Override |
10 | 199 |
public boolean isInterface() { |
200 |
return Modifier.isInterface(getModifiers()); |
|
201 |
} |
|
202 |
||
203 |
/** |
|
204 |
* Return true if this is an exception class |
|
205 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
206 |
@Override |
10 | 207 |
public boolean isException() { |
208 |
if (isEnum() || isInterface() || isAnnotationType()) { |
|
209 |
return false; |
|
210 |
} |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14260
diff
changeset
|
211 |
for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { |
10 | 212 |
if (t.tsym == env.syms.exceptionType.tsym) { |
213 |
return true; |
|
214 |
} |
|
215 |
} |
|
216 |
return false; |
|
217 |
} |
|
218 |
||
219 |
/** |
|
220 |
* Return true if this is an error class |
|
221 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
222 |
@Override |
10 | 223 |
public boolean isError() { |
224 |
if (isEnum() || isInterface() || isAnnotationType()) { |
|
225 |
return false; |
|
226 |
} |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14260
diff
changeset
|
227 |
for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { |
10 | 228 |
if (t.tsym == env.syms.errorType.tsym) { |
229 |
return true; |
|
230 |
} |
|
231 |
} |
|
232 |
return false; |
|
233 |
} |
|
234 |
||
235 |
/** |
|
236 |
* Return true if this is a throwable class |
|
237 |
*/ |
|
238 |
public boolean isThrowable() { |
|
239 |
if (isEnum() || isInterface() || isAnnotationType()) { |
|
240 |
return false; |
|
241 |
} |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14260
diff
changeset
|
242 |
for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) { |
10 | 243 |
if (t.tsym == env.syms.throwableType.tsym) { |
244 |
return true; |
|
245 |
} |
|
246 |
} |
|
247 |
return false; |
|
248 |
} |
|
249 |
||
250 |
/** |
|
251 |
* Return true if this class is abstract |
|
252 |
*/ |
|
253 |
public boolean isAbstract() { |
|
254 |
return Modifier.isAbstract(getModifiers()); |
|
255 |
} |
|
256 |
||
257 |
/** |
|
258 |
* Returns true if this class was synthesized by the compiler. |
|
259 |
*/ |
|
260 |
public boolean isSynthetic() { |
|
261 |
return (getFlags() & Flags.SYNTHETIC) != 0; |
|
262 |
} |
|
263 |
||
264 |
/** |
|
265 |
* Return true if this class is included in the active set. |
|
266 |
* A ClassDoc is included iff either it is specified on the |
|
267 |
* commandline, or if it's containing package is specified |
|
268 |
* on the command line, or if it is a member class of an |
|
269 |
* included class. |
|
270 |
*/ |
|
271 |
||
272 |
public boolean isIncluded() { |
|
273 |
if (isIncluded) { |
|
274 |
return true; |
|
275 |
} |
|
276 |
if (env.shouldDocument(tsym)) { |
|
277 |
// Class is nameable from top-level and |
|
278 |
// the class and all enclosing classes |
|
279 |
// pass the modifier filter. |
|
280 |
if (containingPackage().isIncluded()) { |
|
281 |
return isIncluded=true; |
|
282 |
} |
|
283 |
ClassDoc outer = containingClass(); |
|
284 |
if (outer != null && outer.isIncluded()) { |
|
285 |
return isIncluded=true; |
|
286 |
} |
|
287 |
} |
|
288 |
return false; |
|
289 |
} |
|
290 |
||
14951
8d9ea42e4aba
8004814: javadoc should be able to detect default methods
vromero
parents:
14802
diff
changeset
|
291 |
public boolean isFunctionalInterface() { |
19912
4b1a79163f9c
8022738: doclet should only generate functional interface text if source >= 8
bpatel
parents:
19669
diff
changeset
|
292 |
return env.types.isFunctionalInterface(tsym) && env.source.allowLambda(); |
14951
8d9ea42e4aba
8004814: javadoc should be able to detect default methods
vromero
parents:
14802
diff
changeset
|
293 |
} |
8d9ea42e4aba
8004814: javadoc should be able to detect default methods
vromero
parents:
14802
diff
changeset
|
294 |
|
10 | 295 |
/** |
296 |
* Return the package that this class is contained in. |
|
297 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
298 |
@Override |
10 | 299 |
public PackageDoc containingPackage() { |
300 |
PackageDocImpl p = env.getPackageDoc(tsym.packge()); |
|
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
301 |
if (p.setDocPath == false) { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
302 |
FileObject docPath; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
303 |
try { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
304 |
Location location = env.fileManager.hasLocation(StandardLocation.SOURCE_PATH) |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
305 |
? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
306 |
|
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
307 |
docPath = env.fileManager.getFileForInput( |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
308 |
location, p.qualifiedName(), "package.html"); |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
309 |
} catch (IOException e) { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
310 |
docPath = null; |
10 | 311 |
} |
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
312 |
|
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
313 |
if (docPath == null) { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
314 |
// fall back on older semantics of looking in same directory as |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
315 |
// source file for this class |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
316 |
SourcePosition po = position(); |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
317 |
if (env.fileManager instanceof StandardJavaFileManager && |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
318 |
po instanceof SourcePositionImpl) { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
319 |
URI uri = ((SourcePositionImpl) po).filename.toUri(); |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
320 |
if ("file".equals(uri.getScheme())) { |
3782 | 321 |
File f = new File(uri); |
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
322 |
File dir = f.getParentFile(); |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
323 |
if (dir != null) { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
324 |
File pf = new File(dir, "package.html"); |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
325 |
if (pf.exists()) { |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
326 |
StandardJavaFileManager sfm = (StandardJavaFileManager) env.fileManager; |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
327 |
docPath = sfm.getJavaFileObjects(pf).iterator().next(); |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
328 |
} |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
329 |
} |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
330 |
|
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
331 |
} |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
332 |
} |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
333 |
} |
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
334 |
|
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
335 |
p.setDocPath(docPath); |
10 | 336 |
} |
337 |
return p; |
|
338 |
} |
|
339 |
||
340 |
/** |
|
341 |
* Return the class name without package qualifier - but with |
|
342 |
* enclosing class qualifier - as a String. |
|
343 |
* <pre> |
|
344 |
* Examples: |
|
345 |
* for java.util.Hashtable |
|
346 |
* return Hashtable |
|
347 |
* for java.util.Map.Entry |
|
348 |
* return Map.Entry |
|
349 |
* </pre> |
|
350 |
*/ |
|
351 |
public String name() { |
|
17275
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
352 |
if (name == null) { |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
353 |
name = getClassName(tsym, false); |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
354 |
} |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
355 |
return name; |
10 | 356 |
} |
357 |
||
17275
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
358 |
private String name; |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
359 |
|
10 | 360 |
/** |
361 |
* Return the qualified class name as a String. |
|
362 |
* <pre> |
|
363 |
* Example: |
|
364 |
* for java.util.Hashtable |
|
365 |
* return java.util.Hashtable |
|
366 |
* if no qualifier, just return flat name |
|
367 |
* </pre> |
|
368 |
*/ |
|
369 |
public String qualifiedName() { |
|
17275
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
370 |
if (qualifiedName == null) { |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
371 |
qualifiedName = getClassName(tsym, true); |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
372 |
} |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
373 |
return qualifiedName; |
10 | 374 |
} |
375 |
||
17275
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
376 |
private String qualifiedName; |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
377 |
|
10 | 378 |
/** |
379 |
* Return unqualified name of type excluding any dimension information. |
|
380 |
* <p> |
|
381 |
* For example, a two dimensional array of String returns 'String'. |
|
382 |
*/ |
|
383 |
public String typeName() { |
|
384 |
return name(); |
|
385 |
} |
|
386 |
||
387 |
/** |
|
388 |
* Return qualified name of type excluding any dimension information. |
|
389 |
*<p> |
|
390 |
* For example, a two dimensional array of String |
|
391 |
* returns 'java.lang.String'. |
|
392 |
*/ |
|
393 |
public String qualifiedTypeName() { |
|
394 |
return qualifiedName(); |
|
395 |
} |
|
396 |
||
397 |
/** |
|
398 |
* Return the simple name of this type. |
|
399 |
*/ |
|
400 |
public String simpleTypeName() { |
|
17275
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
401 |
if (simpleTypeName == null) { |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
402 |
simpleTypeName = tsym.name.toString(); |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
403 |
} |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
404 |
return simpleTypeName; |
10 | 405 |
} |
406 |
||
17275
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
407 |
private String simpleTypeName; |
bcaa1940863a
8012656: cache frequently used name strings for DocImpl classes
jjg
parents:
16969
diff
changeset
|
408 |
|
10 | 409 |
/** |
410 |
* Return the qualified name and any type parameters. |
|
411 |
* Each parameter is a type variable with optional bounds. |
|
412 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
413 |
@Override |
10 | 414 |
public String toString() { |
415 |
return classToString(env, tsym, true); |
|
416 |
} |
|
417 |
||
418 |
/** |
|
419 |
* Return the class name as a string. If "full" is true the name is |
|
420 |
* qualified, otherwise it is qualified by its enclosing class(es) only. |
|
421 |
*/ |
|
422 |
static String getClassName(ClassSymbol c, boolean full) { |
|
423 |
if (full) { |
|
424 |
return c.getQualifiedName().toString(); |
|
425 |
} else { |
|
426 |
String n = ""; |
|
427 |
for ( ; c != null; c = c.owner.enclClass()) { |
|
428 |
n = c.name + (n.equals("") ? "" : ".") + n; |
|
429 |
} |
|
430 |
return n; |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
/** |
|
435 |
* Return the class name with any type parameters as a string. |
|
436 |
* Each parameter is a type variable with optional bounds. |
|
437 |
* If "full" is true all names are qualified, otherwise they are |
|
438 |
* qualified by their enclosing class(es) only. |
|
439 |
*/ |
|
440 |
static String classToString(DocEnv env, ClassSymbol c, boolean full) { |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
441 |
StringBuilder s = new StringBuilder(); |
10 | 442 |
if (!c.isInner()) { // if c is not an inner class |
443 |
s.append(getClassName(c, full)); |
|
444 |
} else { |
|
445 |
// c is an inner class, so include type params of outer. |
|
446 |
ClassSymbol encl = c.owner.enclClass(); |
|
447 |
s.append(classToString(env, encl, full)) |
|
448 |
.append('.') |
|
449 |
.append(c.name); |
|
450 |
} |
|
451 |
s.append(TypeMaker.typeParametersString(env, c, full)); |
|
452 |
return s.toString(); |
|
453 |
} |
|
454 |
||
455 |
/** |
|
456 |
* Is this class (or any enclosing class) generic? That is, does |
|
457 |
* it have type parameters? |
|
458 |
*/ |
|
459 |
static boolean isGeneric(ClassSymbol c) { |
|
460 |
return c.type.allparams().nonEmpty(); |
|
461 |
} |
|
462 |
||
463 |
/** |
|
464 |
* Return the formal type parameters of this class or interface. |
|
465 |
* Return an empty array if there are none. |
|
466 |
*/ |
|
467 |
public TypeVariable[] typeParameters() { |
|
468 |
if (env.legacyDoclet) { |
|
469 |
return new TypeVariable[0]; |
|
470 |
} |
|
471 |
TypeVariable res[] = new TypeVariable[type.getTypeArguments().length()]; |
|
472 |
TypeMaker.getTypes(env, type.getTypeArguments(), res); |
|
473 |
return res; |
|
474 |
} |
|
475 |
||
476 |
/** |
|
477 |
* Return the type parameter tags of this class or interface. |
|
478 |
*/ |
|
479 |
public ParamTag[] typeParamTags() { |
|
480 |
return (env.legacyDoclet) |
|
481 |
? new ParamTag[0] |
|
482 |
: comment().typeParamTags(); |
|
483 |
} |
|
484 |
||
485 |
/** |
|
486 |
* Return the modifier string for this class. If it's an interface |
|
487 |
* exclude 'abstract' keyword from the modifier string |
|
488 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
489 |
@Override |
10 | 490 |
public String modifiers() { |
491 |
return Modifier.toString(modifierSpecifier()); |
|
492 |
} |
|
493 |
||
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
494 |
@Override |
10 | 495 |
public int modifierSpecifier() { |
496 |
int modifiers = getModifiers(); |
|
497 |
return (isInterface() || isAnnotationType()) |
|
498 |
? modifiers & ~Modifier.ABSTRACT |
|
499 |
: modifiers; |
|
500 |
} |
|
501 |
||
502 |
/** |
|
503 |
* Return the superclass of this class |
|
504 |
* |
|
505 |
* @return the ClassDocImpl for the superclass of this class, null |
|
506 |
* if there is no superclass. |
|
507 |
*/ |
|
508 |
public ClassDoc superclass() { |
|
509 |
if (isInterface() || isAnnotationType()) return null; |
|
510 |
if (tsym == env.syms.objectType.tsym) return null; |
|
511 |
ClassSymbol c = (ClassSymbol)env.types.supertype(type).tsym; |
|
512 |
if (c == null || c == tsym) c = (ClassSymbol)env.syms.objectType.tsym; |
|
513 |
return env.getClassDoc(c); |
|
514 |
} |
|
515 |
||
516 |
/** |
|
517 |
* Return the superclass of this class. Return null if this is an |
|
518 |
* interface. A superclass is represented by either a |
|
519 |
* <code>ClassDoc</code> or a <code>ParameterizedType</code>. |
|
520 |
*/ |
|
521 |
public com.sun.javadoc.Type superclassType() { |
|
522 |
if (isInterface() || isAnnotationType() || |
|
523 |
(tsym == env.syms.objectType.tsym)) |
|
524 |
return null; |
|
525 |
Type sup = env.types.supertype(type); |
|
526 |
return TypeMaker.getType(env, |
|
18915
dcc9c8265f65
8016640: compiler hangs if the generics arity of a base class is wrong
mcimadamore
parents:
17275
diff
changeset
|
527 |
(sup.hasTag(TypeTag.NONE)) ? env.syms.objectType : sup); |
10 | 528 |
} |
529 |
||
530 |
/** |
|
531 |
* Test whether this class is a subclass of the specified class. |
|
532 |
* |
|
533 |
* @param cd the candidate superclass. |
|
534 |
* @return true if cd is a superclass of this class. |
|
535 |
*/ |
|
536 |
public boolean subclassOf(ClassDoc cd) { |
|
537 |
return tsym.isSubClass(((ClassDocImpl)cd).tsym, env.types); |
|
538 |
} |
|
539 |
||
540 |
/** |
|
541 |
* Return interfaces implemented by this class or interfaces |
|
542 |
* extended by this interface. |
|
543 |
* |
|
544 |
* @return An array of ClassDocImpl representing the interfaces. |
|
545 |
* Return an empty array if there are no interfaces. |
|
546 |
*/ |
|
547 |
public ClassDoc[] interfaces() { |
|
22163 | 548 |
ListBuffer<ClassDocImpl> ta = new ListBuffer<>(); |
10 | 549 |
for (Type t : env.types.interfaces(type)) { |
550 |
ta.append(env.getClassDoc((ClassSymbol)t.tsym)); |
|
551 |
} |
|
552 |
//### Cache ta here? |
|
553 |
return ta.toArray(new ClassDocImpl[ta.length()]); |
|
554 |
} |
|
555 |
||
556 |
/** |
|
557 |
* Return interfaces implemented by this class or interfaces extended |
|
558 |
* by this interface. Includes only directly-declared interfaces, not |
|
559 |
* inherited interfaces. |
|
560 |
* Return an empty array if there are no interfaces. |
|
561 |
*/ |
|
562 |
public com.sun.javadoc.Type[] interfaceTypes() { |
|
563 |
//### Cache result here? |
|
564 |
return TypeMaker.getTypes(env, env.types.interfaces(type)); |
|
565 |
} |
|
566 |
||
567 |
/** |
|
568 |
* Return fields in class. |
|
569 |
* @param filter include only the included fields if filter==true |
|
570 |
*/ |
|
571 |
public FieldDoc[] fields(boolean filter) { |
|
572 |
return fields(filter, false); |
|
573 |
} |
|
574 |
||
575 |
/** |
|
576 |
* Return included fields in class. |
|
577 |
*/ |
|
578 |
public FieldDoc[] fields() { |
|
579 |
return fields(true, false); |
|
580 |
} |
|
581 |
||
582 |
/** |
|
583 |
* Return the enum constants if this is an enum type. |
|
584 |
*/ |
|
585 |
public FieldDoc[] enumConstants() { |
|
586 |
return fields(false, true); |
|
587 |
} |
|
588 |
||
589 |
/** |
|
590 |
* Return fields in class. |
|
591 |
* @param filter if true, return only the included fields |
|
592 |
* @param enumConstants if true, return the enum constants instead |
|
593 |
*/ |
|
594 |
private FieldDoc[] fields(boolean filter, boolean enumConstants) { |
|
595 |
List<FieldDocImpl> fields = List.nil(); |
|
596 |
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { |
|
597 |
if (e.sym != null && e.sym.kind == VAR) { |
|
598 |
VarSymbol s = (VarSymbol)e.sym; |
|
599 |
boolean isEnum = ((s.flags() & Flags.ENUM) != 0) && |
|
600 |
!env.legacyDoclet; |
|
601 |
if (isEnum == enumConstants && |
|
602 |
(!filter || env.shouldDocument(s))) { |
|
603 |
fields = fields.prepend(env.getFieldDoc(s)); |
|
604 |
} |
|
605 |
} |
|
606 |
} |
|
607 |
return fields.toArray(new FieldDocImpl[fields.length()]); |
|
608 |
} |
|
609 |
||
610 |
/** |
|
611 |
* Return methods in class. |
|
612 |
* This method is overridden by AnnotationTypeDocImpl. |
|
613 |
* |
|
614 |
* @param filter include only the included methods if filter==true |
|
615 |
* @return an array of MethodDocImpl for representing the visible |
|
616 |
* methods in this class. Does not include constructors. |
|
617 |
*/ |
|
618 |
public MethodDoc[] methods(boolean filter) { |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
619 |
Names names = tsym.name.table.names; |
10 | 620 |
List<MethodDocImpl> methods = List.nil(); |
621 |
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { |
|
21020
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
19912
diff
changeset
|
622 |
if (e.sym != null |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
19912
diff
changeset
|
623 |
&& e.sym.kind == Kinds.MTH |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
19912
diff
changeset
|
624 |
&& e.sym.name != names.init |
591de6ab30f4
8025693: recent javadoc changes cause com/sun/javadoc/testLinkOption/TestLinkOption.java to fail
jjg
parents:
19912
diff
changeset
|
625 |
&& e.sym.name != names.clinit) { |
10 | 626 |
MethodSymbol s = (MethodSymbol)e.sym; |
627 |
if (!filter || env.shouldDocument(s)) { |
|
628 |
methods = methods.prepend(env.getMethodDoc(s)); |
|
629 |
} |
|
630 |
} |
|
631 |
} |
|
632 |
//### Cache methods here? |
|
633 |
return methods.toArray(new MethodDocImpl[methods.length()]); |
|
634 |
} |
|
635 |
||
636 |
/** |
|
637 |
* Return included methods in class. |
|
638 |
* |
|
639 |
* @return an array of MethodDocImpl for representing the visible |
|
640 |
* methods in this class. Does not include constructors. |
|
641 |
*/ |
|
642 |
public MethodDoc[] methods() { |
|
643 |
return methods(true); |
|
644 |
} |
|
645 |
||
646 |
/** |
|
647 |
* Return constructors in class. |
|
648 |
* |
|
649 |
* @param filter include only the included constructors if filter==true |
|
650 |
* @return an array of ConstructorDocImpl for representing the visible |
|
651 |
* constructors in this class. |
|
652 |
*/ |
|
653 |
public ConstructorDoc[] constructors(boolean filter) { |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
654 |
Names names = tsym.name.table.names; |
10 | 655 |
List<ConstructorDocImpl> constructors = List.nil(); |
656 |
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { |
|
657 |
if (e.sym != null && |
|
658 |
e.sym.kind == Kinds.MTH && e.sym.name == names.init) { |
|
659 |
MethodSymbol s = (MethodSymbol)e.sym; |
|
660 |
if (!filter || env.shouldDocument(s)) { |
|
661 |
constructors = constructors.prepend(env.getConstructorDoc(s)); |
|
662 |
} |
|
663 |
} |
|
664 |
} |
|
665 |
//### Cache constructors here? |
|
666 |
return constructors.toArray(new ConstructorDocImpl[constructors.length()]); |
|
667 |
} |
|
668 |
||
669 |
/** |
|
670 |
* Return included constructors in class. |
|
671 |
* |
|
672 |
* @return an array of ConstructorDocImpl for representing the visible |
|
673 |
* constructors in this class. |
|
674 |
*/ |
|
675 |
public ConstructorDoc[] constructors() { |
|
676 |
return constructors(true); |
|
677 |
} |
|
678 |
||
679 |
/** |
|
680 |
* Adds all inner classes of this class, and their |
|
681 |
* inner classes recursively, to the list l. |
|
682 |
*/ |
|
683 |
void addAllClasses(ListBuffer<ClassDocImpl> l, boolean filtered) { |
|
684 |
try { |
|
685 |
if (isSynthetic()) return; |
|
686 |
// sometimes synthetic classes are not marked synthetic |
|
687 |
if (!JavadocTool.isValidClassName(tsym.name.toString())) return; |
|
688 |
if (filtered && !env.shouldDocument(tsym)) return; |
|
689 |
if (l.contains(this)) return; |
|
690 |
l.append(this); |
|
691 |
List<ClassDocImpl> more = List.nil(); |
|
692 |
for (Scope.Entry e = tsym.members().elems; e != null; |
|
693 |
e = e.sibling) { |
|
694 |
if (e.sym != null && e.sym.kind == Kinds.TYP) { |
|
695 |
ClassSymbol s = (ClassSymbol)e.sym; |
|
696 |
ClassDocImpl c = env.getClassDoc(s); |
|
697 |
if (c.isSynthetic()) continue; |
|
698 |
if (c != null) more = more.prepend(c); |
|
699 |
} |
|
700 |
} |
|
701 |
// this extra step preserves the ordering from oldjavadoc |
|
702 |
for (; more.nonEmpty(); more=more.tail) { |
|
703 |
more.head.addAllClasses(l, filtered); |
|
704 |
} |
|
705 |
} catch (CompletionFailure e) { |
|
706 |
// quietly ignore completion failures |
|
707 |
} |
|
708 |
} |
|
709 |
||
710 |
/** |
|
711 |
* Return inner classes within this class. |
|
712 |
* |
|
713 |
* @param filter include only the included inner classes if filter==true. |
|
714 |
* @return an array of ClassDocImpl for representing the visible |
|
715 |
* classes defined in this class. Anonymous and local classes |
|
716 |
* are not included. |
|
717 |
*/ |
|
718 |
public ClassDoc[] innerClasses(boolean filter) { |
|
22163 | 719 |
ListBuffer<ClassDocImpl> innerClasses = new ListBuffer<>(); |
10 | 720 |
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { |
721 |
if (e.sym != null && e.sym.kind == Kinds.TYP) { |
|
722 |
ClassSymbol s = (ClassSymbol)e.sym; |
|
723 |
if ((s.flags_field & Flags.SYNTHETIC) != 0) continue; |
|
724 |
if (!filter || env.isVisible(s)) { |
|
725 |
innerClasses.prepend(env.getClassDoc(s)); |
|
726 |
} |
|
727 |
} |
|
728 |
} |
|
729 |
//### Cache classes here? |
|
730 |
return innerClasses.toArray(new ClassDocImpl[innerClasses.length()]); |
|
731 |
} |
|
732 |
||
733 |
/** |
|
734 |
* Return included inner classes within this class. |
|
735 |
* |
|
736 |
* @return an array of ClassDocImpl for representing the visible |
|
737 |
* classes defined in this class. Anonymous and local classes |
|
738 |
* are not included. |
|
739 |
*/ |
|
740 |
public ClassDoc[] innerClasses() { |
|
741 |
return innerClasses(true); |
|
742 |
} |
|
743 |
||
744 |
/** |
|
745 |
* Find a class within the context of this class. |
|
746 |
* Search order: qualified name, in this class (inner), |
|
747 |
* in this package, in the class imports, in the package |
|
748 |
* imports. |
|
749 |
* Return the ClassDocImpl if found, null if not found. |
|
750 |
*/ |
|
751 |
//### The specified search order is not the normal rule the |
|
752 |
//### compiler would use. Leave as specified or change it? |
|
753 |
public ClassDoc findClass(String className) { |
|
754 |
ClassDoc searchResult = searchClass(className); |
|
755 |
if (searchResult == null) { |
|
756 |
ClassDocImpl enclosingClass = (ClassDocImpl)containingClass(); |
|
757 |
//Expand search space to include enclosing class. |
|
758 |
while (enclosingClass != null && enclosingClass.containingClass() != null) { |
|
759 |
enclosingClass = (ClassDocImpl)enclosingClass.containingClass(); |
|
760 |
} |
|
761 |
searchResult = enclosingClass == null ? |
|
762 |
null : enclosingClass.searchClass(className); |
|
763 |
} |
|
764 |
return searchResult; |
|
765 |
} |
|
766 |
||
767 |
private ClassDoc searchClass(String className) { |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
768 |
Names names = tsym.name.table.names; |
10 | 769 |
|
770 |
// search by qualified name first |
|
771 |
ClassDoc cd = env.lookupClass(className); |
|
772 |
if (cd != null) { |
|
773 |
return cd; |
|
774 |
} |
|
775 |
||
776 |
// search inner classes |
|
777 |
//### Add private entry point to avoid creating array? |
|
778 |
//### Replicate code in innerClasses here to avoid consing? |
|
10203
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
779 |
for (ClassDoc icd : innerClasses()) { |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
780 |
if (icd.name().equals(className) || |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
781 |
//### This is from original javadoc but it looks suspicious to me... |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
782 |
//### I believe it is attempting to compensate for the confused |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
783 |
//### convention of including the nested class qualifiers in the |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
784 |
//### 'name' of the inner class, rather than the true simple name. |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
785 |
icd.name().endsWith("." + className)) { |
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
786 |
return icd; |
10 | 787 |
} else { |
10203
cca843a7d258
7064544: (javadoc) miscellaneous fixes requested by netbeans
ksrini
parents:
8631
diff
changeset
|
788 |
ClassDoc innercd = ((ClassDocImpl) icd).searchClass(className); |
10 | 789 |
if (innercd != null) { |
790 |
return innercd; |
|
791 |
} |
|
792 |
} |
|
793 |
} |
|
794 |
||
795 |
// check in this package |
|
796 |
cd = containingPackage().findClass(className); |
|
797 |
if (cd != null) { |
|
798 |
return cd; |
|
799 |
} |
|
800 |
||
801 |
// make sure that this symbol has been completed |
|
802 |
if (tsym.completer != null) { |
|
803 |
tsym.complete(); |
|
804 |
} |
|
805 |
||
806 |
// search imports |
|
807 |
||
808 |
if (tsym.sourcefile != null) { |
|
809 |
||
810 |
//### This information is available only for source classes. |
|
811 |
||
812 |
Env<AttrContext> compenv = env.enter.getEnv(tsym); |
|
813 |
if (compenv == null) return null; |
|
814 |
||
815 |
Scope s = compenv.toplevel.namedImportScope; |
|
816 |
for (Scope.Entry e = s.lookup(names.fromString(className)); e.scope != null; e = e.next()) { |
|
817 |
if (e.sym.kind == Kinds.TYP) { |
|
818 |
ClassDoc c = env.getClassDoc((ClassSymbol)e.sym); |
|
819 |
return c; |
|
820 |
} |
|
821 |
} |
|
822 |
||
823 |
s = compenv.toplevel.starImportScope; |
|
824 |
for (Scope.Entry e = s.lookup(names.fromString(className)); e.scope != null; e = e.next()) { |
|
825 |
if (e.sym.kind == Kinds.TYP) { |
|
826 |
ClassDoc c = env.getClassDoc((ClassSymbol)e.sym); |
|
827 |
return c; |
|
828 |
} |
|
829 |
} |
|
830 |
} |
|
831 |
||
832 |
return null; // not found |
|
833 |
} |
|
834 |
||
835 |
||
836 |
private boolean hasParameterTypes(MethodSymbol method, String[] argTypes) { |
|
837 |
||
838 |
if (argTypes == null) { |
|
839 |
// wildcard |
|
840 |
return true; |
|
841 |
} |
|
842 |
||
843 |
int i = 0; |
|
844 |
List<Type> types = method.type.getParameterTypes(); |
|
845 |
||
846 |
if (argTypes.length != types.length()) { |
|
847 |
return false; |
|
848 |
} |
|
849 |
||
850 |
for (Type t : types) { |
|
851 |
String argType = argTypes[i++]; |
|
852 |
// For vararg method, "T..." matches type T[]. |
|
853 |
if (i == argTypes.length) { |
|
854 |
argType = argType.replace("...", "[]"); |
|
855 |
} |
|
856 |
if (!hasTypeName(env.types.erasure(t), argType)) { //###(gj) |
|
857 |
return false; |
|
858 |
} |
|
859 |
} |
|
860 |
return true; |
|
861 |
} |
|
862 |
// where |
|
863 |
private boolean hasTypeName(Type t, String name) { |
|
864 |
return |
|
865 |
name.equals(TypeMaker.getTypeName(t, true)) |
|
866 |
|| |
|
867 |
name.equals(TypeMaker.getTypeName(t, false)) |
|
868 |
|| |
|
869 |
(qualifiedName() + "." + name).equals(TypeMaker.getTypeName(t, true)); |
|
870 |
} |
|
871 |
||
872 |
||
873 |
||
874 |
/** |
|
875 |
* Find a method in this class scope. |
|
876 |
* Search order: this class, interfaces, superclasses, outerclasses. |
|
877 |
* Note that this is not necessarily what the compiler would do! |
|
878 |
* |
|
879 |
* @param methodName the unqualified name to search for. |
|
14259 | 880 |
* @param paramTypes the array of Strings for method parameter types. |
10 | 881 |
* @return the first MethodDocImpl which matches, null if not found. |
882 |
*/ |
|
883 |
public MethodDocImpl findMethod(String methodName, String[] paramTypes) { |
|
884 |
// Use hash table 'searched' to avoid searching same class twice. |
|
885 |
//### It is not clear how this could happen. |
|
22165
ec53c8946fc2
8030807: langtools should still build using jdk 7
vromero
parents:
22163
diff
changeset
|
886 |
return searchMethod(methodName, paramTypes, new HashSet<ClassDocImpl>()); |
10 | 887 |
} |
888 |
||
889 |
private MethodDocImpl searchMethod(String methodName, |
|
890 |
String[] paramTypes, Set<ClassDocImpl> searched) { |
|
891 |
//### Note that this search is not necessarily what the compiler would do! |
|
892 |
||
7071
8bcda461a06a
6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents:
5520
diff
changeset
|
893 |
Names names = tsym.name.table.names; |
8bcda461a06a
6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents:
5520
diff
changeset
|
894 |
// do not match constructors |
8bcda461a06a
6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents:
5520
diff
changeset
|
895 |
if (names.init.contentEquals(methodName)) { |
8bcda461a06a
6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents:
5520
diff
changeset
|
896 |
return null; |
8bcda461a06a
6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents:
5520
diff
changeset
|
897 |
} |
8bcda461a06a
6551367: javadoc throws ClassCastException when an @link tries to reference constructor.
sundar
parents:
5520
diff
changeset
|
898 |
|
10 | 899 |
ClassDocImpl cdi; |
900 |
MethodDocImpl mdi; |
|
901 |
||
902 |
if (searched.contains(this)) { |
|
903 |
return null; |
|
904 |
} |
|
905 |
searched.add(this); |
|
906 |
||
907 |
//DEBUG |
|
908 |
/*---------------------------------* |
|
909 |
System.out.print("searching " + this + " for " + methodName); |
|
910 |
if (paramTypes == null) { |
|
911 |
System.out.println("()"); |
|
912 |
} else { |
|
913 |
System.out.print("("); |
|
914 |
for (int k=0; k < paramTypes.length; k++) { |
|
915 |
System.out.print(paramTypes[k]); |
|
916 |
if ((k + 1) < paramTypes.length) { |
|
917 |
System.out.print(", "); |
|
918 |
} |
|
919 |
} |
|
920 |
System.out.println(")"); |
|
921 |
} |
|
922 |
*---------------------------------*/ |
|
923 |
||
924 |
// search current class |
|
925 |
Scope.Entry e = tsym.members().lookup(names.fromString(methodName)); |
|
926 |
||
927 |
//### Using modifier filter here isn't really correct, |
|
928 |
//### but emulates the old behavior. Instead, we should |
|
929 |
//### apply the normal rules of visibility and inheritance. |
|
930 |
||
931 |
if (paramTypes == null) { |
|
932 |
// If no parameters specified, we are allowed to return |
|
933 |
// any method with a matching name. In practice, the old |
|
934 |
// code returned the first method, which is now the last! |
|
935 |
// In order to provide textually identical results, we |
|
936 |
// attempt to emulate the old behavior. |
|
937 |
MethodSymbol lastFound = null; |
|
938 |
for (; e.scope != null; e = e.next()) { |
|
939 |
if (e.sym.kind == Kinds.MTH) { |
|
940 |
//### Should intern methodName as Name. |
|
941 |
if (e.sym.name.toString().equals(methodName)) { |
|
942 |
lastFound = (MethodSymbol)e.sym; |
|
943 |
} |
|
944 |
} |
|
945 |
} |
|
946 |
if (lastFound != null) { |
|
947 |
return env.getMethodDoc(lastFound); |
|
948 |
} |
|
949 |
} else { |
|
950 |
for (; e.scope != null; e = e.next()) { |
|
951 |
if (e.sym != null && |
|
952 |
e.sym.kind == Kinds.MTH) { |
|
953 |
//### Should intern methodName as Name. |
|
954 |
if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) { |
|
955 |
return env.getMethodDoc((MethodSymbol)e.sym); |
|
956 |
} |
|
957 |
} |
|
958 |
} |
|
959 |
} |
|
960 |
||
961 |
//### If we found a MethodDoc above, but which did not pass |
|
962 |
//### the modifier filter, we should return failure here! |
|
963 |
||
964 |
// search superclass |
|
965 |
cdi = (ClassDocImpl)superclass(); |
|
966 |
if (cdi != null) { |
|
967 |
mdi = cdi.searchMethod(methodName, paramTypes, searched); |
|
968 |
if (mdi != null) { |
|
969 |
return mdi; |
|
970 |
} |
|
971 |
} |
|
972 |
||
973 |
// search interfaces |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
21020
diff
changeset
|
974 |
for (ClassDoc intf : interfaces()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
21020
diff
changeset
|
975 |
cdi = (ClassDocImpl) intf; |
10 | 976 |
mdi = cdi.searchMethod(methodName, paramTypes, searched); |
977 |
if (mdi != null) { |
|
978 |
return mdi; |
|
979 |
} |
|
980 |
} |
|
981 |
||
982 |
// search enclosing class |
|
983 |
cdi = (ClassDocImpl)containingClass(); |
|
984 |
if (cdi != null) { |
|
985 |
mdi = cdi.searchMethod(methodName, paramTypes, searched); |
|
986 |
if (mdi != null) { |
|
987 |
return mdi; |
|
988 |
} |
|
989 |
} |
|
990 |
||
991 |
//###(gj) As a temporary measure until type variables are better |
|
992 |
//### handled, try again without the parameter types. |
|
993 |
//### This should most often find the right method, and occassionally |
|
994 |
//### find the wrong one. |
|
995 |
//if (paramTypes != null) { |
|
996 |
// return findMethod(methodName, null); |
|
997 |
//} |
|
998 |
||
999 |
return null; |
|
1000 |
} |
|
1001 |
||
1002 |
/** |
|
1003 |
* Find constructor in this class. |
|
1004 |
* |
|
1005 |
* @param constrName the unqualified name to search for. |
|
14259 | 1006 |
* @param paramTypes the array of Strings for constructor parameters. |
10 | 1007 |
* @return the first ConstructorDocImpl which matches, null if not found. |
1008 |
*/ |
|
1009 |
public ConstructorDoc findConstructor(String constrName, |
|
1010 |
String[] paramTypes) { |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
1011 |
Names names = tsym.name.table.names; |
10 | 1012 |
for (Scope.Entry e = tsym.members().lookup(names.fromString("<init>")); e.scope != null; e = e.next()) { |
1013 |
if (e.sym.kind == Kinds.MTH) { |
|
1014 |
if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) { |
|
1015 |
return env.getConstructorDoc((MethodSymbol)e.sym); |
|
1016 |
} |
|
1017 |
} |
|
1018 |
} |
|
1019 |
||
1020 |
//###(gj) As a temporary measure until type variables are better |
|
1021 |
//### handled, try again without the parameter types. |
|
1022 |
//### This will often find the right constructor, and occassionally |
|
1023 |
//### find the wrong one. |
|
1024 |
//if (paramTypes != null) { |
|
1025 |
// return findConstructor(constrName, null); |
|
1026 |
//} |
|
1027 |
||
1028 |
return null; |
|
1029 |
} |
|
1030 |
||
1031 |
/** |
|
1032 |
* Find a field in this class scope. |
|
1033 |
* Search order: this class, outerclasses, interfaces, |
|
1034 |
* superclasses. IMP: If see tag is defined in an inner class, |
|
1035 |
* which extends a super class and if outerclass and the super |
|
1036 |
* class have a visible field in common then Java compiler cribs |
|
1037 |
* about the ambiguity, but the following code will search in the |
|
1038 |
* above given search order. |
|
1039 |
* |
|
1040 |
* @param fieldName the unqualified name to search for. |
|
1041 |
* @return the first FieldDocImpl which matches, null if not found. |
|
1042 |
*/ |
|
1043 |
public FieldDoc findField(String fieldName) { |
|
22165
ec53c8946fc2
8030807: langtools should still build using jdk 7
vromero
parents:
22163
diff
changeset
|
1044 |
return searchField(fieldName, new HashSet<ClassDocImpl>()); |
10 | 1045 |
} |
1046 |
||
1047 |
private FieldDocImpl searchField(String fieldName, Set<ClassDocImpl> searched) { |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
1048 |
Names names = tsym.name.table.names; |
10 | 1049 |
if (searched.contains(this)) { |
1050 |
return null; |
|
1051 |
} |
|
1052 |
searched.add(this); |
|
1053 |
||
1054 |
for (Scope.Entry e = tsym.members().lookup(names.fromString(fieldName)); e.scope != null; e = e.next()) { |
|
1055 |
if (e.sym.kind == Kinds.VAR) { |
|
1056 |
//### Should intern fieldName as Name. |
|
1057 |
return env.getFieldDoc((VarSymbol)e.sym); |
|
1058 |
} |
|
1059 |
} |
|
1060 |
||
1061 |
//### If we found a FieldDoc above, but which did not pass |
|
1062 |
//### the modifier filter, we should return failure here! |
|
1063 |
||
1064 |
ClassDocImpl cdi = (ClassDocImpl)containingClass(); |
|
1065 |
if (cdi != null) { |
|
1066 |
FieldDocImpl fdi = cdi.searchField(fieldName, searched); |
|
1067 |
if (fdi != null) { |
|
1068 |
return fdi; |
|
1069 |
} |
|
1070 |
} |
|
1071 |
||
1072 |
// search superclass |
|
1073 |
cdi = (ClassDocImpl)superclass(); |
|
1074 |
if (cdi != null) { |
|
1075 |
FieldDocImpl fdi = cdi.searchField(fieldName, searched); |
|
1076 |
if (fdi != null) { |
|
1077 |
return fdi; |
|
1078 |
} |
|
1079 |
} |
|
1080 |
||
1081 |
// search interfaces |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
21020
diff
changeset
|
1082 |
for (ClassDoc intf : interfaces()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
21020
diff
changeset
|
1083 |
cdi = (ClassDocImpl) intf; |
10 | 1084 |
FieldDocImpl fdi = cdi.searchField(fieldName, searched); |
1085 |
if (fdi != null) { |
|
1086 |
return fdi; |
|
1087 |
} |
|
1088 |
} |
|
1089 |
||
1090 |
return null; |
|
1091 |
} |
|
1092 |
||
1093 |
/** |
|
1094 |
* Get the list of classes declared as imported. |
|
1095 |
* These are called "single-type-import declarations" in the JLS. |
|
1096 |
* This method is deprecated in the ClassDoc interface. |
|
1097 |
* |
|
1098 |
* @return an array of ClassDocImpl representing the imported classes. |
|
1099 |
* |
|
1100 |
* @deprecated Import declarations are implementation details that |
|
1101 |
* should not be exposed here. In addition, not all imported |
|
1102 |
* classes are imported through single-type-import declarations. |
|
1103 |
*/ |
|
1104 |
@Deprecated |
|
1105 |
public ClassDoc[] importedClasses() { |
|
1106 |
// information is not available for binary classfiles |
|
1107 |
if (tsym.sourcefile == null) return new ClassDoc[0]; |
|
1108 |
||
22163 | 1109 |
ListBuffer<ClassDocImpl> importedClasses = new ListBuffer<>(); |
10 | 1110 |
|
1111 |
Env<AttrContext> compenv = env.enter.getEnv(tsym); |
|
1112 |
if (compenv == null) return new ClassDocImpl[0]; |
|
1113 |
||
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
1114 |
Name asterisk = tsym.name.table.names.asterisk; |
10 | 1115 |
for (JCTree t : compenv.toplevel.defs) { |
10950 | 1116 |
if (t.hasTag(IMPORT)) { |
10 | 1117 |
JCTree imp = ((JCImport) t).qualid; |
1118 |
if ((TreeInfo.name(imp) != asterisk) && |
|
1119 |
(imp.type.tsym.kind & Kinds.TYP) != 0) { |
|
1120 |
importedClasses.append( |
|
1121 |
env.getClassDoc((ClassSymbol)imp.type.tsym)); |
|
1122 |
} |
|
1123 |
} |
|
1124 |
} |
|
1125 |
||
1126 |
return importedClasses.toArray(new ClassDocImpl[importedClasses.length()]); |
|
1127 |
} |
|
1128 |
||
1129 |
/** |
|
1130 |
* Get the list of packages declared as imported. |
|
1131 |
* These are called "type-import-on-demand declarations" in the JLS. |
|
1132 |
* This method is deprecated in the ClassDoc interface. |
|
1133 |
* |
|
1134 |
* @return an array of PackageDocImpl representing the imported packages. |
|
1135 |
* |
|
1136 |
* ###NOTE: the syntax supports importing all inner classes from a class as well. |
|
1137 |
* @deprecated Import declarations are implementation details that |
|
1138 |
* should not be exposed here. In addition, this method's |
|
1139 |
* return type does not allow for all type-import-on-demand |
|
1140 |
* declarations to be returned. |
|
1141 |
*/ |
|
1142 |
@Deprecated |
|
1143 |
public PackageDoc[] importedPackages() { |
|
1144 |
// information is not available for binary classfiles |
|
1145 |
if (tsym.sourcefile == null) return new PackageDoc[0]; |
|
1146 |
||
22163 | 1147 |
ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<>(); |
10 | 1148 |
|
1149 |
//### Add the implicit "import java.lang.*" to the result |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
1150 |
Names names = tsym.name.table.names; |
10 | 1151 |
importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang))); |
1152 |
||
1153 |
Env<AttrContext> compenv = env.enter.getEnv(tsym); |
|
1154 |
if (compenv == null) return new PackageDocImpl[0]; |
|
1155 |
||
1156 |
for (JCTree t : compenv.toplevel.defs) { |
|
10950 | 1157 |
if (t.hasTag(IMPORT)) { |
10 | 1158 |
JCTree imp = ((JCImport) t).qualid; |
1159 |
if (TreeInfo.name(imp) == names.asterisk) { |
|
1160 |
JCFieldAccess sel = (JCFieldAccess)imp; |
|
1161 |
Symbol s = sel.selected.type.tsym; |
|
1162 |
PackageDocImpl pdoc = env.getPackageDoc(s.packge()); |
|
1163 |
if (!importedPackages.contains(pdoc)) |
|
1164 |
importedPackages.append(pdoc); |
|
1165 |
} |
|
1166 |
} |
|
1167 |
} |
|
1168 |
||
1169 |
return importedPackages.toArray(new PackageDocImpl[importedPackages.length()]); |
|
1170 |
} |
|
1171 |
||
1172 |
/** |
|
1173 |
* Return the type's dimension information. |
|
1174 |
* Always return "", as this is not an array type. |
|
1175 |
*/ |
|
1176 |
public String dimension() { |
|
1177 |
return ""; |
|
1178 |
} |
|
1179 |
||
1180 |
/** |
|
1181 |
* Return this type as a class, which it already is. |
|
1182 |
*/ |
|
1183 |
public ClassDoc asClassDoc() { |
|
1184 |
return this; |
|
1185 |
} |
|
1186 |
||
1187 |
/** |
|
1188 |
* Return null (unless overridden), as this is not an annotation type. |
|
1189 |
*/ |
|
1190 |
public AnnotationTypeDoc asAnnotationTypeDoc() { |
|
1191 |
return null; |
|
1192 |
} |
|
1193 |
||
1194 |
/** |
|
1195 |
* Return null, as this is not a class instantiation. |
|
1196 |
*/ |
|
1197 |
public ParameterizedType asParameterizedType() { |
|
1198 |
return null; |
|
1199 |
} |
|
1200 |
||
1201 |
/** |
|
1202 |
* Return null, as this is not a type variable. |
|
1203 |
*/ |
|
1204 |
public TypeVariable asTypeVariable() { |
|
1205 |
return null; |
|
1206 |
} |
|
1207 |
||
1208 |
/** |
|
1209 |
* Return null, as this is not a wildcard type. |
|
1210 |
*/ |
|
1211 |
public WildcardType asWildcardType() { |
|
1212 |
return null; |
|
1213 |
} |
|
1214 |
||
1215 |
/** |
|
15385 | 1216 |
* Returns null, as this is not an annotated type. |
1217 |
*/ |
|
1218 |
public AnnotatedType asAnnotatedType() { |
|
1219 |
return null; |
|
1220 |
} |
|
1221 |
||
1222 |
/** |
|
10 | 1223 |
* Return false, as this is not a primitive type. |
1224 |
*/ |
|
1225 |
public boolean isPrimitive() { |
|
1226 |
return false; |
|
1227 |
} |
|
1228 |
||
1229 |
//--- Serialization --- |
|
1230 |
||
1231 |
//### These methods ignore modifier filter. |
|
1232 |
||
1233 |
/** |
|
1234 |
* Return true if this class implements <code>java.io.Serializable</code>. |
|
1235 |
* |
|
1236 |
* Since <code>java.io.Externalizable</code> extends |
|
1237 |
* <code>java.io.Serializable</code>, |
|
1238 |
* Externalizable objects are also Serializable. |
|
1239 |
*/ |
|
1240 |
public boolean isSerializable() { |
|
1241 |
try { |
|
1242 |
return env.types.isSubtype(type, env.syms.serializableType); |
|
1243 |
} catch (CompletionFailure ex) { |
|
1244 |
// quietly ignore completion failures |
|
1245 |
return false; |
|
1246 |
} |
|
1247 |
} |
|
1248 |
||
1249 |
/** |
|
1250 |
* Return true if this class implements |
|
1251 |
* <code>java.io.Externalizable</code>. |
|
1252 |
*/ |
|
1253 |
public boolean isExternalizable() { |
|
1254 |
try { |
|
1255 |
return env.types.isSubtype(type, env.externalizableSym.type); |
|
1256 |
} catch (CompletionFailure ex) { |
|
1257 |
// quietly ignore completion failures |
|
1258 |
return false; |
|
1259 |
} |
|
1260 |
} |
|
1261 |
||
1262 |
/** |
|
1263 |
* Return the serialization methods for this class. |
|
1264 |
* |
|
1265 |
* @return an array of <code>MethodDocImpl</code> that represents |
|
1266 |
* the serialization methods for this class. |
|
1267 |
*/ |
|
1268 |
public MethodDoc[] serializationMethods() { |
|
1269 |
if (serializedForm == null) { |
|
1270 |
serializedForm = new SerializedForm(env, tsym, this); |
|
1271 |
} |
|
1272 |
//### Clone this? |
|
1273 |
return serializedForm.methods(); |
|
1274 |
} |
|
1275 |
||
1276 |
/** |
|
1277 |
* Return the Serializable fields of class.<p> |
|
1278 |
* |
|
1279 |
* Return either a list of default fields documented by |
|
1280 |
* <code>serial</code> tag<br> |
|
1281 |
* or return a single <code>FieldDoc</code> for |
|
1282 |
* <code>serialPersistentField</code> member. |
|
1283 |
* There should be a <code>serialField</code> tag for |
|
1284 |
* each Serializable field defined by an <code>ObjectStreamField</code> |
|
1285 |
* array component of <code>serialPersistentField</code>. |
|
1286 |
* |
|
1287 |
* @returns an array of <code>FieldDoc</code> for the Serializable fields |
|
1288 |
* of this class. |
|
1289 |
* |
|
1290 |
* @see #definesSerializableFields() |
|
1291 |
* @see SerialFieldTagImpl |
|
1292 |
*/ |
|
1293 |
public FieldDoc[] serializableFields() { |
|
1294 |
if (serializedForm == null) { |
|
1295 |
serializedForm = new SerializedForm(env, tsym, this); |
|
1296 |
} |
|
1297 |
//### Clone this? |
|
1298 |
return serializedForm.fields(); |
|
1299 |
} |
|
1300 |
||
1301 |
/** |
|
1302 |
* Return true if Serializable fields are explicitly defined with |
|
1303 |
* the special class member <code>serialPersistentFields</code>. |
|
1304 |
* |
|
1305 |
* @see #serializableFields() |
|
1306 |
* @see SerialFieldTagImpl |
|
1307 |
*/ |
|
1308 |
public boolean definesSerializableFields() { |
|
1309 |
if (!isSerializable() || isExternalizable()) { |
|
1310 |
return false; |
|
1311 |
} else { |
|
1312 |
if (serializedForm == null) { |
|
1313 |
serializedForm = new SerializedForm(env, tsym, this); |
|
1314 |
} |
|
1315 |
//### Clone this? |
|
1316 |
return serializedForm.definesSerializableFields(); |
|
1317 |
} |
|
1318 |
} |
|
1319 |
||
1320 |
/** |
|
1321 |
* Determine if a class is a RuntimeException. |
|
1322 |
* <p> |
|
1323 |
* Used only by ThrowsTagImpl. |
|
1324 |
*/ |
|
1325 |
boolean isRuntimeException() { |
|
1326 |
return tsym.isSubClass(env.syms.runtimeExceptionType.tsym, env.types); |
|
1327 |
} |
|
1328 |
||
1329 |
/** |
|
1330 |
* Return the source position of the entity, or null if |
|
1331 |
* no position is available. |
|
1332 |
*/ |
|
8631
664f84942e74
6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents:
7681
diff
changeset
|
1333 |
@Override |
10 | 1334 |
public SourcePosition position() { |
1335 |
if (tsym.sourcefile == null) return null; |
|
1869
0e193a8f3520
6794582: javadoc should read files using a FileManager
jjg
parents:
1264
diff
changeset
|
1336 |
return SourcePositionImpl.make(tsym.sourcefile, |
10 | 1337 |
(tree==null) ? Position.NOPOS : tree.pos, |
1338 |
lineMap); |
|
1339 |
} |
|
1340 |
} |