author | bpatel |
Thu, 09 Jun 2016 23:24:05 -0700 | |
changeset 38911 | 48a00b5ee366 |
parent 35426 | 374342e56a56 |
child 44180 | 207e05e0d9ad |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
2 |
* Copyright (c) 2003, 2016, 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 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
25 |
package jdk.javadoc.internal.doclets.toolkit.taglets; |
10 | 26 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
27 |
import java.util.List; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
28 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
29 |
import javax.lang.model.element.Element; |
10 | 30 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
31 |
import com.sun.source.doctree.DocTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
32 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.toolkit.util.Utils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
35 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
36 |
import static jdk.javadoc.doclet.taglet.Taglet.Location.*; |
10 | 37 |
|
38 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
39 |
* A taglet wrapper, allows the public taglet {@link jdk.javadoc.doclet.taglet.Taglet} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
40 |
* wrapped into an internal Taglet representation. |
10 | 41 |
* |
14260 | 42 |
* <p><b>This is NOT part of any supported API. |
43 |
* If you write code that depends on this, you do so at your own risk. |
|
44 |
* This code and its internal interfaces are subject to change or |
|
45 |
* deletion without notice.</b> |
|
10 | 46 |
* |
47 |
* @author Jamie Ho |
|
48 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
49 |
public class UserTaglet implements Taglet { |
10 | 50 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
51 |
final private jdk.javadoc.doclet.taglet.Taglet userTaglet; |
10 | 52 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
53 |
public UserTaglet(jdk.javadoc.doclet.taglet.Taglet t) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
54 |
userTaglet = t; |
10 | 55 |
} |
56 |
||
57 |
/** |
|
58 |
* {@inheritDoc} |
|
59 |
*/ |
|
60 |
public boolean inField() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
61 |
return userTaglet.isInlineTag() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
62 |
|| userTaglet.getAllowedLocations().contains(FIELD); |
10 | 63 |
} |
64 |
||
65 |
/** |
|
66 |
* {@inheritDoc} |
|
67 |
*/ |
|
68 |
public boolean inConstructor() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
69 |
return userTaglet.isInlineTag() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
70 |
|| userTaglet.getAllowedLocations().contains(CONSTRUCTOR); |
10 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
* {@inheritDoc} |
|
75 |
*/ |
|
76 |
public boolean inMethod() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
77 |
return userTaglet.isInlineTag() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
78 |
|| userTaglet.getAllowedLocations().contains(METHOD); |
10 | 79 |
} |
80 |
||
81 |
/** |
|
82 |
* {@inheritDoc} |
|
83 |
*/ |
|
84 |
public boolean inOverview() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
85 |
return userTaglet.isInlineTag() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
86 |
|| userTaglet.getAllowedLocations().contains(OVERVIEW); |
10 | 87 |
} |
88 |
||
89 |
/** |
|
90 |
* {@inheritDoc} |
|
91 |
*/ |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
92 |
public boolean inModule() { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
93 |
return userTaglet.isInlineTag() |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
94 |
|| userTaglet.getAllowedLocations().contains(MODULE); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
95 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
96 |
|
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
97 |
/** |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
98 |
* {@inheritDoc} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
99 |
*/ |
10 | 100 |
public boolean inPackage() { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
101 |
return userTaglet.isInlineTag() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
102 |
|| userTaglet.getAllowedLocations().contains(PACKAGE); |
10 | 103 |
} |
104 |
||
105 |
/** |
|
106 |
* {@inheritDoc} |
|
107 |
*/ |
|
108 |
public boolean inType() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
109 |
return userTaglet.isInlineTag() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
110 |
|| userTaglet.getAllowedLocations().contains(TYPE); |
10 | 111 |
} |
112 |
||
113 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
114 |
* Return true if this <code>Taglet</code> is an inline tag. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
115 |
* |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
116 |
* @return true if this <code>Taglet</code> is an inline tag and false otherwise. |
10 | 117 |
*/ |
118 |
public boolean isInlineTag() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
119 |
return userTaglet.isInlineTag(); |
10 | 120 |
} |
121 |
||
122 |
/** |
|
123 |
* {@inheritDoc} |
|
124 |
*/ |
|
125 |
public String getName() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
126 |
return userTaglet.getName(); |
10 | 127 |
} |
128 |
||
129 |
/** |
|
130 |
* {@inheritDoc} |
|
131 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
132 |
public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer){ |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
14260
diff
changeset
|
133 |
Content output = writer.getOutputInstance(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
134 |
output.addContent(new RawHtml(userTaglet.toString(tag))); |
10 | 135 |
return output; |
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* {@inheritDoc} |
|
140 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
141 |
public Content getTagletOutput(Element holder, TagletWriter writer) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
14260
diff
changeset
|
142 |
Content output = writer.getOutputInstance(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
143 |
Utils utils = writer.configuration().utils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
144 |
List<? extends DocTree> tags = utils.getBlockTags(holder, getName()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
145 |
if (!tags.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
146 |
String tagString = userTaglet.toString(tags); |
19910 | 147 |
if (tagString != null) { |
148 |
output.addContent(new RawHtml(tagString)); |
|
149 |
} |
|
150 |
} |
|
10 | 151 |
return output; |
152 |
} |
|
153 |
} |