public class CompositeDocumentationProvider extends java.lang.Object implements DocumentationProvider, ExternalDocumentationProvider, ExternalDocumentationHandler
EP_NAME
Modifier and Type | Method and Description |
---|---|
boolean |
canFetchDocumentationLink(java.lang.String link) |
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.
|
java.lang.String |
fetchExternalDocumentation(Project project,
PsiElement element,
java.util.List<java.lang.String> docUrls) |
java.lang.String |
fetchExternalDocumentation(java.lang.String link,
PsiElement element) |
java.lang.String |
generateDoc(PsiElement element,
PsiElement originalElement)
Callback for asking the doc provider for the complete documentation.
|
java.lang.String |
generateHoverDoc(PsiElement element,
PsiElement originalElement)
Same as
DocumentationProvider.generateDoc(PsiElement, PsiElement) , but used for documentation showed on mouse hover in editor. |
java.lang.String |
generateRenderedDoc(PsiElement element)
This is used to display rendered documentation in editor, in place of corresponding documentation comment's text.
|
java.util.List<DocumentationProvider> |
getAllProviders() |
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.
|
PsiElement |
getDocumentationElementForLookupItem(PsiManager psiManager,
java.lang.Object object,
PsiElement element) |
CodeDocumentationProvider |
getFirstCodeDocumentationProvider() |
java.util.List<DocumentationProvider> |
getProviders() |
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 |
handleExternal(PsiElement element,
PsiElement originalElement) |
boolean |
handleExternalLink(PsiManager psiManager,
java.lang.String link,
PsiElement context) |
boolean |
hasDocumentationFor(PsiElement element,
PsiElement originalElement)
Quick check for existence of external documentation for specified element.
|
static boolean |
hasUrlsFor(DocumentationProvider provider,
PsiElement element,
PsiElement originalElement) |
void |
promptToConfigureDocumentation(PsiElement element)
Prompts the user to configure the external documentation for an element if none was found.
|
java.lang.String |
toString() |
static DocumentationProvider |
wrapProviders(java.util.Collection<? extends DocumentationProvider> providers) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canHandleExternal, extractRefFromLink
public static DocumentationProvider wrapProviders(java.util.Collection<? extends DocumentationProvider> providers)
public java.util.List<DocumentationProvider> getAllProviders()
public java.util.List<DocumentationProvider> getProviders()
public boolean handleExternal(PsiElement element, PsiElement originalElement)
handleExternal
in interface ExternalDocumentationHandler
public boolean handleExternalLink(PsiManager psiManager, java.lang.String link, PsiElement context)
handleExternalLink
in interface ExternalDocumentationHandler
public boolean canFetchDocumentationLink(java.lang.String link)
canFetchDocumentationLink
in interface ExternalDocumentationHandler
public java.lang.String fetchExternalDocumentation(java.lang.String link, PsiElement element)
fetchExternalDocumentation
in interface ExternalDocumentationHandler
public java.lang.String getQuickNavigateInfo(PsiElement element, PsiElement originalElement)
DocumentationProvider
getQuickNavigateInfo
in interface DocumentationProvider
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.public java.util.List<java.lang.String> getUrlFor(PsiElement element, PsiElement originalElement)
DocumentationProvider
getUrlFor
in interface DocumentationProvider
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.public java.lang.String generateDoc(PsiElement element, PsiElement originalElement)
DocumentationProvider
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,
DocumentationProvider.generateHoverDoc(PsiElement, PsiElement)
should be implemented.generateDoc
in interface DocumentationProvider
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 elementpublic java.lang.String generateHoverDoc(PsiElement element, PsiElement originalElement)
DocumentationProvider
DocumentationProvider.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,
DocumentationProvider.generateDoc(PsiElement, PsiElement)
will be used to fetch corresponding content.
generateHoverDoc
in interface DocumentationProvider
public java.lang.String generateRenderedDoc(PsiElement element)
DocumentationProvider
PsiDocCommentBase
for this functionality to work.
Value returned by PsiDocCommentBase.getOwner()
will be passed as element
parameter to this method.generateRenderedDoc
in interface DocumentationProvider
DocumentationProvider.collectDocComments(PsiFile, Consumer)
public void collectDocComments(PsiFile file, java.util.function.Consumer<PsiDocCommentBase> sink)
DocumentationProvider
DocumentationProvider.generateRenderedDoc(PsiElement)
method.collectDocComments
in interface DocumentationProvider
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, java.lang.Object object, PsiElement element)
getDocumentationElementForLookupItem
in interface DocumentationProvider
public PsiElement getDocumentationElementForLink(PsiManager psiManager, java.lang.String link, PsiElement context)
DocumentationProvider
DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL
protocol.getDocumentationElementForLink
in interface DocumentationProvider
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)
public CodeDocumentationProvider getFirstCodeDocumentationProvider()
public java.lang.String fetchExternalDocumentation(Project project, PsiElement element, java.util.List<java.lang.String> docUrls)
fetchExternalDocumentation
in interface ExternalDocumentationProvider
public boolean hasDocumentationFor(PsiElement element, PsiElement originalElement)
ExternalDocumentationProvider
DocumentationProvider.getUrlFor(PsiElement, PsiElement)
.hasDocumentationFor
in interface ExternalDocumentationProvider
element
- the element to check for existence of documentationoriginalElement
- the element at caret (on which the action was invoked)public boolean canPromptToConfigureDocumentation(PsiElement element)
ExternalDocumentationProvider
canPromptToConfigureDocumentation
in interface ExternalDocumentationProvider
element
- the element for which no documentation was foundpublic void promptToConfigureDocumentation(PsiElement element)
ExternalDocumentationProvider
promptToConfigureDocumentation
in interface ExternalDocumentationProvider
element
- the element for which no documentation was foundpublic static boolean hasUrlsFor(DocumentationProvider provider, PsiElement element, PsiElement originalElement)
public PsiElement getCustomDocumentationElement(Editor editor, PsiFile file, PsiElement contextElement, int targetOffset)
DocumentationProvider
PsiReference
, but for which users might benefit from context help.getCustomDocumentationElement
in interface DocumentationProvider
contextElement
- 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 java.lang.String toString()
toString
in class java.lang.Object