author | jjg |
Sun, 18 May 2014 19:59:10 -0700 | |
changeset 24604 | 7f68545b5128 |
parent 17578 | 46ac954e4a84 |
child 25443 | 9187d77f2c64 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
17578 | 2 |
* Copyright (c) 2003, 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 |
||
28 |
import com.sun.javadoc.*; |
|
29 |
||
14802 | 30 |
import com.sun.source.util.TreePath; |
10 | 31 |
import com.sun.tools.javac.code.Kinds; |
32 |
import com.sun.tools.javac.code.Scope; |
|
33 |
import com.sun.tools.javac.code.Symbol.*; |
|
34 |
import com.sun.tools.javac.util.List; |
|
35 |
||
36 |
/** |
|
37 |
* Represents an annotation type. |
|
38 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
39 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
40 |
* 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:
14258
diff
changeset
|
41 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
42 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
43 |
* |
10 | 44 |
* @author Scott Seligman |
45 |
* @since 1.5 |
|
46 |
*/ |
|
47 |
||
48 |
public class AnnotationTypeDocImpl |
|
49 |
extends ClassDocImpl implements AnnotationTypeDoc { |
|
50 |
||
10189
57268b86d4da
7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents:
5520
diff
changeset
|
51 |
public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) { |
14802 | 52 |
this(env, sym, null); |
10 | 53 |
} |
54 |
||
14802 | 55 |
public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) { |
56 |
super(env, sym, treePath); |
|
10 | 57 |
} |
58 |
||
59 |
/** |
|
60 |
* Returns true, as this is an annotation type. |
|
61 |
* (For legacy doclets, return false.) |
|
62 |
*/ |
|
63 |
public boolean isAnnotationType() { |
|
64 |
return !isInterface(); |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* Returns false. Though technically an interface, an annotation |
|
69 |
* type is not considered an interface for this purpose. |
|
70 |
* (For legacy doclets, returns true.) |
|
71 |
*/ |
|
72 |
public boolean isInterface() { |
|
73 |
return env.legacyDoclet; |
|
74 |
} |
|
75 |
||
76 |
/** |
|
77 |
* Returns an empty array, as all methods are annotation type elements. |
|
78 |
* (For legacy doclets, returns the elements.) |
|
79 |
* @see #elements() |
|
80 |
*/ |
|
81 |
public MethodDoc[] methods(boolean filter) { |
|
82 |
return env.legacyDoclet |
|
83 |
? (MethodDoc[])elements() |
|
84 |
: new MethodDoc[0]; |
|
85 |
} |
|
86 |
||
87 |
/** |
|
88 |
* Returns the elements of this annotation type. |
|
89 |
* Returns an empty array if there are none. |
|
90 |
* Elements are always public, so no need to filter them. |
|
91 |
*/ |
|
92 |
public AnnotationTypeElementDoc[] elements() { |
|
93 |
List<AnnotationTypeElementDoc> elements = List.nil(); |
|
94 |
for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { |
|
95 |
if (e.sym != null && e.sym.kind == Kinds.MTH) { |
|
96 |
MethodSymbol s = (MethodSymbol)e.sym; |
|
97 |
elements = elements.prepend(env.getAnnotationTypeElementDoc(s)); |
|
98 |
} |
|
99 |
} |
|
100 |
return |
|
101 |
elements.toArray(new AnnotationTypeElementDoc[elements.length()]); |
|
102 |
} |
|
103 |
} |