author | jjg |
Tue, 11 Dec 2012 15:05:55 -0800 | |
changeset 14802 | 969e90f68ac5 |
parent 14441 | 6c066a762e05 |
child 15354 | 52a04c670c05 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
13077 | 2 |
* Copyright (c) 2003, 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.javadoc; |
|
27 |
||
14802 | 28 |
import com.sun.source.util.TreePath; |
10 | 29 |
import com.sun.tools.javac.code.Flags; |
30 |
import com.sun.tools.javac.code.Kinds; |
|
31 |
import com.sun.tools.javac.code.Symbol.*; |
|
32 |
import com.sun.tools.javac.comp.MemberEnter; |
|
33 |
import com.sun.tools.javac.tree.JCTree.*; |
|
13077 | 34 |
import com.sun.tools.javac.util.Context; |
10 | 35 |
|
36 |
/** |
|
37 |
* Javadoc's own memberEnter phase does a few things above and beyond that |
|
38 |
* done by javac. |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
13077
diff
changeset
|
39 |
* |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
13077
diff
changeset
|
40 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
13077
diff
changeset
|
41 |
* 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:
13077
diff
changeset
|
42 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
13077
diff
changeset
|
43 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
13077
diff
changeset
|
44 |
* |
10 | 45 |
* @author Neal Gafter |
46 |
*/ |
|
10189
57268b86d4da
7059905: (javadoc) promote method visibility for netbeans usage
ksrini
parents:
8614
diff
changeset
|
47 |
public class JavadocMemberEnter extends MemberEnter { |
10 | 48 |
public static JavadocMemberEnter instance0(Context context) { |
49 |
MemberEnter instance = context.get(memberEnterKey); |
|
50 |
if (instance == null) |
|
51 |
instance = new JavadocMemberEnter(context); |
|
52 |
return (JavadocMemberEnter)instance; |
|
53 |
} |
|
54 |
||
8614 | 55 |
public static void preRegister(Context context) { |
10 | 56 |
context.put(memberEnterKey, new Context.Factory<MemberEnter>() { |
8614 | 57 |
public MemberEnter make(Context c) { |
58 |
return new JavadocMemberEnter(c); |
|
10 | 59 |
} |
60 |
}); |
|
61 |
} |
|
62 |
||
63 |
final DocEnv docenv; |
|
64 |
||
65 |
protected JavadocMemberEnter(Context context) { |
|
66 |
super(context); |
|
67 |
docenv = DocEnv.instance(context); |
|
68 |
} |
|
69 |
||
13077 | 70 |
@Override |
10 | 71 |
public void visitMethodDef(JCMethodDecl tree) { |
72 |
super.visitMethodDef(tree); |
|
868 | 73 |
MethodSymbol meth = tree.sym; |
10 | 74 |
if (meth == null || meth.kind != Kinds.MTH) return; |
14802 | 75 |
TreePath treePath = docenv.getTreePath(env.toplevel, tree); |
10 | 76 |
if (meth.isConstructor()) |
14802 | 77 |
docenv.makeConstructorDoc(meth, treePath); |
10 | 78 |
else if (isAnnotationTypeElement(meth)) |
14802 | 79 |
docenv.makeAnnotationTypeElementDoc(meth, treePath); |
10 | 80 |
else |
14802 | 81 |
docenv.makeMethodDoc(meth, treePath); |
14441
6c066a762e05
8002146: javadoc doesn't release resources in a timely manner
jjg
parents:
14260
diff
changeset
|
82 |
|
6c066a762e05
8002146: javadoc doesn't release resources in a timely manner
jjg
parents:
14260
diff
changeset
|
83 |
// release resources |
6c066a762e05
8002146: javadoc doesn't release resources in a timely manner
jjg
parents:
14260
diff
changeset
|
84 |
tree.body = null; |
10 | 85 |
} |
86 |
||
13077 | 87 |
@Override |
10 | 88 |
public void visitVarDef(JCVariableDecl tree) { |
89 |
super.visitVarDef(tree); |
|
90 |
if (tree.sym != null && |
|
91 |
tree.sym.kind == Kinds.VAR && |
|
92 |
!isParameter(tree.sym)) { |
|
14802 | 93 |
docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, tree)); |
10 | 94 |
} |
95 |
} |
|
96 |
||
97 |
private static boolean isAnnotationTypeElement(MethodSymbol meth) { |
|
98 |
return ClassDocImpl.isAnnotationType(meth.enclClass()); |
|
99 |
} |
|
100 |
||
101 |
private static boolean isParameter(VarSymbol var) { |
|
102 |
return (var.flags() & Flags.PARAMETER) != 0; |
|
103 |
} |
|
104 |
} |