From cecc888790b1246a5cd79aa986e19016c4476c6c Mon Sep 17 00:00:00 2001 From: Rik van der Kleij Date: Tue, 24 Jul 2018 21:46:06 +0200 Subject: [PATCH] Do not show presentation for expression and type signature. --- .../HaskellDocumentationProvider.scala | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main/scala/intellij/haskell/external/component/HaskellDocumentationProvider.scala b/src/main/scala/intellij/haskell/external/component/HaskellDocumentationProvider.scala index ebbd3e3a3..5b5e1dd8c 100644 --- a/src/main/scala/intellij/haskell/external/component/HaskellDocumentationProvider.scala +++ b/src/main/scala/intellij/haskell/external/component/HaskellDocumentationProvider.scala @@ -32,7 +32,7 @@ class HaskellDocumentationProvider extends AbstractDocumentationProvider { (Option(element), Option(originalElement)) match { case (Some(e), Some(oe)) => val psiFile = Option(e.getContainingFile) - val moduleName = psiFile.flatMap(HaskellPsiUtil.findModuleName) + val moduleName = psiFile.flatMap(HaskellPsiUtil.findModuleName) val originalPsiFile = Option(oe.getContainingFile) val projectFile = originalPsiFile.exists(HaskellProjectUtil.isProjectFile) val typeSignature = if (projectFile) { @@ -63,31 +63,33 @@ class HaskellDocumentationProvider extends AbstractDocumentationProvider { (Option(element), Option(originalElement)) match { case (Some(e), Some(oe)) => val project = e.getProject - val definedInSameFile = Option(e.getContainingFile) == Option(oe.getContainingFile) if (e.isInstanceOf[PsiFile]) { getQuickNavigateInfo(e, oe) } else { - HaskellPsiUtil.findQualifiedNameParent(oe) match { - case Some(qone) => - val presentationText = HaskellPsiUtil.findNamedElement(e).map { ne => - Separator + "" + - HaskellPsiImplUtil.getItemPresentableText(ne, shortened = false). - replace(" ", HtmlElement.Nbsp). - replace("<", HtmlElement.Lt). - replace(">", HtmlElement.Gt). - replace("\n", HtmlElement.Break) + - "" - }.getOrElse("") + val definedInSameFile = Option(e.getContainingFile) == Option(oe.getContainingFile) + if (definedInSameFile) { + getQuickNavigateInfo(e, oe) + } else { + HaskellPsiUtil.findQualifiedNameParent(oe) match { + case Some(qone) => + val presentationText = HaskellPsiUtil.findNamedElement(e).flatMap { ne => + if (HaskellPsiUtil.findExpressionParent(ne).isDefined || HaskellPsiUtil.findTypeSignatureDeclarationParent(ne).isDefined) { + None + } else { + Some(DoubleNbsp + "" + + HaskellPsiImplUtil.getItemPresentableText(ne, shortened = false). + replace(" ", HtmlElement.Nbsp). + replace("<", HtmlElement.Lt). + replace(">", HtmlElement.Gt). + replace("\n", HtmlElement.Break) + + "") + } + } - val documentationText = if (definedInSameFile) { - "" - } else { - Separator + HoogleComponent.findDocumentation(project, qone).getOrElse("No documentation found") - } - - getQuickNavigateInfo(e, oe) + presentationText + documentationText - - case _ => getQuickNavigateInfo(e, oe) + val documentationText = HoogleComponent.findDocumentation(project, qone).getOrElse("No documentation found") + (documentationText + Separator + getQuickNavigateInfo(e, oe) + presentationText.map(t => Separator + t).getOrElse("")) + Separator + case _ => getQuickNavigateInfo(e, oe) + } } } case _ => null