diff --git a/platform/lang-api/src/com/intellij/lang/documentation/ExternalDocumentationHandler.java b/platform/lang-api/src/com/intellij/lang/documentation/ExternalDocumentationHandler.java index 358a83f7f88e..e801c9a9bccb 100644 --- a/platform/lang-api/src/com/intellij/lang/documentation/ExternalDocumentationHandler.java +++ b/platform/lang-api/src/com/intellij/lang/documentation/ExternalDocumentationHandler.java @@ -27,4 +27,17 @@ public interface ExternalDocumentationHandler { @NotNull String fetchExternalDocumentation(@NotNull String link, @Nullable PsiElement element); + + /** + * Defines whether we will show external documentation + * link at the bottom of the documentation pane or not. + * + * + * @return true if external documentation link should be + * shown, false otherwise + */ + default boolean canHandleExternal(@Nullable PsiElement element, + @Nullable PsiElement originalElement) { + return true; + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index 13ce2f3e2374..ef7400f7f828 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -990,10 +990,14 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr final PsiElement element = getElement(); if (element == null) return null; - String title = myManager.getTitle(element); final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element); + final PsiElement originalElement = DocumentationManager.getOriginalElement(element); + if (!shouldShowExternalDocumentationLink(provider, element, originalElement)) { + return null; + } + + final String title = myManager.getTitle(element); if (myEffectiveExternalUrl == null) { - final PsiElement originalElement = DocumentationManager.getOriginalElement(element); List urls = provider.getUrlFor(element, originalElement); if (urls != null) { boolean hasBadUrl = false; @@ -1036,6 +1040,21 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr return result.toString(); } + private static boolean shouldShowExternalDocumentationLink(DocumentationProvider provider, + PsiElement element, + PsiElement originalElement) { + if (provider instanceof CompositeDocumentationProvider) { + for (DocumentationProvider documentationProvider : ((CompositeDocumentationProvider)provider).getProviders()) { + if (documentationProvider instanceof ExternalDocumentationHandler) { + return ((ExternalDocumentationHandler)documentationProvider).canHandleExternal(element, originalElement); + } + } + } else if (provider instanceof ExternalDocumentationHandler) { + return ((ExternalDocumentationHandler)provider).canHandleExternal(element, originalElement); + } + return true; + } + private static String getHostname(String url) { try { return new URL(url).toURI().getHost();