Lines 27-33
Link Here
|
27 |
private static final int[] UNKNOWN_FORMAT = new int[0]; |
27 |
private static final int[] UNKNOWN_FORMAT = new int[0]; |
28 |
|
28 |
|
29 |
private BinaryType type; |
29 |
private BinaryType type; |
30 |
private String content; |
30 |
private char[] content; |
31 |
|
31 |
|
32 |
private int childrenStart; |
32 |
private int childrenStart; |
33 |
|
33 |
|
Lines 60-75
Link Here
|
60 |
|
60 |
|
61 |
public JavadocContents(BinaryType type, String content) { |
61 |
public JavadocContents(BinaryType type, String content) { |
62 |
this.type = type; |
62 |
this.type = type; |
63 |
this.content = content; |
63 |
this.content = content != null ? content.toCharArray() : null; |
64 |
} |
64 |
} |
65 |
|
|
|
66 |
/* |
67 |
* Return the full content of the javadoc |
68 |
*/ |
69 |
public String getContent() { |
70 |
return this.content; |
71 |
} |
72 |
|
73 |
/* |
65 |
/* |
74 |
* Returns the part of the javadoc that describe the type |
66 |
* Returns the part of the javadoc that describe the type |
75 |
*/ |
67 |
*/ |
Lines 84-90
Link Here
|
84 |
|
76 |
|
85 |
if (this.typeDocRange != null) { |
77 |
if (this.typeDocRange != null) { |
86 |
if (this.typeDocRange == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this.type)); |
78 |
if (this.typeDocRange == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this.type)); |
87 |
return this.content.substring(this.typeDocRange[0], this.typeDocRange[1]); |
79 |
return String.valueOf(CharOperation.subarray(this.content, this.typeDocRange[0], this.typeDocRange[1])); |
88 |
} |
80 |
} |
89 |
return null; |
81 |
return null; |
90 |
} |
82 |
} |
Lines 111-117
Link Here
|
111 |
|
103 |
|
112 |
if (range != null) { |
104 |
if (range != null) { |
113 |
if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); |
105 |
if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); |
114 |
return this.content.substring(range[0], range[1]); |
106 |
return String.valueOf(CharOperation.subarray(this.content, range[0], range[1])); |
115 |
} |
107 |
} |
116 |
return null; |
108 |
return null; |
117 |
} |
109 |
} |
Lines 138-144
Link Here
|
138 |
|
130 |
|
139 |
if (range != null) { |
131 |
if (range != null) { |
140 |
if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); |
132 |
if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); |
141 |
return this.content.substring(range[0], range[1]); |
133 |
return String.valueOf(CharOperation.subarray(this.content, range[0], range[1])); |
142 |
} |
134 |
} |
143 |
return null; |
135 |
return null; |
144 |
} |
136 |
} |
Lines 146-159
Link Here
|
146 |
/* |
138 |
/* |
147 |
* Compute the ranges of the parts of the javadoc that describe each method of the type |
139 |
* Compute the ranges of the parts of the javadoc that describe each method of the type |
148 |
*/ |
140 |
*/ |
149 |
private int[] computeChildRange(String anchor, int indexOfSectionBottom) throws JavaModelException { |
141 |
private int[] computeChildRange(char[] anchor, int indexOfSectionBottom) throws JavaModelException { |
150 |
|
142 |
|
151 |
// checks each known anchor locations |
143 |
// checks each known anchor locations |
152 |
if (this.tempAnchorIndexesCount > 0) { |
144 |
if (this.tempAnchorIndexesCount > 0) { |
153 |
for (int i = 0; i < this.tempAnchorIndexesCount; i++) { |
145 |
for (int i = 0; i < this.tempAnchorIndexesCount; i++) { |
154 |
int anchorEndStart = this.tempAnchorIndexes[i]; |
146 |
int anchorEndStart = this.tempAnchorIndexes[i]; |
155 |
|
147 |
|
156 |
if (anchorEndStart != -1 && this.content.startsWith(anchor, anchorEndStart)) { |
148 |
if (anchorEndStart != -1 && CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) { |
157 |
|
149 |
|
158 |
this.tempAnchorIndexes[i] = -1; |
150 |
this.tempAnchorIndexes[i] = -1; |
159 |
|
151 |
|
Lines 166-180
Link Here
|
166 |
int index; |
158 |
int index; |
167 |
|
159 |
|
168 |
// check each next unknown anchor locations |
160 |
// check each next unknown anchor locations |
169 |
while ((index = this.content.indexOf(JavadocConstants.ANCHOR_PREFIX_START, fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) { |
161 |
while ((index = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) { |
170 |
fromIndex = index + 1; |
162 |
fromIndex = index + 1; |
171 |
|
163 |
|
172 |
int anchorEndStart = index + JavadocConstants.ANCHOR_PREFIX_START_LENGHT; |
164 |
int anchorEndStart = index + JavadocConstants.ANCHOR_PREFIX_START_LENGHT; |
173 |
|
165 |
|
174 |
this.tempLastAnchorFoundIndex = anchorEndStart; |
166 |
this.tempLastAnchorFoundIndex = anchorEndStart; |
175 |
|
167 |
|
176 |
if (this.content.startsWith(anchor, anchorEndStart)) { |
168 |
if (CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) { |
177 |
|
|
|
178 |
return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); |
169 |
return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); |
179 |
} else { |
170 |
} else { |
180 |
if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) { |
171 |
if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) { |
Lines 188-203
Link Here
|
188 |
return null; |
179 |
return null; |
189 |
} |
180 |
} |
190 |
|
181 |
|
191 |
private int[] computeChildRange(int anchorEndStart, String anchor, int indexOfBottom) { |
182 |
private int[] computeChildRange(int anchorEndStart, char[] anchor, int indexOfBottom) { |
192 |
int[] range = null; |
183 |
int[] range = null; |
193 |
|
184 |
|
194 |
// try to find the bottom of the section |
185 |
// try to find the bottom of the section |
195 |
if (indexOfBottom != -1) { |
186 |
if (indexOfBottom != -1) { |
196 |
// try to find the end of the anchor |
187 |
// try to find the end of the anchor |
197 |
int indexOfEndLink = this.content.indexOf(JavadocConstants.ANCHOR_SUFFIX, anchorEndStart + anchor.length()); |
188 |
int indexOfEndLink = CharOperation.indexOf(JavadocConstants.ANCHOR_SUFFIX, this.content, false, anchorEndStart + anchor.length); |
198 |
if (indexOfEndLink != -1) { |
189 |
if (indexOfEndLink != -1) { |
199 |
// try to find the next anchor |
190 |
// try to find the next anchor |
200 |
int indexOfNextElement = this.content.indexOf(JavadocConstants.ANCHOR_PREFIX_START, indexOfEndLink); |
191 |
int indexOfNextElement = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, indexOfEndLink); |
201 |
|
192 |
|
202 |
int javadocStart = indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH; |
193 |
int javadocStart = indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH; |
203 |
int javadocEnd = indexOfNextElement == -1 ? indexOfBottom : Math.min(indexOfNextElement, indexOfBottom); |
194 |
int javadocEnd = indexOfNextElement == -1 ? indexOfBottom : Math.min(indexOfNextElement, indexOfBottom); |
Lines 216-237
Link Here
|
216 |
|
207 |
|
217 |
private void computeChildrenSections() { |
208 |
private void computeChildrenSections() { |
218 |
// try to find the next separator part |
209 |
// try to find the next separator part |
219 |
int lastIndex = this.content.indexOf(JavadocConstants.SEPARATOR_START, this.childrenStart); |
210 |
int lastIndex = CharOperation.indexOf(JavadocConstants.SEPARATOR_START, this.content, false, this.childrenStart); |
220 |
|
211 |
|
221 |
// try to find field detail start |
212 |
// try to find field detail start |
222 |
this.indexOfFieldDetails = this.content.indexOf(JavadocConstants.FIELD_DETAIL, lastIndex); |
213 |
this.indexOfFieldDetails = CharOperation.indexOf(JavadocConstants.FIELD_DETAIL, this.content, false, lastIndex); |
223 |
lastIndex = this.indexOfFieldDetails == -1 ? lastIndex : this.indexOfFieldDetails; |
214 |
lastIndex = this.indexOfFieldDetails == -1 ? lastIndex : this.indexOfFieldDetails; |
224 |
|
215 |
|
225 |
// try to find constructor detail start |
216 |
// try to find constructor detail start |
226 |
this.indexOfConstructorDetails = this.content.indexOf(JavadocConstants.CONSTRUCTOR_DETAIL, lastIndex); |
217 |
this.indexOfConstructorDetails = CharOperation.indexOf(JavadocConstants.CONSTRUCTOR_DETAIL, this.content, false, lastIndex); |
227 |
lastIndex = this.indexOfConstructorDetails == -1 ? lastIndex : this.indexOfConstructorDetails; |
218 |
lastIndex = this.indexOfConstructorDetails == -1 ? lastIndex : this.indexOfConstructorDetails; |
228 |
|
219 |
|
229 |
// try to find method detail start |
220 |
// try to find method detail start |
230 |
this.indexOfMethodDetails = this.content.indexOf(JavadocConstants.METHOD_DETAIL, lastIndex); |
221 |
this.indexOfMethodDetails = CharOperation.indexOf(JavadocConstants.METHOD_DETAIL, this.content, false, lastIndex); |
231 |
lastIndex = this.indexOfMethodDetails == -1 ? lastIndex : this.indexOfMethodDetails; |
222 |
lastIndex = this.indexOfMethodDetails == -1 ? lastIndex : this.indexOfMethodDetails; |
232 |
|
223 |
|
233 |
// we take the end of class data |
224 |
// we take the end of class data |
234 |
this.indexOfEndOfClassData = this.content.indexOf(JavadocConstants.END_OF_CLASS_DATA, lastIndex); |
225 |
this.indexOfEndOfClassData = CharOperation.indexOf(JavadocConstants.END_OF_CLASS_DATA, this.content, false, lastIndex); |
235 |
|
226 |
|
236 |
// try to find the field detail end |
227 |
// try to find the field detail end |
237 |
this.indexOfFieldsBottom = |
228 |
this.indexOfFieldsBottom = |
Lines 257-263
Link Here
|
257 |
computeChildrenSections(); |
248 |
computeChildrenSections(); |
258 |
} |
249 |
} |
259 |
|
250 |
|
260 |
String anchor = field.getElementName() + JavadocConstants.ANCHOR_PREFIX_END; |
251 |
StringBuffer buffer = new StringBuffer(field.getElementName()); |
|
|
252 |
buffer.append(JavadocConstants.ANCHOR_PREFIX_END); |
253 |
char[] anchor = String.valueOf(buffer).toCharArray(); |
261 |
|
254 |
|
262 |
int[] range = null; |
255 |
int[] range = null; |
263 |
|
256 |
|
Lines 307-313
Link Here
|
307 |
computeChildrenSections(); |
300 |
computeChildrenSections(); |
308 |
} |
301 |
} |
309 |
|
302 |
|
310 |
String anchor = computeMethodAnchorPrefixEnd((BinaryMethod)method); |
303 |
char[] anchor = computeMethodAnchorPrefixEnd((BinaryMethod)method).toCharArray(); |
311 |
|
304 |
|
312 |
int[] range = null; |
305 |
int[] range = null; |
313 |
|
306 |
|
Lines 420-464
Link Here
|
420 |
* Compute the range of the part of the javadoc that describe the type |
413 |
* Compute the range of the part of the javadoc that describe the type |
421 |
*/ |
414 |
*/ |
422 |
private void computeTypeRange() throws JavaModelException { |
415 |
private void computeTypeRange() throws JavaModelException { |
423 |
final int indexOfStartOfClassData = this.content.indexOf(JavadocConstants.START_OF_CLASS_DATA); |
416 |
final int indexOfStartOfClassData = CharOperation.indexOf(JavadocConstants.START_OF_CLASS_DATA, this.content, false); |
424 |
if (indexOfStartOfClassData == -1) { |
417 |
if (indexOfStartOfClassData == -1) { |
425 |
this.typeDocRange = UNKNOWN_FORMAT; |
418 |
this.typeDocRange = UNKNOWN_FORMAT; |
426 |
return; |
419 |
return; |
427 |
} |
420 |
} |
428 |
int indexOfNextSeparator = this.content.indexOf(JavadocConstants.SEPARATOR_START, indexOfStartOfClassData); |
421 |
int indexOfNextSeparator = CharOperation.indexOf(JavadocConstants.SEPARATOR_START, this.content, false, indexOfStartOfClassData); |
429 |
if (indexOfNextSeparator == -1) { |
422 |
if (indexOfNextSeparator == -1) { |
430 |
this.typeDocRange = UNKNOWN_FORMAT; |
423 |
this.typeDocRange = UNKNOWN_FORMAT; |
431 |
return; |
424 |
return; |
432 |
} |
425 |
} |
433 |
int indexOfNextSummary = this.content.indexOf(JavadocConstants.NESTED_CLASS_SUMMARY, indexOfNextSeparator); |
426 |
int indexOfNextSummary = CharOperation.indexOf(JavadocConstants.NESTED_CLASS_SUMMARY, this.content, false, indexOfNextSeparator); |
434 |
if (indexOfNextSummary == -1 && this.type.isEnum()) { |
427 |
if (indexOfNextSummary == -1 && this.type.isEnum()) { |
435 |
// try to find enum constant summary start |
428 |
// try to find enum constant summary start |
436 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.ENUM_CONSTANT_SUMMARY, indexOfNextSeparator); |
429 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.ENUM_CONSTANT_SUMMARY, this.content, false, indexOfNextSeparator); |
437 |
} |
430 |
} |
438 |
if (indexOfNextSummary == -1 && this.type.isAnnotation()) { |
431 |
if (indexOfNextSummary == -1 && this.type.isAnnotation()) { |
439 |
// try to find required enum constant summary start |
432 |
// try to find required enum constant summary start |
440 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY, indexOfNextSeparator); |
433 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY, this.content, false, indexOfNextSeparator); |
441 |
if (indexOfNextSummary == -1) { |
434 |
if (indexOfNextSummary == -1) { |
442 |
// try to find optional enum constant summary start |
435 |
// try to find optional enum constant summary start |
443 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY, indexOfNextSeparator); |
436 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY, this.content, false, indexOfNextSeparator); |
444 |
} |
437 |
} |
445 |
} |
438 |
} |
446 |
if (indexOfNextSummary == -1) { |
439 |
if (indexOfNextSummary == -1) { |
447 |
// try to find field summary start |
440 |
// try to find field summary start |
448 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.FIELD_SUMMARY, indexOfNextSeparator); |
441 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.FIELD_SUMMARY, this.content, false, indexOfNextSeparator); |
449 |
} |
442 |
} |
450 |
if (indexOfNextSummary == -1) { |
443 |
if (indexOfNextSummary == -1) { |
451 |
// try to find constructor summary start |
444 |
// try to find constructor summary start |
452 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.CONSTRUCTOR_SUMMARY, indexOfNextSeparator); |
445 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.CONSTRUCTOR_SUMMARY, this.content, false, indexOfNextSeparator); |
453 |
} |
446 |
} |
454 |
if (indexOfNextSummary == -1) { |
447 |
if (indexOfNextSummary == -1) { |
455 |
// try to find method summary start |
448 |
// try to find method summary start |
456 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.METHOD_SUMMARY, indexOfNextSeparator); |
449 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.METHOD_SUMMARY, this.content, false, indexOfNextSeparator); |
457 |
} |
450 |
} |
458 |
|
451 |
|
459 |
if (indexOfNextSummary == -1) { |
452 |
if (indexOfNextSummary == -1) { |
460 |
// we take the end of class data |
453 |
// we take the end of class data |
461 |
indexOfNextSummary = this.content.indexOf(JavadocConstants.END_OF_CLASS_DATA, indexOfNextSeparator); |
454 |
indexOfNextSummary = CharOperation.indexOf(JavadocConstants.END_OF_CLASS_DATA, this.content, false, indexOfNextSeparator); |
462 |
} else { |
455 |
} else { |
463 |
// improve performance of computation of children ranges |
456 |
// improve performance of computation of children ranges |
464 |
this.childrenStart = indexOfNextSummary + 1; |
457 |
this.childrenStart = indexOfNextSummary + 1; |
Lines 473-482
Link Here
|
473 |
* We remove what the contents between the start of class data and the first <P> |
466 |
* We remove what the contents between the start of class data and the first <P> |
474 |
*/ |
467 |
*/ |
475 |
int start = indexOfStartOfClassData + JavadocConstants.START_OF_CLASS_DATA_LENGTH; |
468 |
int start = indexOfStartOfClassData + JavadocConstants.START_OF_CLASS_DATA_LENGTH; |
476 |
int indexOfFirstParagraph = this.content.indexOf("<P>", start); //$NON-NLS-1$ |
469 |
int indexOfFirstParagraph = CharOperation.indexOf("<P>".toCharArray(), this.content, false, start); //$NON-NLS-1$ |
477 |
if (indexOfFirstParagraph == -1) { |
|
|
478 |
indexOfFirstParagraph = this.content.indexOf("<p>", start); //$NON-NLS-1$ |
479 |
} |
480 |
if (indexOfFirstParagraph != -1 && indexOfFirstParagraph < indexOfNextSummary) { |
470 |
if (indexOfFirstParagraph != -1 && indexOfFirstParagraph < indexOfNextSummary) { |
481 |
start = indexOfFirstParagraph; |
471 |
start = indexOfFirstParagraph; |
482 |
} |
472 |
} |