Lines 30-41
Link Here
|
30 |
*/ |
30 |
*/ |
31 |
package org.netbeans.api.java.source.ui; |
31 |
package org.netbeans.api.java.source.ui; |
32 |
|
32 |
|
|
|
33 |
import com.sun.source.util.Trees; |
33 |
import java.awt.event.ActionEvent; |
34 |
import java.awt.event.ActionEvent; |
34 |
import java.io.IOException; |
35 |
import java.io.IOException; |
35 |
import java.lang.reflect.Modifier; |
36 |
import java.lang.reflect.Modifier; |
36 |
import java.net.URI; |
37 |
import java.net.URI; |
37 |
import java.net.URL; |
38 |
import java.net.URL; |
38 |
import java.util.*; |
39 |
import java.util.*; |
|
|
40 |
import java.util.concurrent.ExecutionException; |
41 |
import java.util.concurrent.Future; |
42 |
import java.util.concurrent.TimeUnit; |
43 |
import java.util.concurrent.TimeoutException; |
39 |
import javax.lang.model.element.Element; |
44 |
import javax.lang.model.element.Element; |
40 |
import javax.lang.model.element.ElementKind; |
45 |
import javax.lang.model.element.ElementKind; |
41 |
import javax.lang.model.element.ExecutableElement; |
46 |
import javax.lang.model.element.ExecutableElement; |
Lines 50-59
Link Here
|
50 |
import javax.swing.Action; |
55 |
import javax.swing.Action; |
51 |
import com.sun.javadoc.*; |
56 |
import com.sun.javadoc.*; |
52 |
import com.sun.javadoc.AnnotationDesc.ElementValuePair; |
57 |
import com.sun.javadoc.AnnotationDesc.ElementValuePair; |
53 |
import com.sun.source.util.Trees; |
|
|
54 |
import java.net.MalformedURLException; |
58 |
import java.net.MalformedURLException; |
55 |
import java.util.ArrayList; |
59 |
import java.util.ArrayList; |
56 |
import java.util.concurrent.Callable; |
60 |
import java.util.concurrent.Callable; |
|
|
61 |
import java.util.concurrent.FutureTask; |
57 |
import org.netbeans.api.java.source.ClasspathInfo; |
62 |
import org.netbeans.api.java.source.ClasspathInfo; |
58 |
import org.netbeans.api.java.source.CompilationController; |
63 |
import org.netbeans.api.java.source.CompilationController; |
59 |
import org.netbeans.api.java.source.CompilationInfo; |
64 |
import org.netbeans.api.java.source.CompilationInfo; |
Lines 63-73
Link Here
|
63 |
import org.netbeans.api.java.source.JavaSource.Phase; |
68 |
import org.netbeans.api.java.source.JavaSource.Phase; |
64 |
import org.netbeans.api.java.source.SourceUtils; |
69 |
import org.netbeans.api.java.source.SourceUtils; |
65 |
import org.netbeans.api.java.source.Task; |
70 |
import org.netbeans.api.java.source.Task; |
|
|
71 |
import org.netbeans.modules.java.preprocessorbridge.api.JavaSourceUtil; |
72 |
import org.netbeans.modules.java.source.JavaSourceAccessor; |
66 |
import org.netbeans.modules.java.source.JavadocHelper; |
73 |
import org.netbeans.modules.java.source.JavadocHelper; |
|
|
74 |
import org.netbeans.modules.java.source.usages.Pair; |
75 |
import org.netbeans.modules.parsing.spi.ParseException; |
67 |
import org.openide.filesystems.FileObject; |
76 |
import org.openide.filesystems.FileObject; |
68 |
import org.openide.filesystems.FileStateInvalidException; |
77 |
import org.openide.filesystems.FileStateInvalidException; |
69 |
import org.openide.util.Exceptions; |
78 |
import org.openide.util.Exceptions; |
70 |
import org.openide.util.NbBundle; |
79 |
import org.openide.util.NbBundle; |
|
|
80 |
import org.openide.util.RequestProcessor; |
71 |
import org.openide.xml.XMLUtil; |
81 |
import org.openide.xml.XMLUtil; |
72 |
|
82 |
|
73 |
/** Utility class for viewing Javadoc comments as HTML. |
83 |
/** Utility class for viewing Javadoc comments as HTML. |
Lines 78-83
Link Here
|
78 |
|
88 |
|
79 |
private static final String API = "/api"; //NOI18N |
89 |
private static final String API = "/api"; //NOI18N |
80 |
private static final Set<String> LANGS; |
90 |
private static final Set<String> LANGS; |
|
|
91 |
|
92 |
private static final RequestProcessor RP = new RequestProcessor(ElementJavadoc.class); |
81 |
|
93 |
|
82 |
static { |
94 |
static { |
83 |
Locale[] availableLocales = Locale.getAvailableLocales(); |
95 |
Locale[] availableLocales = Locale.getAvailableLocales(); |
Lines 92-101
Link Here
|
92 |
} |
104 |
} |
93 |
|
105 |
|
94 |
private ClasspathInfo cpInfo; |
106 |
private ClasspathInfo cpInfo; |
95 |
private ElementUtilities eu; |
|
|
96 |
private Trees trees; |
97 |
//private Doc doc; |
107 |
//private Doc doc; |
98 |
private String content = null; |
108 |
private Future<String> content; |
99 |
private Hashtable<String, ElementHandle<? extends Element>> links = new Hashtable<String, ElementHandle<? extends Element>>(); |
109 |
private Hashtable<String, ElementHandle<? extends Element>> links = new Hashtable<String, ElementHandle<? extends Element>>(); |
100 |
private int linkCounter = 0; |
110 |
private int linkCounter = 0; |
101 |
private URL docURL = null; |
111 |
private URL docURL = null; |
Lines 143-148
Link Here
|
143 |
* @return HTML text of the javadoc |
153 |
* @return HTML text of the javadoc |
144 |
*/ |
154 |
*/ |
145 |
public String getText() { |
155 |
public String getText() { |
|
|
156 |
try { |
157 |
return content.get(); |
158 |
} catch (InterruptedException ex) { |
159 |
return null; |
160 |
} catch (ExecutionException ex) { |
161 |
return null; |
162 |
} |
163 |
} |
164 |
|
165 |
public Future<String> getFutureText() { |
146 |
return content; |
166 |
return content; |
147 |
} |
167 |
} |
148 |
|
168 |
|
Lines 246-255
Link Here
|
246 |
} |
266 |
} |
247 |
|
267 |
|
248 |
private ElementJavadoc(CompilationInfo compilationInfo, Element element, URL url, final Callable<Boolean> cancel) { |
268 |
private ElementJavadoc(CompilationInfo compilationInfo, Element element, URL url, final Callable<Boolean> cancel) { |
249 |
this.trees = compilationInfo.getTrees(); |
269 |
Pair<Trees,ElementUtilities> context = Pair.of(compilationInfo.getTrees(), compilationInfo.getElementUtilities()); |
250 |
this.eu = compilationInfo.getElementUtilities(); |
|
|
251 |
this.cpInfo = compilationInfo.getClasspathInfo(); |
270 |
this.cpInfo = compilationInfo.getClasspathInfo(); |
252 |
Doc doc = eu.javaDocFor(element); |
271 |
Doc doc = context.second.javaDocFor(element); |
253 |
boolean localized = false; |
272 |
boolean localized = false; |
254 |
StringBuilder content = new StringBuilder(); |
273 |
StringBuilder content = new StringBuilder(); |
255 |
JavadocHelper.TextStream page = null; |
274 |
JavadocHelper.TextStream page = null; |
Lines 282-288
Link Here
|
282 |
} |
301 |
} |
283 |
} |
302 |
} |
284 |
} |
303 |
} |
285 |
this.content = content.append(prepareContent(doc, localized, page, cancel)).toString(); |
304 |
try { |
|
|
305 |
//Optimisitic no http |
306 |
this.content = prepareContent(content, doc,localized, page, cancel, true, context); |
307 |
} catch (RemoteJavadocException re) { |
308 |
final FileObject fo = compilationInfo.getFileObject(); |
309 |
final ElementHandle<? extends Element> handle = ElementHandle.create(element); |
310 |
final StringBuilder contentFin = content; |
311 |
final boolean localizedFin = localized; |
312 |
this.content = new FutureTask<String>(new Callable<String>(){ |
313 |
@Override |
314 |
public String call() throws Exception { |
315 |
final JavaSourceUtil.Handle ch = JavaSourceUtil.createControllerHandle(fo, null); |
316 |
final CompilationController c = (CompilationController) ch.getCompilationController(); |
317 |
c.toPhase(Phase.RESOLVED); |
318 |
final Element element = handle.resolve(c); |
319 |
Pair<Trees,ElementUtilities> context = Pair.of(c.getTrees(), c.getElementUtilities()); |
320 |
Doc doc = context.second.javaDocFor(element); |
321 |
JavadocHelper.TextStream page = JavadocHelper.getJavadoc(element, cancel); |
322 |
return prepareContent(contentFin, doc,localizedFin, page, cancel, false, context).get(); |
323 |
} |
324 |
}); |
325 |
RP.post((Runnable)this.content); |
326 |
} |
286 |
} |
327 |
} |
287 |
|
328 |
|
288 |
private ElementJavadoc(URL url) { |
329 |
private ElementJavadoc(URL url) { |
Lines 329-353
Link Here
|
329 |
|
370 |
|
330 |
/** |
371 |
/** |
331 |
* Creates javadoc content |
372 |
* Creates javadoc content |
|
|
373 |
* @header header of the generated HTML |
332 |
* @param eu element utilities to find out elements |
374 |
* @param eu element utilities to find out elements |
333 |
* @param doc javac javadoc model |
375 |
* @param doc javac javadoc model |
334 |
* @param useJavadoc preffer javadoc to sources |
376 |
* @param useJavadoc preffer javadoc to sources |
335 |
* @return Javadoc content |
377 |
* @return Javadoc content |
336 |
*/ |
378 |
*/ |
337 |
private StringBuilder prepareContent(Doc doc, final boolean useJavadoc, JavadocHelper.TextStream page, Callable<Boolean> cancel) { |
379 |
private Future<String> prepareContent( |
338 |
StringBuilder sb = new StringBuilder(); |
380 |
final StringBuilder header, |
|
|
381 |
final Doc doc, |
382 |
final boolean useJavadoc, |
383 |
final JavadocHelper.TextStream page, |
384 |
final Callable<Boolean> cancel, |
385 |
final boolean sync, Pair<Trees,ElementUtilities> ctx) throws RemoteJavadocException { |
386 |
|
387 |
|
388 |
final StringBuilder sb = new StringBuilder(header); |
339 |
if (doc != null) { |
389 |
if (doc != null) { |
340 |
if (doc instanceof ProgramElementDoc) { |
390 |
if (doc instanceof ProgramElementDoc) { |
341 |
sb.append(getContainingClassOrPackageHeader((ProgramElementDoc)doc)); |
391 |
sb.append(getContainingClassOrPackageHeader((ProgramElementDoc)doc, ctx)); |
342 |
} |
392 |
} |
343 |
if (doc.isMethod() || doc.isConstructor() || doc.isAnnotationTypeElement()) { |
393 |
if (doc.isMethod() || doc.isConstructor() || doc.isAnnotationTypeElement()) { |
344 |
sb.append(getMethodHeader((ExecutableMemberDoc)doc)); |
394 |
sb.append(getMethodHeader((ExecutableMemberDoc)doc, ctx)); |
345 |
} else if (doc.isField() || doc.isEnumConstant()) { |
395 |
} else if (doc.isField() || doc.isEnumConstant()) { |
346 |
sb.append(getFieldHeader((FieldDoc)doc)); |
396 |
sb.append(getFieldHeader((FieldDoc)doc, ctx)); |
347 |
} else if (doc.isClass() || doc.isInterface() || doc.isAnnotationType()) { |
397 |
} else if (doc.isClass() || doc.isInterface() || doc.isAnnotationType()) { |
348 |
sb.append(getClassHeader((ClassDoc)doc)); |
398 |
sb.append(getClassHeader((ClassDoc)doc, ctx)); |
349 |
} else if (doc instanceof PackageDoc) { |
399 |
} else if (doc instanceof PackageDoc) { |
350 |
sb.append(getPackageHeader((PackageDoc)doc)); |
400 |
sb.append(getPackageHeader((PackageDoc)doc, ctx)); |
351 |
} |
401 |
} |
352 |
sb.append("<p>"); //NOI18N |
402 |
sb.append("<p>"); //NOI18N |
353 |
if (!useJavadoc) { |
403 |
if (!useJavadoc) { |
Lines 454-467
Link Here
|
454 |
inheritedReturnTags != null && inheritedReturnTags.isEmpty() || |
504 |
inheritedReturnTags != null && inheritedReturnTags.isEmpty() || |
455 |
paramPos != null && !paramPos.isEmpty() || |
505 |
paramPos != null && !paramPos.isEmpty() || |
456 |
throwsTypes != null && !throwsTypes.isEmpty()) { |
506 |
throwsTypes != null && !throwsTypes.isEmpty()) { |
457 |
String s = inheritedDocFor(mdoc, mdoc.containingClass(), inheritedTags, inheritedReturnTags, |
507 |
String s = inheritedDocFor(mdoc, mdoc.containingClass(), inheritedTags, inheritedReturnTags, |
458 |
paramPos, inheritedParamTags, inheritedParamInlineTags, |
508 |
paramPos, inheritedParamTags, inheritedParamInlineTags, |
459 |
throwsTypes, inheritedThrowsTags, inheritedThrowsInlineTags, cancel); |
509 |
throwsTypes, inheritedThrowsTags, inheritedThrowsInlineTags, cancel, sync, ctx); |
460 |
if (s != null) { |
510 |
if (s != null) { |
461 |
sb.append(s); |
511 |
sb.append(s); |
462 |
sb.append("</p>"); //NOI18N |
512 |
sb.append("</p>"); //NOI18N |
463 |
return sb; |
513 |
return new Now(sb.toString()); |
464 |
} |
514 |
} |
465 |
} |
515 |
} |
466 |
if (inheritedTags != null && !inheritedTags.isEmpty()) { |
516 |
if (inheritedTags != null && !inheritedTags.isEmpty()) { |
467 |
if (inlineTags.length == 0) { |
517 |
if (inlineTags.length == 0) { |
Lines 542-583
Link Here
|
542 |
} |
592 |
} |
543 |
} |
593 |
} |
544 |
if (inlineTags.length > 0 || doc.tags().length > 0) { |
594 |
if (inlineTags.length > 0 || doc.tags().length > 0) { |
545 |
sb.append(getDeprecatedTag(doc)); |
595 |
sb.append(getDeprecatedTag(doc, ctx)); |
546 |
sb.append(inlineTags(doc, inlineTags)); |
596 |
sb.append(inlineTags(doc, inlineTags, ctx)); |
547 |
sb.append("</p><p>"); //NOI18N |
597 |
sb.append("</p><p>"); //NOI18N |
548 |
sb.append(getMethodTags(mdoc, returnTags, paramTags, |
598 |
sb.append(getMethodTags(mdoc, returnTags, paramTags, |
549 |
throwsTags, throwsInlineTags)); |
599 |
throwsTags, throwsInlineTags, ctx)); |
550 |
sb.append("</p>"); //NOI18N |
600 |
sb.append("</p>"); //NOI18N |
551 |
return sb; |
601 |
return new Now(sb.toString()); |
552 |
} |
602 |
} |
553 |
} else { |
603 |
} else { |
554 |
if (inlineTags.length > 0 || doc.tags().length > 0) { |
604 |
if (inlineTags.length > 0 || doc.tags().length > 0) { |
555 |
sb.append(getDeprecatedTag(doc)); |
605 |
sb.append(getDeprecatedTag(doc, ctx)); |
556 |
sb.append(inlineTags(doc, inlineTags)); |
606 |
sb.append(inlineTags(doc, inlineTags, ctx)); |
557 |
sb.append("</p><p>"); //NOI18N |
607 |
sb.append("</p><p>"); //NOI18N |
558 |
sb.append(getTags(doc)); |
608 |
sb.append(getTags(doc, ctx)); |
559 |
sb.append("</p>"); //NOI18N |
609 |
sb.append("</p>"); //NOI18N |
560 |
return sb; |
610 |
return new Now(sb.toString()); |
561 |
} |
611 |
} |
562 |
} |
612 |
} |
563 |
} |
613 |
} |
564 |
String jdText = page != null ? HTMLJavadocParser.getJavadocText(page, false) : docURL != null ? HTMLJavadocParser.getJavadocText(docURL, false) : null; |
614 |
|
565 |
if (jdText != null) |
615 |
final Callable<String> call = new Callable<String>() { |
566 |
sb.append(jdText); |
616 |
@Override |
567 |
else |
617 |
public String call() throws Exception { |
568 |
sb.append(NbBundle.getMessage(ElementJavadoc.class, "javadoc_content_not_found")); //NOI18N |
618 |
String jdText = page != null ? HTMLJavadocParser.getJavadocText(page, false) : docURL != null ? HTMLJavadocParser.getJavadocText(docURL, false) : null; |
569 |
sb.append("</p>"); //NOI18N |
619 |
if (jdText != null) |
570 |
return sb; |
620 |
sb.append(jdText); |
|
|
621 |
else |
622 |
sb.append(NbBundle.getMessage(ElementJavadoc.class, "javadoc_content_not_found")); //NOI18N |
623 |
sb.append("</p>"); //NOI18N |
624 |
return sb.toString(); |
625 |
} |
626 |
}; |
627 |
final FutureTask<String> task = new FutureTask<String>(call); |
628 |
if (sync) { |
629 |
RP.post(task); |
630 |
} else { |
631 |
task.run(); |
632 |
} |
633 |
return task; |
571 |
} |
634 |
} |
572 |
sb.append(NbBundle.getMessage(ElementJavadoc.class, "javadoc_content_not_found")); //NOI18N |
635 |
sb.append(NbBundle.getMessage(ElementJavadoc.class, "javadoc_content_not_found")); //NOI18N |
573 |
return sb; |
636 |
return new Now (sb.toString()); |
574 |
} |
637 |
} |
575 |
|
638 |
|
576 |
private CharSequence getContainingClassOrPackageHeader(ProgramElementDoc peDoc) { |
639 |
private CharSequence getContainingClassOrPackageHeader(ProgramElementDoc peDoc, Pair<Trees,ElementUtilities> ctx) { |
577 |
StringBuilder sb = new StringBuilder(); |
640 |
StringBuilder sb = new StringBuilder(); |
578 |
ClassDoc cls = peDoc.containingClass(); |
641 |
ClassDoc cls = peDoc.containingClass(); |
579 |
if (cls != null) { |
642 |
if (cls != null) { |
580 |
Element e = eu.elementFor(cls); |
643 |
Element e = ctx.second.elementFor(cls); |
581 |
if (e != null) { |
644 |
if (e != null) { |
582 |
switch(e.getEnclosingElement().getKind()) { |
645 |
switch(e.getEnclosingElement().getKind()) { |
583 |
case ANNOTATION_TYPE: |
646 |
case ANNOTATION_TYPE: |
Lines 596-602
Link Here
|
596 |
PackageDoc pkg = peDoc.containingPackage(); |
659 |
PackageDoc pkg = peDoc.containingPackage(); |
597 |
if (pkg != null) { |
660 |
if (pkg != null) { |
598 |
sb.append("<font size='+0'><b>"); //NOI18N |
661 |
sb.append("<font size='+0'><b>"); //NOI18N |
599 |
createLink(sb, eu.elementFor(pkg), makeNameLineBreakable(pkg.name())); |
662 |
createLink(sb, ctx.second.elementFor(pkg), makeNameLineBreakable(pkg.name())); |
600 |
sb.append("</b></font>"); //NOI18N) |
663 |
sb.append("</b></font>"); //NOI18N) |
601 |
} |
664 |
} |
602 |
} |
665 |
} |
Lines 606-615
Link Here
|
606 |
return name.replace(".", /* ZERO WIDTH SPACE */".​"); |
669 |
return name.replace(".", /* ZERO WIDTH SPACE */".​"); |
607 |
} |
670 |
} |
608 |
|
671 |
|
609 |
private CharSequence getMethodHeader(ExecutableMemberDoc mdoc) { |
672 |
private CharSequence getMethodHeader(ExecutableMemberDoc mdoc, Pair<Trees,ElementUtilities> ctx) { |
610 |
StringBuilder sb = new StringBuilder(); |
673 |
StringBuilder sb = new StringBuilder(); |
611 |
sb.append("<p><tt>"); //NOI18N |
674 |
sb.append("<p><tt>"); //NOI18N |
612 |
sb.append(getAnnotations(mdoc.annotations())); |
675 |
sb.append(getAnnotations(mdoc.annotations(), ctx)); |
613 |
int len = sb.length(); |
676 |
int len = sb.length(); |
614 |
sb.append(Modifier.toString(mdoc.modifierSpecifier() &~ Modifier.NATIVE)); |
677 |
sb.append(Modifier.toString(mdoc.modifierSpecifier() &~ Modifier.NATIVE)); |
615 |
len = sb.length() - len; |
678 |
len = sb.length() - len; |
Lines 621-627
Link Here
|
621 |
} |
684 |
} |
622 |
sb.append("<"); //NOI18N |
685 |
sb.append("<"); //NOI18N |
623 |
for (int i = 0; i < tvars.length; i++) { |
686 |
for (int i = 0; i < tvars.length; i++) { |
624 |
len += appendType(sb, tvars[i], false, true, false); |
687 |
len += appendType(sb, tvars[i], false, true, false, ctx); |
625 |
if (i < tvars.length - 1) { |
688 |
if (i < tvars.length - 1) { |
626 |
sb.append(","); //NOI18N |
689 |
sb.append(","); //NOI18N |
627 |
len++; |
690 |
len++; |
Lines 635-641
Link Here
|
635 |
sb.append(' '); //NOI18N |
698 |
sb.append(' '); //NOI18N |
636 |
len++; |
699 |
len++; |
637 |
} |
700 |
} |
638 |
len += appendType(sb, ((MethodDoc)mdoc).returnType(), false, false, false); |
701 |
len += appendType(sb, ((MethodDoc)mdoc).returnType(), false, false, false, ctx); |
639 |
} |
702 |
} |
640 |
String name = mdoc.name(); |
703 |
String name = mdoc.name(); |
641 |
len += name.length(); |
704 |
len += name.length(); |
Lines 645-653
Link Here
|
645 |
len++; |
708 |
len++; |
646 |
Parameter[] params = mdoc.parameters(); |
709 |
Parameter[] params = mdoc.parameters(); |
647 |
for(int i = 0; i < params.length; i++) { |
710 |
for(int i = 0; i < params.length; i++) { |
648 |
sb.append(getAnnotations(params[i].annotations())); |
711 |
sb.append(getAnnotations(params[i].annotations(), ctx)); |
649 |
boolean varArg = i == params.length - 1 && mdoc.isVarArgs(); |
712 |
boolean varArg = i == params.length - 1 && mdoc.isVarArgs(); |
650 |
appendType(sb, params[i].type(), varArg, false, false); |
713 |
appendType(sb, params[i].type(), varArg, false, false, ctx); |
651 |
sb.append(' ').append(params[i].name()); //NOI18N |
714 |
sb.append(' ').append(params[i].name()); //NOI18N |
652 |
String dim = params[i].type().dimension(); |
715 |
String dim = params[i].type().dimension(); |
653 |
if (dim.length() > 0) { |
716 |
if (dim.length() > 0) { |
Lines 665-671
Link Here
|
665 |
if (exs.length > 0) { |
728 |
if (exs.length > 0) { |
666 |
sb.append(" throws "); //NOI18N |
729 |
sb.append(" throws "); //NOI18N |
667 |
for (int i = 0; i < exs.length; i++) { |
730 |
for (int i = 0; i < exs.length; i++) { |
668 |
appendType(sb, exs[i], false, false, false); |
731 |
appendType(sb, exs[i], false, false, false, ctx); |
669 |
if (i < exs.length - 1) |
732 |
if (i < exs.length - 1) |
670 |
sb.append(", "); //NOI18N |
733 |
sb.append(", "); //NOI18N |
671 |
} |
734 |
} |
Lines 674-698
Link Here
|
674 |
return sb; |
737 |
return sb; |
675 |
} |
738 |
} |
676 |
|
739 |
|
677 |
private CharSequence getFieldHeader(FieldDoc fdoc) { |
740 |
private CharSequence getFieldHeader(FieldDoc fdoc, Pair<Trees,ElementUtilities> ctx) { |
678 |
StringBuilder sb = new StringBuilder(); |
741 |
StringBuilder sb = new StringBuilder(); |
679 |
sb.append("<p><tt>"); //NOI18N |
742 |
sb.append("<p><tt>"); //NOI18N |
680 |
sb.append(getAnnotations(fdoc.annotations())); |
743 |
sb.append(getAnnotations(fdoc.annotations(), ctx)); |
681 |
int len = sb.length(); |
744 |
int len = sb.length(); |
682 |
sb.append(fdoc.modifiers()); |
745 |
sb.append(fdoc.modifiers()); |
683 |
len = sb.length() - len; |
746 |
len = sb.length() - len; |
684 |
if (len > 0) |
747 |
if (len > 0) |
685 |
sb.append(' '); //NOI18N |
748 |
sb.append(' '); //NOI18N |
686 |
appendType(sb, fdoc.type(), false, false, false); |
749 |
appendType(sb, fdoc.type(), false, false, false, ctx); |
687 |
sb.append(" <b>").append(fdoc.name()).append("</b>"); //NOI18N |
750 |
sb.append(" <b>").append(fdoc.name()).append("</b>"); //NOI18N |
688 |
sb.append("</tt></p>"); //NOI18N |
751 |
sb.append("</tt></p>"); //NOI18N |
689 |
return sb; |
752 |
return sb; |
690 |
} |
753 |
} |
691 |
|
754 |
|
692 |
private CharSequence getClassHeader(ClassDoc cdoc) { |
755 |
private CharSequence getClassHeader(ClassDoc cdoc, Pair<Trees,ElementUtilities> ctx) { |
693 |
StringBuilder sb = new StringBuilder(); |
756 |
StringBuilder sb = new StringBuilder(); |
694 |
sb.append("<p><tt>"); //NOI18N |
757 |
sb.append("<p><tt>"); //NOI18N |
695 |
sb.append(getAnnotations(cdoc.annotations())); |
758 |
sb.append(getAnnotations(cdoc.annotations(), ctx)); |
696 |
int mods = cdoc.modifierSpecifier() & ~Modifier.INTERFACE; |
759 |
int mods = cdoc.modifierSpecifier() & ~Modifier.INTERFACE; |
697 |
if (cdoc.isEnum()) |
760 |
if (cdoc.isEnum()) |
698 |
mods &= ~Modifier.FINAL; |
761 |
mods &= ~Modifier.FINAL; |
Lines 712-718
Link Here
|
712 |
if (tvars.length > 0) { |
775 |
if (tvars.length > 0) { |
713 |
sb.append("<"); //NOI18N |
776 |
sb.append("<"); //NOI18N |
714 |
for (int i = 0; i < tvars.length; i++) { |
777 |
for (int i = 0; i < tvars.length; i++) { |
715 |
appendType(sb, tvars[i], false, true, false); |
778 |
appendType(sb, tvars[i], false, true, false, ctx); |
716 |
if (i < tvars.length - 1) |
779 |
if (i < tvars.length - 1) |
717 |
sb.append(","); //NOI18N |
780 |
sb.append(","); //NOI18N |
718 |
} |
781 |
} |
Lines 724-737
Link Here
|
724 |
Type supercls = cdoc.superclassType(); |
787 |
Type supercls = cdoc.superclassType(); |
725 |
if (supercls != null) { |
788 |
if (supercls != null) { |
726 |
sb.append(" extends "); //NOI18N |
789 |
sb.append(" extends "); //NOI18N |
727 |
appendType(sb, supercls, false, false, false); |
790 |
appendType(sb, supercls, false, false, false, ctx); |
728 |
} |
791 |
} |
729 |
} |
792 |
} |
730 |
Type[] ifaces = cdoc.interfaceTypes(); |
793 |
Type[] ifaces = cdoc.interfaceTypes(); |
731 |
if (ifaces.length > 0) { |
794 |
if (ifaces.length > 0) { |
732 |
sb.append(cdoc.isInterface() ? " extends " : " implements "); //NOI18N |
795 |
sb.append(cdoc.isInterface() ? " extends " : " implements "); //NOI18N |
733 |
for (int i = 0; i < ifaces.length; i++) { |
796 |
for (int i = 0; i < ifaces.length; i++) { |
734 |
appendType(sb, ifaces[i], false, false, false); |
797 |
appendType(sb, ifaces[i], false, false, false, ctx); |
735 |
if (i < ifaces.length - 1) |
798 |
if (i < ifaces.length - 1) |
736 |
sb.append(", "); //NOI18N |
799 |
sb.append(", "); //NOI18N |
737 |
} |
800 |
} |
Lines 741-769
Link Here
|
741 |
return sb; |
804 |
return sb; |
742 |
} |
805 |
} |
743 |
|
806 |
|
744 |
private CharSequence getPackageHeader(PackageDoc pdoc) { |
807 |
private CharSequence getPackageHeader(PackageDoc pdoc, Pair<Trees,ElementUtilities> ctx) { |
745 |
StringBuilder sb = new StringBuilder(); |
808 |
StringBuilder sb = new StringBuilder(); |
746 |
sb.append("<p><tt>"); //NOI18N |
809 |
sb.append("<p><tt>"); //NOI18N |
747 |
sb.append(getAnnotations(pdoc.annotations())); |
810 |
sb.append(getAnnotations(pdoc.annotations(), ctx)); |
748 |
sb.append("package <b>").append(pdoc.name()).append("</b>"); //NOI18N |
811 |
sb.append("package <b>").append(pdoc.name()).append("</b>"); //NOI18N |
749 |
sb.append("</tt></p>"); //NOI18N |
812 |
sb.append("</tt></p>"); //NOI18N |
750 |
return sb; |
813 |
return sb; |
751 |
} |
814 |
} |
752 |
|
815 |
|
753 |
private CharSequence getAnnotations(AnnotationDesc[] annotations) { |
816 |
private CharSequence getAnnotations(AnnotationDesc[] annotations, Pair<Trees,ElementUtilities> ctx) { |
754 |
StringBuilder sb = new StringBuilder(); |
817 |
StringBuilder sb = new StringBuilder(); |
755 |
for (AnnotationDesc annotationDesc : annotations) { |
818 |
for (AnnotationDesc annotationDesc : annotations) { |
756 |
AnnotationTypeDoc annotationType = annotationDesc.annotationType(); |
819 |
AnnotationTypeDoc annotationType = annotationDesc.annotationType(); |
757 |
if (annotationType != null && isDocumented(annotationType)) { |
820 |
if (annotationType != null && isDocumented(annotationType)) { |
758 |
appendType(sb, annotationType, false, false, true); |
821 |
appendType(sb, annotationType, false, false, true, ctx); |
759 |
ElementValuePair[] pairs = annotationDesc.elementValues(); |
822 |
ElementValuePair[] pairs = annotationDesc.elementValues(); |
760 |
if (pairs.length > 0) { |
823 |
if (pairs.length > 0) { |
761 |
sb.append('('); //NOI18N |
824 |
sb.append('('); //NOI18N |
762 |
for (int i = 0; i < pairs.length; i++) { |
825 |
for (int i = 0; i < pairs.length; i++) { |
763 |
AnnotationTypeElementDoc ated = pairs[i].element(); |
826 |
AnnotationTypeElementDoc ated = pairs[i].element(); |
764 |
createLink(sb, eu.elementFor(ated), ated.name()); |
827 |
createLink(sb, ctx.second.elementFor(ated), ated.name()); |
765 |
sb.append('='); //NOI18N |
828 |
sb.append('='); //NOI18N |
766 |
appendAnnotationValue(sb, pairs[i].value()); |
829 |
appendAnnotationValue(sb, pairs[i].value(), ctx); |
767 |
if (i < pairs.length - 1) |
830 |
if (i < pairs.length - 1) |
768 |
sb.append(","); //NOI18N |
831 |
sb.append(","); //NOI18N |
769 |
} |
832 |
} |
Lines 783-813
Link Here
|
783 |
return false; |
846 |
return false; |
784 |
} |
847 |
} |
785 |
|
848 |
|
786 |
private void appendAnnotationValue(StringBuilder sb, AnnotationValue av) { |
849 |
private void appendAnnotationValue(StringBuilder sb, AnnotationValue av, Pair<Trees,ElementUtilities> ctx) { |
787 |
Object value = av.value(); |
850 |
Object value = av.value(); |
788 |
if (value instanceof AnnotationValue[]) { |
851 |
if (value instanceof AnnotationValue[]) { |
789 |
int length = ((AnnotationValue[])value).length; |
852 |
int length = ((AnnotationValue[])value).length; |
790 |
if (length > 1) |
853 |
if (length > 1) |
791 |
sb.append('{'); //NOI18N |
854 |
sb.append('{'); //NOI18N |
792 |
for(int i = 0; i < ((AnnotationValue[])value).length; i++) { |
855 |
for(int i = 0; i < ((AnnotationValue[])value).length; i++) { |
793 |
appendAnnotationValue(sb, ((AnnotationValue[])value)[i]); |
856 |
appendAnnotationValue(sb, ((AnnotationValue[])value)[i], ctx); |
794 |
if (i < ((AnnotationValue[])value).length - 1) |
857 |
if (i < ((AnnotationValue[])value).length - 1) |
795 |
sb.append(","); //NOI18N |
858 |
sb.append(","); //NOI18N |
796 |
} |
859 |
} |
797 |
if (length > 1) |
860 |
if (length > 1) |
798 |
sb.append('}'); //NOI18N |
861 |
sb.append('}'); //NOI18N |
799 |
} else if (value instanceof Doc) { |
862 |
} else if (value instanceof Doc) { |
800 |
createLink(sb, eu.elementFor((Doc)value), ((Doc)value).name()); |
863 |
createLink(sb, ctx.second.elementFor((Doc)value), ((Doc)value).name()); |
801 |
} else { |
864 |
} else { |
802 |
sb.append(value.toString()); |
865 |
sb.append(value.toString()); |
803 |
} |
866 |
} |
804 |
} |
867 |
} |
805 |
|
868 |
|
806 |
private CharSequence getMethodTags(MethodDoc doc, Tag[] returnTags, Map<Integer, List<Tag>> paramInlineTags, |
869 |
private CharSequence getMethodTags(MethodDoc doc, Tag[] returnTags, Map<Integer, List<Tag>> paramInlineTags, |
807 |
List<ThrowsTag> throwsTags, Map<String, List<Tag>> throwsInlineTags) { |
870 |
List<ThrowsTag> throwsTags, Map<String, List<Tag>> throwsInlineTags, Pair<Trees,ElementUtilities> ctx) { |
808 |
StringBuilder ret = new StringBuilder(); |
871 |
StringBuilder ret = new StringBuilder(); |
809 |
if (returnTags.length > 0) { |
872 |
if (returnTags.length > 0) { |
810 |
ret.append(inlineTags(doc, returnTags)); |
873 |
ret.append(inlineTags(doc, returnTags, ctx)); |
811 |
ret.append("<br>"); //NOI18N |
874 |
ret.append("<br>"); //NOI18N |
812 |
} |
875 |
} |
813 |
StringBuilder par = new StringBuilder(); |
876 |
StringBuilder par = new StringBuilder(); |
Lines 818-824
Link Here
|
818 |
List<Tag> tags = paramInlineTags.get(pos); |
881 |
List<Tag> tags = paramInlineTags.get(pos); |
819 |
Tag[] its = tags.toArray(new Tag[tags.size()]); |
882 |
Tag[] its = tags.toArray(new Tag[tags.size()]); |
820 |
if (its.length > 0) { |
883 |
if (its.length > 0) { |
821 |
CharSequence cs = inlineTags(doc, its); |
884 |
CharSequence cs = inlineTags(doc, its, ctx); |
822 |
if (cs.length() > 0) { |
885 |
if (cs.length() > 0) { |
823 |
par.append(" - "); //NOI18N |
886 |
par.append(" - "); //NOI18N |
824 |
par.append(cs); |
887 |
par.append(cs); |
Lines 834-840
Link Here
|
834 |
tpar.append("<code>").append(pTag.parameterName()).append("</code>"); //NOI18N |
897 |
tpar.append("<code>").append(pTag.parameterName()).append("</code>"); //NOI18N |
835 |
Tag[] its = pTag.inlineTags(); |
898 |
Tag[] its = pTag.inlineTags(); |
836 |
if (its.length > 0) { |
899 |
if (its.length > 0) { |
837 |
CharSequence cs = inlineTags(doc, its); |
900 |
CharSequence cs = inlineTags(doc, its, ctx); |
838 |
if (cs.length() > 0) { |
901 |
if (cs.length() > 0) { |
839 |
tpar.append(" - "); //NOI18N |
902 |
tpar.append(" - "); //NOI18N |
840 |
tpar.append(cs); |
903 |
tpar.append(cs); |
Lines 849-855
Link Here
|
849 |
thr.append("<code>"); //NOI18N |
912 |
thr.append("<code>"); //NOI18N |
850 |
Type exType = throwsTag.exceptionType(); |
913 |
Type exType = throwsTag.exceptionType(); |
851 |
if (exType != null) { |
914 |
if (exType != null) { |
852 |
createLink(thr, eu.elementFor(exType.asClassDoc()), exType.simpleTypeName()); |
915 |
createLink(thr, ctx.second.elementFor(exType.asClassDoc()), exType.simpleTypeName()); |
853 |
} else { |
916 |
} else { |
854 |
thr.append(throwsTag.exceptionName()); |
917 |
thr.append(throwsTag.exceptionName()); |
855 |
} |
918 |
} |
Lines 857-863
Link Here
|
857 |
List<Tag> tags = throwsInlineTags.get(exType != null ? exType.qualifiedTypeName() : throwsTag.exceptionName()); |
920 |
List<Tag> tags = throwsInlineTags.get(exType != null ? exType.qualifiedTypeName() : throwsTag.exceptionName()); |
858 |
Tag[] its = tags == null ? throwsTag.inlineTags() : tags.toArray(new Tag[tags.size()]); |
921 |
Tag[] its = tags == null ? throwsTag.inlineTags() : tags.toArray(new Tag[tags.size()]); |
859 |
if (its.length > 0) { |
922 |
if (its.length > 0) { |
860 |
CharSequence cs = inlineTags(doc, its); |
923 |
CharSequence cs = inlineTags(doc, its, ctx); |
861 |
if (cs.length() > 0) { |
924 |
if (cs.length() > 0) { |
862 |
thr.append(" - "); //NOI18N |
925 |
thr.append(" - "); //NOI18N |
863 |
thr.append(cs); |
926 |
thr.append(cs); |
Lines 877-883
Link Here
|
877 |
String label = stag.label(); |
940 |
String label = stag.label(); |
878 |
if (memberName != null) { |
941 |
if (memberName != null) { |
879 |
if (refClass != null) { |
942 |
if (refClass != null) { |
880 |
createLink(see, eu.elementFor(stag.referencedMember()), "<code>" + (label != null && label.length() > 0 ? label : (refClass.simpleTypeName() + "." + memberName)) + "</code>"); //NOI18N |
943 |
createLink(see, ctx.second.elementFor(stag.referencedMember()), "<code>" + (label != null && label.length() > 0 ? label : (refClass.simpleTypeName() + "." + memberName)) + "</code>"); //NOI18N |
881 |
} else { |
944 |
} else { |
882 |
see.append(className); |
945 |
see.append(className); |
883 |
see.append('.'); //NOI18N |
946 |
see.append('.'); //NOI18N |
Lines 886-892
Link Here
|
886 |
see.append(", "); //NOI18N |
949 |
see.append(", "); //NOI18N |
887 |
} else if (className != null) { |
950 |
} else if (className != null) { |
888 |
if (refClass != null) { |
951 |
if (refClass != null) { |
889 |
createLink(see, eu.elementFor(refClass), "<code>" + (label != null && label.length() > 0 ? label : refClass.simpleTypeName()) + "</code>"); //NOI18N |
952 |
createLink(see, ctx.second.elementFor(refClass), "<code>" + (label != null && label.length() > 0 ? label : refClass.simpleTypeName()) + "</code>"); //NOI18N |
890 |
} else { |
953 |
} else { |
891 |
see.append(className); |
954 |
see.append(className); |
892 |
} |
955 |
} |
Lines 921-927
Link Here
|
921 |
return sb; |
984 |
return sb; |
922 |
} |
985 |
} |
923 |
|
986 |
|
924 |
private CharSequence getTags(Doc doc) { |
987 |
private CharSequence getTags(Doc doc, Pair<Trees,ElementUtilities> ctx) { |
925 |
StringBuilder see = new StringBuilder(); |
988 |
StringBuilder see = new StringBuilder(); |
926 |
StringBuilder par = new StringBuilder(); |
989 |
StringBuilder par = new StringBuilder(); |
927 |
StringBuilder thr = new StringBuilder(); |
990 |
StringBuilder thr = new StringBuilder(); |
Lines 933-957
Link Here
|
933 |
Tag[] its = tag.inlineTags(); |
996 |
Tag[] its = tag.inlineTags(); |
934 |
if (its.length > 0) { |
997 |
if (its.length > 0) { |
935 |
par.append(" - "); //NOI18N |
998 |
par.append(" - "); //NOI18N |
936 |
par.append(inlineTags(doc, its)); |
999 |
par.append(inlineTags(doc, its, ctx)); |
937 |
} |
1000 |
} |
938 |
par.append("<br>"); //NOI18N |
1001 |
par.append("<br>"); //NOI18N |
939 |
} else if (THROWS_TAG.equals(tag.kind()) && !doc.isMethod()) { |
1002 |
} else if (THROWS_TAG.equals(tag.kind()) && !doc.isMethod()) { |
940 |
thr.append("<code>"); //NOI18N |
1003 |
thr.append("<code>"); //NOI18N |
941 |
Type exType = ((ThrowsTag)tag).exceptionType(); |
1004 |
Type exType = ((ThrowsTag)tag).exceptionType(); |
942 |
if (exType != null) |
1005 |
if (exType != null) |
943 |
createLink(thr, eu.elementFor(exType.asClassDoc()), exType.simpleTypeName()); |
1006 |
createLink(thr, ctx.second.elementFor(exType.asClassDoc()), exType.simpleTypeName()); |
944 |
else |
1007 |
else |
945 |
thr.append(((ThrowsTag)tag).exceptionName()); |
1008 |
thr.append(((ThrowsTag)tag).exceptionName()); |
946 |
thr.append("</code>"); //NOI18N |
1009 |
thr.append("</code>"); //NOI18N |
947 |
Tag[] its = tag.inlineTags(); |
1010 |
Tag[] its = tag.inlineTags(); |
948 |
if (its.length > 0) { |
1011 |
if (its.length > 0) { |
949 |
thr.append(" - "); //NOI18N |
1012 |
thr.append(" - "); //NOI18N |
950 |
thr.append(inlineTags(doc, its)); |
1013 |
thr.append(inlineTags(doc, its, ctx)); |
951 |
} |
1014 |
} |
952 |
thr.append("<br>"); //NOI18N |
1015 |
thr.append("<br>"); //NOI18N |
953 |
} else if (RETURN_TAG.equals(tag.kind()) && !doc.isMethod()) { |
1016 |
} else if (RETURN_TAG.equals(tag.kind()) && !doc.isMethod()) { |
954 |
ret.append(inlineTags(doc, tag.inlineTags())); |
1017 |
ret.append(inlineTags(doc, tag.inlineTags(), ctx)); |
955 |
ret.append("<br>"); //NOI18N |
1018 |
ret.append("<br>"); //NOI18N |
956 |
} else if (SEE_TAG.equals(tag.kind())) { |
1019 |
} else if (SEE_TAG.equals(tag.kind())) { |
957 |
SeeTag stag = (SeeTag)tag; |
1020 |
SeeTag stag = (SeeTag)tag; |
Lines 961-967
Link Here
|
961 |
String label = stag.label(); |
1024 |
String label = stag.label(); |
962 |
if (memberName != null) { |
1025 |
if (memberName != null) { |
963 |
if (refClass != null) { |
1026 |
if (refClass != null) { |
964 |
createLink(see, eu.elementFor(stag.referencedMember()), "<code>" + (label != null && label.length() > 0 ? label : (refClass.simpleTypeName() + "." + memberName)) + "</code>"); //NOI18N |
1027 |
createLink(see, ctx.second.elementFor(stag.referencedMember()), "<code>" + (label != null && label.length() > 0 ? label : (refClass.simpleTypeName() + "." + memberName)) + "</code>"); //NOI18N |
965 |
} else { |
1028 |
} else { |
966 |
see.append(className); |
1029 |
see.append(className); |
967 |
see.append('.'); //NOI18N |
1030 |
see.append('.'); //NOI18N |
Lines 970-976
Link Here
|
970 |
see.append(", "); //NOI18N |
1033 |
see.append(", "); //NOI18N |
971 |
} else if (className != null) { |
1034 |
} else if (className != null) { |
972 |
if (refClass != null) { |
1035 |
if (refClass != null) { |
973 |
createLink(see, eu.elementFor(refClass), "<code>" + (label != null && label.length() > 0 ? label : refClass.simpleTypeName()) + "</code>"); //NOI18N |
1036 |
createLink(see, ctx.second.elementFor(refClass), "<code>" + (label != null && label.length() > 0 ? label : refClass.simpleTypeName()) + "</code>"); //NOI18N |
974 |
} else { |
1037 |
} else { |
975 |
see.append(className); |
1038 |
see.append(className); |
976 |
} |
1039 |
} |
Lines 1002-1019
Link Here
|
1002 |
return sb; |
1065 |
return sb; |
1003 |
} |
1066 |
} |
1004 |
|
1067 |
|
1005 |
private CharSequence getDeprecatedTag(Doc doc) { |
1068 |
private CharSequence getDeprecatedTag(Doc doc, Pair<Trees,ElementUtilities> ctx) { |
1006 |
StringBuilder sb = new StringBuilder(); |
1069 |
StringBuilder sb = new StringBuilder(); |
1007 |
for (Tag tag : doc.tags()) { |
1070 |
for (Tag tag : doc.tags()) { |
1008 |
if (DEPRECATED_TAG.equals(tag.kind())) { |
1071 |
if (DEPRECATED_TAG.equals(tag.kind())) { |
1009 |
sb.append("<b>").append(NbBundle.getMessage(ElementJavadoc.class, "JCD-deprecated")).append("</b> <i>").append(inlineTags(doc, tag.inlineTags())).append("</i></p><p>"); //NOI18N |
1072 |
sb.append("<b>").append(NbBundle.getMessage(ElementJavadoc.class, "JCD-deprecated")).append("</b> <i>").append(inlineTags(doc, tag.inlineTags(),ctx)).append("</i></p><p>"); //NOI18N |
1010 |
break; |
1073 |
break; |
1011 |
} |
1074 |
} |
1012 |
} |
1075 |
} |
1013 |
return sb; |
1076 |
return sb; |
1014 |
} |
1077 |
} |
1015 |
|
1078 |
|
1016 |
private CharSequence inlineTags(Doc doc, Tag[] tags) { |
1079 |
private CharSequence inlineTags(Doc doc, Tag[] tags, Pair<Trees,ElementUtilities> ctx) { |
1017 |
StringBuilder sb = new StringBuilder(); |
1080 |
StringBuilder sb = new StringBuilder(); |
1018 |
for (Tag tag : tags) { |
1081 |
for (Tag tag : tags) { |
1019 |
if (SEE_TAG.equals(tag.kind())) { |
1082 |
if (SEE_TAG.equals(tag.kind())) { |
Lines 1035-1041
Link Here
|
1035 |
boolean plain = LINKPLAIN_TAG.equals(stag.name()); |
1098 |
boolean plain = LINKPLAIN_TAG.equals(stag.name()); |
1036 |
if (memberName != null) { |
1099 |
if (memberName != null) { |
1037 |
if (refClass != null) { |
1100 |
if (refClass != null) { |
1038 |
createLink(sb, eu.elementFor(stag.referencedMember()), (plain ? "" : "<code>") + (label != null && label.length() > 0 ? label : (refClass.simpleTypeName() + "." + memberName)) + (plain ? "" : "</code>")); //NOI18N |
1101 |
createLink(sb, ctx.second.elementFor(stag.referencedMember()), (plain ? "" : "<code>") + (label != null && label.length() > 0 ? label : (refClass.simpleTypeName() + "." + memberName)) + (plain ? "" : "</code>")); //NOI18N |
1039 |
} else { |
1102 |
} else { |
1040 |
sb.append(stag.referencedClassName()); |
1103 |
sb.append(stag.referencedClassName()); |
1041 |
sb.append('.'); //NOI18N |
1104 |
sb.append('.'); //NOI18N |
Lines 1043-1049
Link Here
|
1043 |
} |
1106 |
} |
1044 |
} else { |
1107 |
} else { |
1045 |
if (refClass != null) { |
1108 |
if (refClass != null) { |
1046 |
createLink(sb, eu.elementFor(refClass), (plain ? "" : "<code>") + (label != null && label.length() > 0 ? label : refClass.simpleTypeName()) + (plain ? "" : "</code>")); //NOI18N |
1109 |
createLink(sb, ctx.second.elementFor(refClass), (plain ? "" : "<code>") + (label != null && label.length() > 0 ? label : refClass.simpleTypeName()) + (plain ? "" : "</code>")); //NOI18N |
1047 |
} else { |
1110 |
} else { |
1048 |
sb.append(stag.referencedClassName()); |
1111 |
sb.append(stag.referencedClassName()); |
1049 |
} |
1112 |
} |
Lines 1053-1059
Link Here
|
1053 |
if (doc.isMethod()) { |
1116 |
if (doc.isMethod()) { |
1054 |
MethodDoc mdoc = ((MethodDoc)doc).overriddenMethod(); |
1117 |
MethodDoc mdoc = ((MethodDoc)doc).overriddenMethod(); |
1055 |
if (mdoc != null) |
1118 |
if (mdoc != null) |
1056 |
sb.append(inlineTags(mdoc, mdoc.inlineTags())); |
1119 |
sb.append(inlineTags(mdoc, mdoc.inlineTags(),ctx)); |
1057 |
} |
1120 |
} |
1058 |
} else if (LITERAL_TAG.equals(tag.kind())) { |
1121 |
} else if (LITERAL_TAG.equals(tag.kind())) { |
1059 |
try { |
1122 |
try { |
Lines 1114-1120
Link Here
|
1114 |
sb.append(' '); //NOI18N |
1177 |
sb.append(' '); //NOI18N |
1115 |
} |
1178 |
} |
1116 |
|
1179 |
|
1117 |
private int appendType(StringBuilder sb, Type type, boolean varArg, boolean typeVar, boolean annotation) { |
1180 |
private int appendType(StringBuilder sb, Type type, boolean varArg, boolean typeVar, boolean annotation, Pair<Trees,ElementUtilities> ctx) { |
1118 |
int len = 0; |
1181 |
int len = 0; |
1119 |
WildcardType wt = type.asWildcardType(); |
1182 |
WildcardType wt = type.asWildcardType(); |
1120 |
if (wt != null) { |
1183 |
if (wt != null) { |
Lines 1124-1136
Link Here
|
1124 |
if (bounds != null && bounds.length > 0) { |
1187 |
if (bounds != null && bounds.length > 0) { |
1125 |
sb.append(" extends "); //NOI18N |
1188 |
sb.append(" extends "); //NOI18N |
1126 |
len += 9; |
1189 |
len += 9; |
1127 |
len += appendType(sb, bounds[0], false, false, false); |
1190 |
len += appendType(sb, bounds[0], false, false, false, ctx); |
1128 |
} |
1191 |
} |
1129 |
bounds = wt.superBounds(); |
1192 |
bounds = wt.superBounds(); |
1130 |
if (bounds != null && bounds.length > 0) { |
1193 |
if (bounds != null && bounds.length > 0) { |
1131 |
sb.append(" super "); //NOI18N |
1194 |
sb.append(" super "); //NOI18N |
1132 |
len += 7; |
1195 |
len += 7; |
1133 |
len += appendType(sb, bounds[0], false, false, false); |
1196 |
len += appendType(sb, bounds[0], false, false, false, ctx); |
1134 |
} |
1197 |
} |
1135 |
} else { |
1198 |
} else { |
1136 |
TypeVariable tv = type.asTypeVariable(); |
1199 |
TypeVariable tv = type.asTypeVariable(); |
Lines 1141-1147
Link Here
|
1141 |
sb.append(" extends "); //NOI18N |
1204 |
sb.append(" extends "); //NOI18N |
1142 |
len += 9; |
1205 |
len += 9; |
1143 |
for (int i = 0; i < bounds.length; i++) { |
1206 |
for (int i = 0; i < bounds.length; i++) { |
1144 |
len += appendType(sb, bounds[i], false, false, false); |
1207 |
len += appendType(sb, bounds[i], false, false, false, ctx); |
1145 |
if (i < bounds.length - 1) { |
1208 |
if (i < bounds.length - 1) { |
1146 |
sb.append(" & "); //NOI18N |
1209 |
sb.append(" & "); //NOI18N |
1147 |
len += 3; |
1210 |
len += 3; |
Lines 1153-1166
Link Here
|
1153 |
String tName = cd != null ? cd.name() : type.simpleTypeName(); |
1216 |
String tName = cd != null ? cd.name() : type.simpleTypeName(); |
1154 |
if (cd != null && cd.isAnnotationType() && annotation) |
1217 |
if (cd != null && cd.isAnnotationType() && annotation) |
1155 |
tName = "@" + tName; //NOI18N |
1218 |
tName = "@" + tName; //NOI18N |
1156 |
len += createLink(sb, eu.elementFor(type.asClassDoc()), tName); |
1219 |
len += createLink(sb, ctx.second.elementFor(type.asClassDoc()), tName); |
1157 |
ParameterizedType pt = type.asParameterizedType(); |
1220 |
ParameterizedType pt = type.asParameterizedType(); |
1158 |
if (pt != null) { |
1221 |
if (pt != null) { |
1159 |
Type[] targs = pt.typeArguments(); |
1222 |
Type[] targs = pt.typeArguments(); |
1160 |
if (targs.length > 0) { |
1223 |
if (targs.length > 0) { |
1161 |
sb.append("<"); //NOI18N |
1224 |
sb.append("<"); //NOI18N |
1162 |
for (int j = 0; j < targs.length; j++) { |
1225 |
for (int j = 0; j < targs.length; j++) { |
1163 |
len += appendType(sb, targs[j], false, false, false); |
1226 |
len += appendType(sb, targs[j], false, false, false, ctx); |
1164 |
if (j < targs.length - 1) { |
1227 |
if (j < targs.length - 1) { |
1165 |
sb.append(","); //NOI18N |
1228 |
sb.append(","); //NOI18N |
1166 |
len++; |
1229 |
len++; |
Lines 1197-1208
Link Here
|
1197 |
private String inheritedDocFor(MethodDoc mdoc, ClassDoc cdoc, List<Tag> inlineTags, List<Tag> returnTags, |
1260 |
private String inheritedDocFor(MethodDoc mdoc, ClassDoc cdoc, List<Tag> inlineTags, List<Tag> returnTags, |
1198 |
Set<Integer> paramPos, Map<Integer, ParamTag> paramTags, Map<Integer, List<Tag>> paramInlineTags, |
1261 |
Set<Integer> paramPos, Map<Integer, ParamTag> paramTags, Map<Integer, List<Tag>> paramInlineTags, |
1199 |
Set<String> throwsTypes, Map<String, ThrowsTag> throwsTags, Map<String, List<Tag>> throwsInlineTags, |
1262 |
Set<String> throwsTypes, Map<String, ThrowsTag> throwsTags, Map<String, List<Tag>> throwsInlineTags, |
1200 |
Callable<Boolean> cancel) { |
1263 |
Callable<Boolean> cancel, boolean stopByRemoteJdoc, Pair<Trees,ElementUtilities> ctx) throws RemoteJavadocException { |
1201 |
JavadocHelper.TextStream inheritedPage = null; |
1264 |
JavadocHelper.TextStream inheritedPage = null; |
1202 |
for (ClassDoc ifaceDoc : cdoc.interfaces()) { |
1265 |
for (ClassDoc ifaceDoc : cdoc.interfaces()) { |
1203 |
for (MethodDoc methodDoc : ifaceDoc.methods(false)) { |
1266 |
for (MethodDoc methodDoc : ifaceDoc.methods(false)) { |
1204 |
if (mdoc.overrides(methodDoc)) { |
1267 |
if (mdoc.overrides(methodDoc)) { |
1205 |
Element e = eu.elementFor(methodDoc); |
1268 |
Element e = ctx.second.elementFor(methodDoc); |
1206 |
boolean isLocalized = false; |
1269 |
boolean isLocalized = false; |
1207 |
if (e != null) { |
1270 |
if (e != null) { |
1208 |
inheritedPage = JavadocHelper.getJavadoc(e, cancel); |
1271 |
inheritedPage = JavadocHelper.getJavadoc(e, cancel); |
Lines 1210-1216
Link Here
|
1210 |
docURL = inheritedPage.getLocation(); |
1273 |
docURL = inheritedPage.getLocation(); |
1211 |
} |
1274 |
} |
1212 |
if (!(isLocalized = isLocalized(docURL, e))) |
1275 |
if (!(isLocalized = isLocalized(docURL, e))) |
1213 |
trees.getTree(e); |
1276 |
ctx.first.getTree(e); |
1214 |
} |
1277 |
} |
1215 |
if (!isLocalized) { |
1278 |
if (!isLocalized) { |
1216 |
List<Tag> inheritedInlineTags = null; |
1279 |
List<Tag> inheritedInlineTags = null; |
Lines 1294-1300
Link Here
|
1294 |
inheritedParamPos != null && inheritedParamTags != null) |
1357 |
inheritedParamPos != null && inheritedParamTags != null) |
1295 |
inheritedDocFor(mdoc, ifaceDoc, inheritedInlineTags, inheritedReturnTags, |
1358 |
inheritedDocFor(mdoc, ifaceDoc, inheritedInlineTags, inheritedReturnTags, |
1296 |
inheritedParamPos, inheritedParamTags, inheritedParamInlineTags, |
1359 |
inheritedParamPos, inheritedParamTags, inheritedParamInlineTags, |
1297 |
inheritedThrowsTypes, inheritedThrowsTags, inheritedThrowsInlineTags, cancel); |
1360 |
inheritedThrowsTypes, inheritedThrowsTags, inheritedThrowsInlineTags, cancel, stopByRemoteJdoc, ctx); |
1298 |
if (inheritedInlineTags != null && !inheritedInlineTags.isEmpty()) { |
1361 |
if (inheritedInlineTags != null && !inheritedInlineTags.isEmpty()) { |
1299 |
inlineTags.clear(); |
1362 |
inlineTags.clear(); |
1300 |
for (Tag tag : methodDoc.inlineTags()) { |
1363 |
for (Tag tag : methodDoc.inlineTags()) { |
Lines 1349-1361
Link Here
|
1349 |
(throwsTypes == null || throwsTypes.isEmpty())) |
1412 |
(throwsTypes == null || throwsTypes.isEmpty())) |
1350 |
return null; |
1413 |
return null; |
1351 |
} |
1414 |
} |
|
|
1415 |
if (stopByRemoteJdoc && isRemote(inheritedPage, docURL)) { |
1416 |
throw new RemoteJavadocException(); |
1417 |
} |
1352 |
String jdText = inheritedPage != null ? HTMLJavadocParser.getJavadocText(inheritedPage, false) : docURL != null ? HTMLJavadocParser.getJavadocText(docURL, false) : null; |
1418 |
String jdText = inheritedPage != null ? HTMLJavadocParser.getJavadocText(inheritedPage, false) : docURL != null ? HTMLJavadocParser.getJavadocText(docURL, false) : null; |
1353 |
if (jdText != null) |
1419 |
if (jdText != null) |
1354 |
return jdText; |
1420 |
return jdText; |
1355 |
for (ClassDoc ifaceDoc : cdoc.interfaces()) { |
1421 |
for (ClassDoc ifaceDoc : cdoc.interfaces()) { |
1356 |
jdText = inheritedDocFor(mdoc, ifaceDoc, inlineTags, returnTags, |
1422 |
jdText = inheritedDocFor(mdoc, ifaceDoc, inlineTags, returnTags, |
1357 |
paramPos, paramTags, paramInlineTags, |
1423 |
paramPos, paramTags, paramInlineTags, |
1358 |
throwsTypes, throwsTags, throwsInlineTags, cancel); |
1424 |
throwsTypes, throwsTags, throwsInlineTags, cancel, stopByRemoteJdoc, ctx); |
1359 |
if (jdText != null) |
1425 |
if (jdText != null) |
1360 |
return jdText; |
1426 |
return jdText; |
1361 |
if ((inlineTags == null || !inlineTags.isEmpty()) && |
1427 |
if ((inlineTags == null || !inlineTags.isEmpty()) && |
Lines 1369-1375
Link Here
|
1369 |
if (superclass != null) { //NOI18N |
1435 |
if (superclass != null) { //NOI18N |
1370 |
for (MethodDoc methodDoc : superclass.methods(false)) { |
1436 |
for (MethodDoc methodDoc : superclass.methods(false)) { |
1371 |
if (mdoc.overrides(methodDoc)) { |
1437 |
if (mdoc.overrides(methodDoc)) { |
1372 |
Element e = eu.elementFor(methodDoc); |
1438 |
Element e = ctx.second.elementFor(methodDoc); |
1373 |
boolean isLocalized = false; |
1439 |
boolean isLocalized = false; |
1374 |
if (e != null) { |
1440 |
if (e != null) { |
1375 |
inheritedPage = JavadocHelper.getJavadoc(e, cancel); |
1441 |
inheritedPage = JavadocHelper.getJavadoc(e, cancel); |
Lines 1377-1383
Link Here
|
1377 |
docURL = inheritedPage.getLocation(); |
1443 |
docURL = inheritedPage.getLocation(); |
1378 |
} |
1444 |
} |
1379 |
if (!(isLocalized = isLocalized(docURL, e))) |
1445 |
if (!(isLocalized = isLocalized(docURL, e))) |
1380 |
trees.getTree(e); |
1446 |
ctx.first.getTree(e); |
1381 |
} |
1447 |
} |
1382 |
if (!isLocalized) { |
1448 |
if (!isLocalized) { |
1383 |
List<Tag> inheritedInlineTags = null; |
1449 |
List<Tag> inheritedInlineTags = null; |
Lines 1462-1468
Link Here
|
1462 |
inheritedDocFor(mdoc, superclass, inheritedInlineTags, |
1528 |
inheritedDocFor(mdoc, superclass, inheritedInlineTags, |
1463 |
inheritedReturnTags, inheritedParamNames, inheritedParamTags, |
1529 |
inheritedReturnTags, inheritedParamNames, inheritedParamTags, |
1464 |
inheritedParamInlineTags, inheritedThrowsTypes, |
1530 |
inheritedParamInlineTags, inheritedThrowsTypes, |
1465 |
inheritedThrowsTags, inheritedThrowsInlineTags, cancel); |
1531 |
inheritedThrowsTags, inheritedThrowsInlineTags, cancel, stopByRemoteJdoc, ctx); |
1466 |
if (inheritedInlineTags != null && !inheritedInlineTags.isEmpty()) { |
1532 |
if (inheritedInlineTags != null && !inheritedInlineTags.isEmpty()) { |
1467 |
inlineTags.clear(); |
1533 |
inlineTags.clear(); |
1468 |
for (Tag tag : methodDoc.inlineTags()) { |
1534 |
for (Tag tag : methodDoc.inlineTags()) { |
Lines 1515-1525
Link Here
|
1515 |
returnTags != null && returnTags.isEmpty() || |
1581 |
returnTags != null && returnTags.isEmpty() || |
1516 |
paramPos != null && !paramPos.isEmpty() || |
1582 |
paramPos != null && !paramPos.isEmpty() || |
1517 |
throwsTypes != null && !throwsTypes.isEmpty()) { |
1583 |
throwsTypes != null && !throwsTypes.isEmpty()) { |
|
|
1584 |
if (stopByRemoteJdoc && isRemote(inheritedPage,docURL)) { |
1585 |
throw new RemoteJavadocException(); |
1586 |
} |
1518 |
jdText = inheritedPage != null ? HTMLJavadocParser.getJavadocText(inheritedPage, false) : docURL != null ? HTMLJavadocParser.getJavadocText(docURL, false) : null; |
1587 |
jdText = inheritedPage != null ? HTMLJavadocParser.getJavadocText(inheritedPage, false) : docURL != null ? HTMLJavadocParser.getJavadocText(docURL, false) : null; |
1519 |
return jdText != null ? jdText : inheritedDocFor(mdoc, superclass, inlineTags, |
1588 |
return jdText != null ? jdText : inheritedDocFor(mdoc, superclass, inlineTags, |
1520 |
returnTags, paramPos, paramTags, |
1589 |
returnTags, paramPos, paramTags, |
1521 |
paramInlineTags, throwsTypes, |
1590 |
paramInlineTags, throwsTypes, |
1522 |
throwsTags, throwsInlineTags, cancel); |
1591 |
throwsTags, throwsInlineTags, cancel, stopByRemoteJdoc, ctx); |
1523 |
} |
1592 |
} |
1524 |
} |
1593 |
} |
1525 |
return null; |
1594 |
return null; |
Lines 1535-1538
Link Here
|
1535 |
return -1; |
1604 |
return -1; |
1536 |
|
1605 |
|
1537 |
} |
1606 |
} |
|
|
1607 |
|
1608 |
private static boolean isRemote(final JavadocHelper.TextStream page, final URL url) { |
1609 |
return page != null ? page.getLocation().toString().startsWith("http") : url != null ? url.toString().startsWith("http") : false; |
1610 |
} |
1611 |
|
1612 |
private static final class Now implements Future<String> { |
1613 |
|
1614 |
private final String value; |
1615 |
|
1616 |
Now(final String value) { |
1617 |
this.value = value; |
1618 |
} |
1619 |
|
1620 |
@Override |
1621 |
public boolean cancel(boolean mayInterruptIfRunning) { |
1622 |
return false; |
1623 |
} |
1624 |
|
1625 |
@Override |
1626 |
public boolean isCancelled() { |
1627 |
return false; |
1628 |
} |
1629 |
|
1630 |
@Override |
1631 |
public boolean isDone() { |
1632 |
return true; |
1633 |
} |
1634 |
|
1635 |
@Override |
1636 |
public String get() throws InterruptedException, ExecutionException { |
1637 |
return value; |
1638 |
} |
1639 |
|
1640 |
@Override |
1641 |
public String get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { |
1642 |
return value; |
1643 |
} |
1644 |
} |
1645 |
|
1646 |
private static class RemoteJavadocException extends Exception { |
1647 |
} |
1538 |
} |
1648 |
} |