rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 96 forks source link

No documentation in code completion #638

Open fantostisch opened 3 years ago

fantostisch commented 3 years ago

When using IntelliJ with other languages it is possible to press CTRL+Q to open the documentation for suggested completions. Example for Scala: scala

This does not seem to work with this plugin: intellisense

Even though the documentation is shown when the full function is written: documentation

rikvdkleij commented 3 years ago

Sorry, I don’t understand the issue. The documentation is shown in latest screenshot. Maybe the difference in layout confuses.

fantostisch commented 3 years ago

It would be nice if the documentation would be shown of what is suggested in the window. Someting like this: intellisense2

I will try to implement this

fantostisch commented 3 years ago

It looks like we have to add a PsiElement to every LookupElement. Doing someting like createLookupElement(_).withPsiElement(...) in https://github.com/rikvdkleij/intellij-haskell/blob/64ff54e04ec751edcd8f184a79c5eff4a775ae85/src/main/scala/intellij/haskell/editor/HaskellCompletionContributor.scala#L413 should work, but I have no idea were to get the right PsiElement from. This PsiElement will then be send to https://github.com/rikvdkleij/intellij-haskell/blob/8c3d788e80606c8fc598214ded5a5c1a03bff209/src/main/scala/intellij/haskell/external/component/HaskellDocumentationProvider.scala#L60 when pressing CTRL+Q.

rikvdkleij commented 3 years ago

I guess you can use this to find the element by using the module identifier: http://github.com/rikvdkleij/intellij-haskell/blob/4f561c252738d4359f6fe06f819ee154aebb3c6c/src/main/scala/intellij/haskell/navigation/HaskellReference.scala#L205-L205

Hopefully it doesn't affect the responsiveness.

fantostisch commented 3 years ago

When importing TVar using

import qualified Control.Concurrent.STM.TVar as TVar

Control.Concurrent.STM.TVar does export newTVar, but it is defined in GHC.Conc.Sync. This is a problem when using HaskellReference.findIdentifiersByModulesAndName, because but it returns a Left when called using

HaskellReference.findIdentifiersByModulesAndName(project, Seq("Control.Concurrent.STM.TVar"), "newTVar")

The following does work however:

HaskellReference.findIdentifiersByModulesAndName(project, Seq("GHC.Conc.Sync"), "newTVar")