Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Development.IDE.Core.PluginUtils (runIdeActionE,
import Development.IDE.Core.PositionMapping (fromCurrentPosition)
import Development.IDE.GHC.Compat (FastStringCompat, Name,
RealSrcSpan,
generatedNodeInfo,
getSourceNodeIds,
isAnnotationInNodeInfo,
mkRealSrcLoc,
Expand Down Expand Up @@ -295,11 +296,19 @@ getNodeNameAndTypes hieKind hieAst =
Nothing -> Nothing
Just name ->
let mTypeOfName = identType identifierDetails
-- types from the source NodeInfo
Comment thread
vidit-od marked this conversation as resolved.
typesOfNode = case sourceNodeInfo hieAst of
Nothing -> []
Just nodeInfo -> nodeType nodeInfo
-- fall back to generated NodeInfo when source has no types
typesOfGeneratedNode = case generatedNodeInfo hieAst of
Nothing -> []
Just nodeInfo -> nodeType nodeInfo
allTypes = case mTypeOfName of
Nothing -> typesOfNode
Nothing ->
case typesOfNode of
[] -> typesOfGeneratedNode
ts -> ts
-- (the last?) one type of 'typesOfNode' may (always?) be the same as 'typeOfName'
-- To avoid generating two identical signature helps, we do a filtering here
-- This is similar to 'dropEnd1' in Development.IDE.Spans.AtPoint.atPoint
Expand Down
15 changes: 15 additions & 0 deletions plugins/hls-signature-help-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,21 @@ main =
Nothing,
Nothing,
Just $ SimilarSignatureHelp $ SignatureHelp [SignatureInformation "f :: forall a b c. a -> b -> c" Nothing (Just [ParameterInformation (InR (19, 20)) Nothing, ParameterInformation (InR (24, 25)) Nothing]) (Just (InL 0))] (Just 0) (Just (InL 0))
],
-- Prevents https://github.com/haskell/haskell-language-server/issues/4769
mkTest
"inside do block"
[__i|
f :: Int -> Int -> Int
f = _
test :: IO ()
test = do
x <- pure 1
Comment thread
vidit-od marked this conversation as resolved.
print (f x 2)
^ ^
|]
[ Just $ SimilarSignatureHelp $ SignatureHelp [SignatureInformation "f :: Int -> Int -> Int" Nothing (Just [ParameterInformation (InR (5, 8)) Nothing, ParameterInformation (InR (12, 15)) Nothing]) (Just (InL 0))] (Just 0) (Just (InL 0)),
Just $ SimilarSignatureHelp $ SignatureHelp [SignatureInformation "f :: Int -> Int -> Int" Nothing (Just [ParameterInformation (InR (5, 8)) Nothing, ParameterInformation (InR (12, 15)) Nothing]) (Just (InL 1))] (Just 0) (Just (InL 1))
]
]

Expand Down
Loading