mirror of
https://github.com/ilyakooo0/intellij-haskell.git
synced 2024-08-17 10:40:44 +03:00
Improve showing the documentation
This commit is contained in:
parent
0ad6468379
commit
2300421f08
@ -37,8 +37,7 @@ class HaskellDocumentationProvider extends AbstractDocumentationProvider {
|
||||
val originalPsiFile = e.getContainingFile.getOriginalFile
|
||||
val isSourceFile = HaskellProjectUtil.isSourceFile(originalPsiFile)
|
||||
val typeSignature = if (isSourceFile) {
|
||||
val typeInfo = TypeInfoComponent.findTypeInfoForElement(oe).toOption.map(_.typeSignature)
|
||||
typeInfo.map(StringUtil.escapeString)
|
||||
TypeInfoComponent.findTypeInfoForElement(oe).toOption.map(_.typeSignature).map(StringUtil.escapeString)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -72,17 +71,13 @@ class HaskellDocumentationProvider extends AbstractDocumentationProvider {
|
||||
HaskellPsiUtil.findQualifiedName(oe) match {
|
||||
case Some(qone) =>
|
||||
val presentationText = HaskellPsiUtil.findNamedElement(e).flatMap { ne =>
|
||||
if (HaskellPsiUtil.findExpression(ne).isDefined || HaskellPsiUtil.findTypeSignatureDeclaration(ne).isDefined) {
|
||||
None
|
||||
} else {
|
||||
Some(DoubleNbsp + "<code>" +
|
||||
HaskellPsiImplUtil.getItemPresentableText(ne, shortened = false).
|
||||
replace(" ", HtmlElement.Nbsp).
|
||||
replace("<", HtmlElement.Lt).
|
||||
replace(">", HtmlElement.Gt).
|
||||
replace("\n", HtmlElement.Break) +
|
||||
"</code>")
|
||||
}
|
||||
Some(DoubleNbsp + "<code>" +
|
||||
HaskellPsiImplUtil.getItemPresentableText(ne).
|
||||
replace(" ", HtmlElement.Nbsp).
|
||||
replace("<", HtmlElement.Lt).
|
||||
replace(">", HtmlElement.Gt).
|
||||
replace("\n", HtmlElement.Break) +
|
||||
"</code>")
|
||||
}
|
||||
|
||||
ProgressManager.checkCanceled()
|
||||
|
@ -231,11 +231,7 @@ object HaskellPsiImplUtil {
|
||||
HaskellPsiUtil.findNamedElement(element) match {
|
||||
case Some(namedElement) =>
|
||||
HaskellPsiUtil.findHighestDeclarationElement(element) match {
|
||||
case Some(de) if de.getIdentifierElements.exists(_ == namedElement) => HaskellPsiUtil.findDeclarationElement(namedElement).map(de => getDeclarationInfo(de, shortened)).
|
||||
orElse(HaskellPsiUtil.findExpression(namedElement).map(e => StringUtil.removeCommentsAndWhiteSpaces(e.getText))).
|
||||
getOrElse(s"${namedElement.getName} `in` ${getDeclarationInfo(de, shortened)}")
|
||||
case Some(de) => s"${namedElement.getName} `in` ${getDeclarationInfo(de, shortened)}"
|
||||
case _ if shortened && HaskellPsiUtil.findExpression(namedElement).isDefined => getContainingLineText(namedElement).getOrElse(namedElement.getName).trim
|
||||
case Some(de) => getDeclarationText(de)
|
||||
case _ => HaskellPsiUtil.findExpression(namedElement).map(_.getText).getOrElse(namedElement.getName)
|
||||
}
|
||||
case _ => element.getText
|
||||
|
Loading…
Reference in New Issue
Block a user