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