public interface DocumentationProvider
Extend AbstractDocumentationProvider
.
Modifier and Type | Field and Description |
---|---|
static ExtensionPointName<DocumentationProvider> |
EP_NAME
Please use
LanguageDocumentation instead of this for language-specific documentation |
Modifier and Type | Method and Description |
---|---|
default void |
collectDocComments(PsiFile file,
java.util.function.Consumer<PsiDocCommentBase> sink)
This defines documentation comments in file, which can be rendered in place.
|
default java.lang.String |
generateDoc(PsiElement element,
PsiElement originalElement)
Callback for asking the doc provider for the complete documentation.
|
default java.lang.String |
generateHoverDoc(PsiElement element,
PsiElement originalElement)
Same as
generateDoc(PsiElement, PsiElement) , but used for documentation showed on mouse hover in editor. |
default java.lang.String |
generateRenderedDoc(PsiElement element)
This is used to display rendered documentation in editor, in place of corresponding documentation comment's text.
|
default 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.
|
default PsiElement |
getDocumentationElementForLink(PsiManager psiManager,
java.lang.String link,
PsiElement context)
Returns the target element for a link in a documentation comment.
|
default PsiElement |
getDocumentationElementForLookupItem(PsiManager psiManager,
java.lang.Object object,
PsiElement element) |
default java.lang.String |
getQuickNavigateInfo(PsiElement element,
PsiElement originalElement)
Returns the text to show in the Ctrl-hover popup for the specified element.
|
default 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.
|
static final ExtensionPointName<DocumentationProvider> EP_NAME
LanguageDocumentation
instead of this for language-specific documentationdefault java.lang.String getQuickNavigateInfo(PsiElement element, PsiElement originalElement)
element
- 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.default java.util.List<java.lang.String> getUrlFor(PsiElement element, PsiElement originalElement)
element
- 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.default java.lang.String generateDoc(PsiElement element, PsiElement originalElement)
Callback 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_ENDTo show different content on mouse hover in editor,
generateHoverDoc(PsiElement, PsiElement)
should be implemented.element
- 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 elementdefault java.lang.String generateHoverDoc(PsiElement element, PsiElement originalElement)
generateDoc(PsiElement, PsiElement)
, but used for documentation showed on mouse hover in editor.
At the moment it's only invoked to get initial on-hover documentation. If user navigates any link in that documentation,
generateDoc(PsiElement, PsiElement)
will be used to fetch corresponding content.
default java.lang.String generateRenderedDoc(PsiElement element)
PsiDocCommentBase
for this functionality to work.
Value returned by PsiDocCommentBase.getOwner()
will be passed as element
parameter to this method.collectDocComments(PsiFile, Consumer)
default void collectDocComments(PsiFile file, java.util.function.Consumer<PsiDocCommentBase> sink)
generateRenderedDoc(PsiElement)
method.default PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, java.lang.Object object, PsiElement element)
default PsiElement getDocumentationElementForLink(PsiManager psiManager, java.lang.String link, PsiElement context)
DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL
protocol.psiManager
- 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)
default PsiElement getCustomDocumentationElement(Editor editor, PsiFile file, PsiElement contextElement, int targetOffset)
PsiReference
, but for which users might benefit from context help.targetOffset
- equals to caret offset for 'Quick Documentation' action, and to offset under mouse cursor for documentation shown
on mouse hovercontextElement
- the leaf PSI element in file
at target offsetnull
if it should be determined by standard platform's logic (default
behaviour)