author | jjg |
Thu, 15 Nov 2012 09:18:36 -0800 | |
changeset 14542 | 7062120649c2 |
parent 14263 | 473b1eaede64 |
child 15385 | ee1eebe7e210 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
14259 | 2 |
* Copyright (c) 1997, 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.doclets.formats.html; |
|
27 |
||
28 |
import com.sun.javadoc.*; |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
29 |
import com.sun.tools.doclets.formats.html.markup.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
30 |
import com.sun.tools.doclets.internal.toolkit.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
10 | 32 |
|
33 |
/** |
|
34 |
* Print method and constructor info. |
|
35 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
36 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
37 |
* 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
|
38 |
* 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
|
39 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
40 |
* |
10 | 41 |
* @author Robert Field |
42 |
* @author Atul M Dambalkar |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
43 |
* @author Bhavesh Patel (Modified) |
10 | 44 |
*/ |
45 |
public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter { |
|
46 |
||
47 |
public AbstractExecutableMemberWriter(SubWriterHolderWriter writer, |
|
14542 | 48 |
ClassDoc classdoc) { |
10 | 49 |
super(writer, classdoc); |
50 |
} |
|
51 |
||
52 |
public AbstractExecutableMemberWriter(SubWriterHolderWriter writer) { |
|
53 |
super(writer); |
|
54 |
} |
|
55 |
||
56 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
57 |
* Add the type parameters for the executable member. |
10 | 58 |
* |
59 |
* @param member the member to write type parameters for. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
60 |
* @param htmltree the content tree to which the parameters will be added. |
10 | 61 |
* @return the display length required to write this information. |
62 |
*/ |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
63 |
protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) { |
14542 | 64 |
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, |
10 | 65 |
LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false); |
66 |
String typeParameters = writer.getTypeParameterLinks(linkInfo); |
|
67 |
if (linkInfo.displayLength > 0) { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
68 |
Content linkContent = new RawHtml(typeParameters); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
69 |
htmltree.addContent(linkContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
70 |
htmltree.addContent(writer.getSpace()); |
10 | 71 |
writer.displayLength += linkInfo.displayLength + 1; |
72 |
} |
|
73 |
return linkInfo.displayLength; |
|
74 |
} |
|
75 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
76 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
77 |
* {@inheritDoc} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
78 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
79 |
protected Content getDeprecatedLink(ProgramElementDoc member) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
80 |
ExecutableMemberDoc emd = (ExecutableMemberDoc)member; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
81 |
return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
82 |
emd.qualifiedName() + emd.flatSignature()); |
10 | 83 |
} |
84 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
85 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
86 |
* Add the summary link for the member. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
87 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
88 |
* @param context the id of the context where the link will be printed |
14259 | 89 |
* @param cd the classDoc that we should link to |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
90 |
* @param member the member being linked to |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
91 |
* @param tdSummary the content tree to which the link will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
92 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
93 |
protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
94 |
Content tdSummary) { |
10 | 95 |
ExecutableMemberDoc emd = (ExecutableMemberDoc)member; |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
96 |
String name = emd.name(); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
97 |
Content strong = HtmlTree.STRONG(new RawHtml( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
98 |
writer.getDocLink(context, cd, (MemberDoc) emd, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
99 |
name, false))); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
100 |
Content code = HtmlTree.CODE(strong); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
101 |
writer.displayLength = name.length(); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
102 |
addParameters(emd, false, code); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
103 |
tdSummary.addContent(code); |
10 | 104 |
} |
105 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
107 |
* Add the inherited summary link for the member. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
108 |
* |
14259 | 109 |
* @param cd the classDoc that we should link to |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
110 |
* @param member the member being linked to |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
111 |
* @param linksTree the content tree to which the link will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
112 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
113 |
protected void addInheritedSummaryLink(ClassDoc cd, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
114 |
ProgramElementDoc member, Content linksTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
115 |
linksTree.addContent(new RawHtml( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
116 |
writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
117 |
member.name(), false))); |
10 | 118 |
} |
119 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
121 |
* Add the parameter for the executable member. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
122 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
123 |
* @param member the member to write parameter for. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
124 |
* @param param the parameter that needs to be written. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
125 |
* @param isVarArg true if this is a link to var arg. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
126 |
* @param tree the content tree to which the parameter information will be added. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
127 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
128 |
protected void addParam(ExecutableMemberDoc member, Parameter param, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
129 |
boolean isVarArg, Content tree) { |
10 | 130 |
if (param.type() != null) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
131 |
Content link = new RawHtml(writer.getLink(new LinkInfoImpl( |
14542 | 132 |
configuration, LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, |
133 |
param.type(), isVarArg))); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
134 |
tree.addContent(link); |
10 | 135 |
} |
136 |
if(param.name().length() > 0) { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
tree.addContent(writer.getSpace()); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
138 |
tree.addContent(param.name()); |
10 | 139 |
} |
140 |
} |
|
141 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
142 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
143 |
* Add all the parameters for the executable member. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
144 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
145 |
* @param member the member to write parameters for. |
14259 | 146 |
* @param htmltree the content tree to which the parameters information will be added. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
148 |
protected void addParameters(ExecutableMemberDoc member, Content htmltree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
149 |
addParameters(member, true, htmltree); |
10 | 150 |
} |
151 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
152 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
153 |
* Add all the parameters for the executable member. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
154 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
155 |
* @param member the member to write parameters for. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
156 |
* @param includeAnnotations true if annotation information needs to be added. |
14259 | 157 |
* @param htmltree the content tree to which the parameters information will be added. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
158 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
159 |
protected void addParameters(ExecutableMemberDoc member, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
160 |
boolean includeAnnotations, Content htmltree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
161 |
htmltree.addContent("("); |
10 | 162 |
Parameter[] params = member.parameters(); |
163 |
String indent = makeSpace(writer.displayLength); |
|
14542 | 164 |
if (configuration.linksource) { |
10 | 165 |
//add spaces to offset indentation changes caused by link. |
166 |
indent+= makeSpace(member.name().length()); |
|
167 |
} |
|
168 |
int paramstart; |
|
169 |
for (paramstart = 0; paramstart < params.length; paramstart++) { |
|
170 |
Parameter param = params[paramstart]; |
|
171 |
if (!param.name().startsWith("this$")) { |
|
172 |
if (includeAnnotations) { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
173 |
boolean foundAnnotations = |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
174 |
writer.addAnnotationInfo(indent.length(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
175 |
member, param, htmltree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
176 |
if (foundAnnotations) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
177 |
htmltree.addContent(DocletConstants.NL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
178 |
htmltree.addContent(indent); |
10 | 179 |
} |
180 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
181 |
addParam(member, param, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
182 |
(paramstart == params.length - 1) && member.isVarArgs(), htmltree); |
10 | 183 |
break; |
184 |
} |
|
185 |
} |
|
186 |
||
187 |
for (int i = paramstart + 1; i < params.length; i++) { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
188 |
htmltree.addContent(","); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
189 |
htmltree.addContent(DocletConstants.NL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
190 |
htmltree.addContent(indent); |
10 | 191 |
if (includeAnnotations) { |
192 |
boolean foundAnnotations = |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
193 |
writer.addAnnotationInfo(indent.length(), member, params[i], |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
194 |
htmltree); |
10 | 195 |
if (foundAnnotations) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
196 |
htmltree.addContent(DocletConstants.NL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
197 |
htmltree.addContent(indent); |
10 | 198 |
} |
199 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
200 |
addParam(member, params[i], (i == params.length - 1) && member.isVarArgs(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
201 |
htmltree); |
10 | 202 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
203 |
htmltree.addContent(")"); |
10 | 204 |
} |
205 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
206 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
207 |
* Add exceptions for the executable member. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
208 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
209 |
* @param member the member to write exceptions for. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
210 |
* @param htmltree the content tree to which the exceptions information will be added. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
211 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
212 |
protected void addExceptions(ExecutableMemberDoc member, Content htmltree) { |
10 | 213 |
Type[] exceptions = member.thrownExceptionTypes(); |
214 |
if(exceptions.length > 0) { |
|
14542 | 215 |
LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
216 |
LinkInfoImpl.CONTEXT_MEMBER, member, false); |
10 | 217 |
int retlen = getReturnTypeLength(member); |
218 |
writer.getTypeParameterLinks(memberTypeParam); |
|
219 |
retlen += memberTypeParam.displayLength == 0 ? |
|
220 |
0 : memberTypeParam.displayLength + 1; |
|
221 |
String indent = makeSpace(modifierString(member).length() + |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
222 |
member.name().length() + retlen - 4); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
223 |
htmltree.addContent(DocletConstants.NL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
224 |
htmltree.addContent(indent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
225 |
htmltree.addContent("throws "); |
10 | 226 |
indent += " "; |
14542 | 227 |
Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
228 |
LinkInfoImpl.CONTEXT_MEMBER, exceptions[0]))); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
229 |
htmltree.addContent(link); |
10 | 230 |
for(int i = 1; i < exceptions.length; i++) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
231 |
htmltree.addContent(","); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
232 |
htmltree.addContent(DocletConstants.NL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
233 |
htmltree.addContent(indent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
234 |
Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl( |
14542 | 235 |
configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[i]))); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
236 |
htmltree.addContent(exceptionLink); |
10 | 237 |
} |
238 |
} |
|
239 |
} |
|
240 |
||
241 |
protected int getReturnTypeLength(ExecutableMemberDoc member) { |
|
242 |
if (member instanceof MethodDoc) { |
|
243 |
MethodDoc method = (MethodDoc)member; |
|
244 |
Type rettype = method.returnType(); |
|
245 |
if (rettype.isPrimitive()) { |
|
246 |
return rettype.typeName().length() + |
|
247 |
rettype.dimension().length(); |
|
248 |
} else { |
|
14542 | 249 |
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, |
10 | 250 |
LinkInfoImpl.CONTEXT_MEMBER, rettype); |
251 |
writer.getLink(linkInfo); |
|
252 |
return linkInfo.displayLength; |
|
253 |
} |
|
254 |
} else { // it's a constructordoc |
|
255 |
return -1; |
|
256 |
} |
|
257 |
} |
|
258 |
||
259 |
protected ClassDoc implementsMethodInIntfac(MethodDoc method, |
|
260 |
ClassDoc[] intfacs) { |
|
261 |
for (int i = 0; i < intfacs.length; i++) { |
|
262 |
MethodDoc[] methods = intfacs[i].methods(); |
|
263 |
if (methods.length > 0) { |
|
264 |
for (int j = 0; j < methods.length; j++) { |
|
265 |
if (methods[j].name().equals(method.name()) && |
|
266 |
methods[j].signature().equals(method.signature())) { |
|
267 |
return intfacs[i]; |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
return null; |
|
273 |
} |
|
274 |
||
275 |
/** |
|
276 |
* For backward compatibility, include an anchor using the erasures of the |
|
277 |
* parameters. NOTE: We won't need this method anymore after we fix |
|
278 |
* see tags so that they use the type instead of the erasure. |
|
279 |
* |
|
280 |
* @param emd the ExecutableMemberDoc to anchor to. |
|
281 |
* @return the 1.4.x style anchor for the ExecutableMemberDoc. |
|
282 |
*/ |
|
283 |
protected String getErasureAnchor(ExecutableMemberDoc emd) { |
|
14263 | 284 |
StringBuilder buf = new StringBuilder(emd.name() + "("); |
10 | 285 |
Parameter[] params = emd.parameters(); |
286 |
boolean foundTypeVariable = false; |
|
287 |
for (int i = 0; i < params.length; i++) { |
|
288 |
if (i > 0) { |
|
289 |
buf.append(","); |
|
290 |
} |
|
291 |
Type t = params[i].type(); |
|
292 |
foundTypeVariable = foundTypeVariable || t.asTypeVariable() != null; |
|
293 |
buf.append(t.isPrimitive() ? |
|
294 |
t.typeName() : t.asClassDoc().qualifiedName()); |
|
295 |
buf.append(t.dimension()); |
|
296 |
} |
|
297 |
buf.append(")"); |
|
298 |
return foundTypeVariable ? buf.toString() : null; |
|
299 |
} |
|
300 |
} |