|
30 | 30 |
|
31 | 31 | import java.io.File;
|
32 | 32 | import java.io.IOException;
|
| 33 | +import java.lang.reflect.Constructor; |
33 | 34 | import java.lang.reflect.Field;
|
34 | 35 | import java.lang.reflect.Method;
|
35 | 36 | import java.lang.reflect.Parameter;
|
@@ -428,6 +429,39 @@ protected static String getSummaryCompletion(final Method method, final Class<?>
|
428 | 429 | summary.append("</DL>");
|
429 | 430 | return summary.toString();
|
430 | 431 | }
|
| 432 | + |
| 433 | + /** |
| 434 | + * Assembles an HTML-formatted auto-completion summary with functional |
| 435 | + * hyperlinks |
| 436 | + * |
| 437 | + * @param constructor the constructor being documented |
| 438 | + * @param c the class being documented. Expected to be documented at the |
| 439 | + * Scijava API documentation portal. |
| 440 | + * @return the completion summary |
| 441 | + */ |
| 442 | + protected static String getSummaryCompletion(final Constructor<?> constructor, final Class<?> c) { |
| 443 | + final StringBuffer summary = new StringBuffer(); |
| 444 | + final StringBuffer replacementHeader = new StringBuffer(c.getSimpleName()); |
| 445 | + final int bIndex = replacementHeader.length(); // remember '(' position |
| 446 | + replacementHeader.append("("); |
| 447 | + final Parameter[] params = constructor.getParameters(); |
| 448 | + if (params.length > 0) { |
| 449 | + for (final Parameter parameter : params) { |
| 450 | + replacementHeader.append(parameter.getType().getSimpleName()).append(" ").append(parameter.getName()).append(", "); |
| 451 | + } |
| 452 | + replacementHeader.setLength(replacementHeader.length() - 2); // remove trailing ', '; |
| 453 | + } |
| 454 | + replacementHeader.append(")"); |
| 455 | + replacementHeader.replace(bIndex, bIndex + 1, "</b>("); // In header, highlight only method name for extra contrast |
| 456 | + summary.append("<b>").append(replacementHeader); |
| 457 | + summary.append("<DL>"); |
| 458 | + summary.append("<DT><b>Intantiates:</b>"); |
| 459 | + summary.append("<DD>").append(c.getSimpleName()); |
| 460 | + summary.append("<DT><b>Defined in:</b>"); |
| 461 | + summary.append("<DD>").append(getJavaDocLink(c)); |
| 462 | + summary.append("</DL>"); |
| 463 | + return summary.toString(); |
| 464 | + } |
431 | 465 |
|
432 | 466 | static List<Completion> classUnavailableCompletions(final CompletionProvider provider, final String pre) {
|
433 | 467 | // placeholder completions to warn users class was not available (repeated to force pop-up display)
|
|
0 commit comments