public class JavaDocumentationProvider extends java.lang.Object implements CodeDocumentationProvider, ExternalDocumentationProvider
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
HTML_EXTENSION |
static java.lang.String |
PACKAGE_SUMMARY_FILE |
EP_NAME| Constructor and Description |
|---|
JavaDocumentationProvider() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canPromptToConfigureDocumentation(PsiElement element)
Checks if the provider is capable of asking the user to configure external documentation for an element.
|
void |
collectDocComments(PsiFile file,
java.util.function.Consumer<PsiDocCommentBase> sink)
This defines documentation comments in file, which can be rendered in place.
|
static void |
createTypeParamsListComment(java.lang.StringBuilder buffer,
CodeDocumentationAwareCommenter commenter,
PsiTypeParameterList typeParameterList) |
java.lang.String |
fetchExternalDocumentation(Project project,
PsiElement element,
java.util.List<java.lang.String> docUrls) |
static java.lang.String |
fetchExternalJavadoc(PsiElement element,
java.util.List<java.lang.String> docURLs,
JavaDocExternalFilter docFilter) |
static java.lang.String |
fetchExternalJavadoc(PsiElement element,
Project project,
java.util.List<java.lang.String> docURLs) |
PsiComment |
findExistingDocComment(PsiComment comment)
Finds primary documentation comment within given context.
|
static java.util.List<java.lang.String> |
findUrlForClass(PsiClass aClass) |
static java.util.List<java.lang.String> |
findUrlForPackage(PsiPackage aPackage) |
static java.lang.String |
generateClassInfo(PsiClass aClass) |
java.lang.String |
generateDoc(PsiElement element,
PsiElement originalElement)
Callback for asking the doc provider for the complete documentation.
|
java.lang.String |
generateDocumentationContentStub(PsiComment _comment)
Generate documentation comment content for given context.
|
static java.lang.String |
generateExternalJavadoc(PsiElement element) |
static java.lang.String |
generateExternalJavadoc(PsiElement element,
JavaDocInfoGenerator generator) |
static java.lang.String |
generateExternalJavadoc(PsiElement element,
java.util.List<java.lang.String> docURLs) |
static java.lang.String |
generateMethodInfo(PsiMethod method,
PsiSubstitutor substitutor) |
static void |
generateParametersTakingDocFromSuperMethods(java.lang.StringBuilder builder,
CodeDocumentationAwareCommenter commenter,
PsiMethod psiMethod) |
java.lang.String |
generateRenderedDoc(PsiElement element)
This is used to display rendered documentation in editor, in place of corresponding documentation comment's text.
|
static void |
generateTypeParameters(PsiTypeParameterListOwner typeParameterOwner,
java.lang.StringBuilder buffer) |
PsiElement |
getCustomDocumentationElement(Editor editor,
PsiFile file,
PsiElement contextElement,
int targetOffset)
Override this method if standard platform's choice for target PSI element to show documentation for (element either declared or
referenced at target offset) isn't suitable for your language.
|
PsiElement |
getDocumentationElementForLink(PsiManager psiManager,
java.lang.String link,
PsiElement context)
Returns the target element for a link in a documentation comment.
|
static java.util.List<java.lang.String> |
getExternalJavaDocUrl(PsiElement element) |
static java.util.Set<java.lang.String> |
getHtmlMethodSignatures(PsiMethod method,
LanguageLevel preferredFormat) |
static PsiDocComment |
getPackageInfoComment(PsiElement packageInfoFile) |
java.lang.String |
getQuickNavigateInfo(PsiElement element,
PsiElement originalElement)
Returns the text to show in the Ctrl-hover popup for the specified element.
|
java.util.List<java.lang.String> |
getUrlFor(PsiElement element,
PsiElement originalElement)
Returns the list of possible URLs to show as external documentation for the specified element.
|
boolean |
hasDocumentationFor(PsiElement element,
PsiElement originalElement)
Quick check for existence of external documentation for specified element.
|
Pair<PsiElement,PsiComment> |
parseContext(PsiElement startPoint)
Examines PSI hierarchy identified by the given 'start' element trying to find element which can be documented
and it's doc comment (if any).
|
void |
promptToConfigureDocumentation(PsiElement element)
Prompts the user to configure the external documentation for an element if none was found.
|
static void |
writeExtends(PsiClass aClass,
java.lang.StringBuilder buffer,
PsiClassType[] refs) |
static void |
writeImplements(PsiClass aClass,
java.lang.StringBuilder buffer,
PsiClassType[] refs) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgenerateHoverDoc, getDocumentationElementForLookupItempublic static final java.lang.String HTML_EXTENSION
public static final java.lang.String PACKAGE_SUMMARY_FILE
public java.lang.String getQuickNavigateInfo(PsiElement element, PsiElement originalElement)
DocumentationProvidergetQuickNavigateInfo in interface DocumentationProviderelement - the element for which the documentation is requested (for example, if the mouse is over
a method reference, this will be the method to which the reference is resolved).originalElement - the element under the mouse cursornull if the provider can't provide any documentation for this element. Documentation can contain
HTML markup. If HTML special characters need to be shown in popup, they should be properly escaped.public java.util.List<java.lang.String> getUrlFor(PsiElement element, PsiElement originalElement)
DocumentationProvidergetUrlFor in interface DocumentationProviderelement - the element for which the documentation is requested (for example, if the mouse is over
a method reference, this will be the method to which the reference is resolved).originalElement - the element under the mouse cursorExternalDocumentationProvider).
If the list contains a single URL, it will be opened.
If the list contains multiple URLs, the user will be prompted to choose one of them.
For ExternalDocumentationProvider, first URL, yielding non-empty result in
ExternalDocumentationProvider.fetchExternalDocumentation(Project, PsiElement, List) will be used.public static java.lang.String generateClassInfo(PsiClass aClass)
public static void writeImplements(PsiClass aClass, java.lang.StringBuilder buffer, PsiClassType[] refs)
public static void writeExtends(PsiClass aClass, java.lang.StringBuilder buffer, PsiClassType[] refs)
public static void generateTypeParameters(PsiTypeParameterListOwner typeParameterOwner, java.lang.StringBuilder buffer)
public static java.lang.String generateMethodInfo(PsiMethod method, PsiSubstitutor substitutor)
public PsiComment findExistingDocComment(PsiComment comment)
CodeDocumentationProviderfindExistingDocComment in interface CodeDocumentationProvidercomment - candidate psi commentpublic Pair<PsiElement,PsiComment> parseContext(PsiElement startPoint)
CodeDocumentationProvider
int test() {
return [caret] 1;
}
PSI element at the caret (return element) is an entry point. This method is expected to return PSI method element
and 'null' as the existing doc comment then.parseContext in interface CodeDocumentationProviderstartPoint - start traversal point'null' as an indication that no doc comment anchor and existing comment
is available;
returned pair must have non-null PSI element and nullable existing comment references thenpublic java.lang.String generateDocumentationContentStub(PsiComment _comment)
CodeDocumentationProvidergenerateDocumentationContentStub in interface CodeDocumentationProvider_comment - context psi commentpublic static void generateParametersTakingDocFromSuperMethods(java.lang.StringBuilder builder,
CodeDocumentationAwareCommenter commenter,
PsiMethod psiMethod)
public static void createTypeParamsListComment(java.lang.StringBuilder buffer,
CodeDocumentationAwareCommenter commenter,
PsiTypeParameterList typeParameterList)
public java.lang.String generateDoc(PsiElement element, PsiElement originalElement)
DocumentationProviderCallback for asking the doc provider for the complete documentation. Underlying implementation may be time-consuming, that's why this method is expected not to be called from EDT.
One can use DocumentationMarkup to get proper content layout. Typical sample will look like this:
DEFINITION_START + definition + DEFINITION_END +
CONTENT_START + main description + CONTENT_END +
SECTIONS_START +
SECTION_HEADER_START + section name +
SECTION_SEPARATOR + "<p>" + section content + SECTION_END +
... +
SECTIONS_END
To show different content on mouse hover in editor, DocumentationProvider.generateHoverDoc(PsiElement, PsiElement) should be implemented.generateDoc in interface DocumentationProviderelement - the element for which the documentation is requested (for example, if the mouse is over
a method reference, this will be the method to which the reference is resolved).originalElement - the element under the mouse cursornull if provider is unable to generate documentation
for the given elementpublic java.lang.String generateRenderedDoc(PsiElement element)
DocumentationProviderPsiDocCommentBase for this functionality to work.
Value returned by PsiDocCommentBase.getOwner() will be passed as element parameter to this method.generateRenderedDoc in interface DocumentationProviderDocumentationProvider.collectDocComments(PsiFile, Consumer)public void collectDocComments(PsiFile file, java.util.function.Consumer<PsiDocCommentBase> sink)
DocumentationProviderDocumentationProvider.generateRenderedDoc(PsiElement) method.collectDocComments in interface DocumentationProviderpublic static java.lang.String generateExternalJavadoc(PsiElement element)
public static java.lang.String generateExternalJavadoc(PsiElement element, java.util.List<java.lang.String> docURLs)
public static java.lang.String generateExternalJavadoc(PsiElement element, JavaDocInfoGenerator generator)
public static java.util.List<java.lang.String> getExternalJavaDocUrl(PsiElement element)
public static java.util.Set<java.lang.String> getHtmlMethodSignatures(PsiMethod method, LanguageLevel preferredFormat)
public static PsiDocComment getPackageInfoComment(PsiElement packageInfoFile)
public static java.util.List<java.lang.String> findUrlForClass(PsiClass aClass)
public static java.util.List<java.lang.String> findUrlForPackage(PsiPackage aPackage)
public PsiElement getDocumentationElementForLink(PsiManager psiManager, java.lang.String link, PsiElement context)
DocumentationProviderDocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL protocol.getDocumentationElementForLink in interface DocumentationProviderpsiManager - the PSI manager for the project in which the documentation is requested.link - the text of the link, not including the protocol.context - the element from which the navigation is performed.null if the link couldn't be resolved.DocumentationManagerUtil.createHyperlink(StringBuilder, String, String, boolean)public java.lang.String fetchExternalDocumentation(Project project, PsiElement element, java.util.List<java.lang.String> docUrls)
fetchExternalDocumentation in interface ExternalDocumentationProviderpublic boolean hasDocumentationFor(PsiElement element, PsiElement originalElement)
ExternalDocumentationProviderDocumentationProvider.getUrlFor(PsiElement, PsiElement).hasDocumentationFor in interface ExternalDocumentationProviderelement - the element to check for existence of documentationoriginalElement - the element at caret (on which the action was invoked)public boolean canPromptToConfigureDocumentation(PsiElement element)
ExternalDocumentationProvidercanPromptToConfigureDocumentation in interface ExternalDocumentationProviderelement - the element for which no documentation was foundpublic void promptToConfigureDocumentation(PsiElement element)
ExternalDocumentationProviderpromptToConfigureDocumentation in interface ExternalDocumentationProviderelement - the element for which no documentation was foundpublic PsiElement getCustomDocumentationElement(Editor editor, PsiFile file, PsiElement contextElement, int targetOffset)
DocumentationProviderPsiReference, but for which users might benefit from context help.getCustomDocumentationElement in interface DocumentationProvidercontextElement - the leaf PSI element in file at target offsettargetOffset - equals to caret offset for 'Quick Documentation' action, and to offset under mouse cursor for documentation shown
on mouse hovernull if it should be determined by standard platform's logic (default
behaviour)public static java.lang.String fetchExternalJavadoc(PsiElement element, Project project, java.util.List<java.lang.String> docURLs)
public static java.lang.String fetchExternalJavadoc(PsiElement element, java.util.List<java.lang.String> docURLs, JavaDocExternalFilter docFilter)