81 } |
82 } |
82 |
83 |
83 /** |
84 /** |
84 * Add links for exceptions that are declared but not documented. |
85 * Add links for exceptions that are declared but not documented. |
85 */ |
86 */ |
86 private TagletOutput linkToUndocumentedDeclaredExceptions( |
87 private Content linkToUndocumentedDeclaredExceptions( |
87 Type[] declaredExceptionTypes, Set<String> alreadyDocumented, |
88 Type[] declaredExceptionTypes, Set<String> alreadyDocumented, |
88 TagletWriter writer) { |
89 TagletWriter writer) { |
89 TagletOutput result = writer.getOutputInstance(); |
90 Content result = writer.getOutputInstance(); |
90 //Add links to the exceptions declared but not documented. |
91 //Add links to the exceptions declared but not documented. |
91 for (int i = 0; i < declaredExceptionTypes.length; i++) { |
92 for (int i = 0; i < declaredExceptionTypes.length; i++) { |
92 if (declaredExceptionTypes[i].asClassDoc() != null && |
93 if (declaredExceptionTypes[i].asClassDoc() != null && |
93 ! alreadyDocumented.contains( |
94 ! alreadyDocumented.contains( |
94 declaredExceptionTypes[i].asClassDoc().name()) && |
95 declaredExceptionTypes[i].asClassDoc().name()) && |
95 ! alreadyDocumented.contains( |
96 ! alreadyDocumented.contains( |
96 declaredExceptionTypes[i].asClassDoc().qualifiedName())) { |
97 declaredExceptionTypes[i].asClassDoc().qualifiedName())) { |
97 if (alreadyDocumented.size() == 0) { |
98 if (alreadyDocumented.size() == 0) { |
98 result.appendOutput(writer.getThrowsHeader()); |
99 result.addContent(writer.getThrowsHeader()); |
99 } |
100 } |
100 result.appendOutput(writer.throwsTagOutput(declaredExceptionTypes[i])); |
101 result.addContent(writer.throwsTagOutput(declaredExceptionTypes[i])); |
101 alreadyDocumented.add(declaredExceptionTypes[i].asClassDoc().name()); |
102 alreadyDocumented.add(declaredExceptionTypes[i].asClassDoc().name()); |
102 } |
103 } |
103 } |
104 } |
104 return result; |
105 return result; |
105 } |
106 } |
106 |
107 |
107 /** |
108 /** |
108 * Inherit throws documentation for exceptions that were declared but not |
109 * Inherit throws documentation for exceptions that were declared but not |
109 * documented. |
110 * documented. |
110 */ |
111 */ |
111 private TagletOutput inheritThrowsDocumentation(Doc holder, |
112 private Content inheritThrowsDocumentation(Doc holder, |
112 Type[] declaredExceptionTypes, Set<String> alreadyDocumented, |
113 Type[] declaredExceptionTypes, Set<String> alreadyDocumented, |
113 TagletWriter writer) { |
114 TagletWriter writer) { |
114 TagletOutput result = writer.getOutputInstance(); |
115 Content result = writer.getOutputInstance(); |
115 if (holder instanceof MethodDoc) { |
116 if (holder instanceof MethodDoc) { |
116 Set<Tag> declaredExceptionTags = new LinkedHashSet<Tag>(); |
117 Set<Tag> declaredExceptionTags = new LinkedHashSet<Tag>(); |
117 for (int j = 0; j < declaredExceptionTypes.length; j++) { |
118 for (int j = 0; j < declaredExceptionTypes.length; j++) { |
118 DocFinder.Output inheritedDoc = |
119 DocFinder.Output inheritedDoc = |
119 DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, |
120 DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, |
123 (MethodDoc) holder, this, |
124 (MethodDoc) holder, this, |
124 declaredExceptionTypes[j].qualifiedTypeName())); |
125 declaredExceptionTypes[j].qualifiedTypeName())); |
125 } |
126 } |
126 declaredExceptionTags.addAll(inheritedDoc.tagList); |
127 declaredExceptionTags.addAll(inheritedDoc.tagList); |
127 } |
128 } |
128 result.appendOutput(throwsTagsOutput( |
129 result.addContent(throwsTagsOutput( |
129 declaredExceptionTags.toArray(new ThrowsTag[] {}), |
130 declaredExceptionTags.toArray(new ThrowsTag[] {}), |
130 writer, alreadyDocumented, false)); |
131 writer, alreadyDocumented, false)); |
131 } |
132 } |
132 return result; |
133 return result; |
133 } |
134 } |
134 |
135 |
135 /** |
136 /** |
136 * {@inheritDoc} |
137 * {@inheritDoc} |
137 */ |
138 */ |
138 public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { |
139 public Content getTagletOutput(Doc holder, TagletWriter writer) { |
139 ExecutableMemberDoc execHolder = (ExecutableMemberDoc) holder; |
140 ExecutableMemberDoc execHolder = (ExecutableMemberDoc) holder; |
140 ThrowsTag[] tags = execHolder.throwsTags(); |
141 ThrowsTag[] tags = execHolder.throwsTags(); |
141 TagletOutput result = writer.getOutputInstance(); |
142 Content result = writer.getOutputInstance(); |
142 HashSet<String> alreadyDocumented = new HashSet<String>(); |
143 HashSet<String> alreadyDocumented = new HashSet<String>(); |
143 if (tags.length > 0) { |
144 if (tags.length > 0) { |
144 result.appendOutput(throwsTagsOutput( |
145 result.addContent(throwsTagsOutput( |
145 execHolder.throwsTags(), writer, alreadyDocumented, true)); |
146 execHolder.throwsTags(), writer, alreadyDocumented, true)); |
146 } |
147 } |
147 result.appendOutput(inheritThrowsDocumentation(holder, |
148 result.addContent(inheritThrowsDocumentation(holder, |
148 execHolder.thrownExceptionTypes(), alreadyDocumented, writer)); |
149 execHolder.thrownExceptionTypes(), alreadyDocumented, writer)); |
149 result.appendOutput(linkToUndocumentedDeclaredExceptions( |
150 result.addContent(linkToUndocumentedDeclaredExceptions( |
150 execHolder.thrownExceptionTypes(), alreadyDocumented, writer)); |
151 execHolder.thrownExceptionTypes(), alreadyDocumented, writer)); |
151 return result; |
152 return result; |
152 } |
153 } |
153 |
154 |
154 |
155 |
158 * @param throwTags the array of <code>ThrowsTag</code>s to convert. |
159 * @param throwTags the array of <code>ThrowsTag</code>s to convert. |
159 * @param writer the TagletWriter that will write this tag. |
160 * @param writer the TagletWriter that will write this tag. |
160 * @param alreadyDocumented the set of exceptions that have already |
161 * @param alreadyDocumented the set of exceptions that have already |
161 * been documented. |
162 * been documented. |
162 * @param allowDups True if we allow duplicate throws tags to be documented. |
163 * @param allowDups True if we allow duplicate throws tags to be documented. |
163 * @return the TagletOutput representation of this <code>Tag</code>. |
164 * @return the Content representation of this <code>Tag</code>. |
164 */ |
165 */ |
165 protected TagletOutput throwsTagsOutput(ThrowsTag[] throwTags, |
166 protected Content throwsTagsOutput(ThrowsTag[] throwTags, |
166 TagletWriter writer, Set<String> alreadyDocumented, boolean allowDups) { |
167 TagletWriter writer, Set<String> alreadyDocumented, boolean allowDups) { |
167 TagletOutput result = writer.getOutputInstance(); |
168 Content result = writer.getOutputInstance(); |
168 if (throwTags.length > 0) { |
169 if (throwTags.length > 0) { |
169 for (int i = 0; i < throwTags.length; ++i) { |
170 for (int i = 0; i < throwTags.length; ++i) { |
170 ThrowsTag tt = throwTags[i]; |
171 ThrowsTag tt = throwTags[i]; |
171 ClassDoc cd = tt.exception(); |
172 ClassDoc cd = tt.exception(); |
172 if ((!allowDups) && (alreadyDocumented.contains(tt.exceptionName()) || |
173 if ((!allowDups) && (alreadyDocumented.contains(tt.exceptionName()) || |
173 (cd != null && alreadyDocumented.contains(cd.qualifiedName())))) { |
174 (cd != null && alreadyDocumented.contains(cd.qualifiedName())))) { |
174 continue; |
175 continue; |
175 } |
176 } |
176 if (alreadyDocumented.size() == 0) { |
177 if (alreadyDocumented.size() == 0) { |
177 result.appendOutput(writer.getThrowsHeader()); |
178 result.addContent(writer.getThrowsHeader()); |
178 } |
179 } |
179 result.appendOutput(writer.throwsTagOutput(tt)); |
180 result.addContent(writer.throwsTagOutput(tt)); |
180 alreadyDocumented.add(cd != null ? |
181 alreadyDocumented.add(cd != null ? |
181 cd.qualifiedName() : tt.exceptionName()); |
182 cd.qualifiedName() : tt.exceptionName()); |
182 } |
183 } |
183 } |
184 } |
184 return result; |
185 return result; |