@@ -47,7 +47,7 @@ prepareCallHierarchy state pluginId param
4747 liftIO (runAction " CallHierarchy.prepareHierarchy" state (prepareCallHierarchyItem nfp pos)) >>=
4848 \ case
4949 Just items -> pure $ Right $ Just $ List items
50- Nothing -> pure $ Left $ responseError " Call Hierarchy: No result "
50+ Nothing -> pure $ Right Nothing
5151 | otherwise = pure $ Left $ responseError $ T. pack $ " Call Hierarchy: uriToNormalizedFilePath failed for: " <> show uri
5252 where
5353 uri = param ^. (L. textDocument . L. uri)
@@ -67,23 +67,28 @@ constructFromAst nfp pos =
6767resolveIntoCallHierarchy :: Applicative f => HieASTs a -> Position -> NormalizedFilePath -> f (Maybe [CallHierarchyItem ])
6868resolveIntoCallHierarchy hf pos nfp =
6969 case listToMaybe $ pointCommand hf pos extract of
70- Just res -> pure $ Just $ mapMaybe (construct nfp hf) res
71- Nothing -> pure Nothing
70+ Nothing -> pure Nothing
71+ Just infos ->
72+ case mapMaybe (construct nfp hf) infos of
73+ [] -> pure Nothing
74+ res -> pure $ Just res
7275
7376extract :: HieAST a -> [(Identifier , S. Set ContextInfo , Span )]
7477extract ast = let span = nodeSpan ast
7578 infos = M. toList $ M. map identInfo (Compat. getNodeIds ast)
7679 in [ (ident, contexts, span ) | (ident, contexts) <- infos ]
7780
7881recFieldInfo, declInfo, valBindInfo, classTyDeclInfo,
79- useInfo , patternBindInfo , tyDeclInfo :: [ContextInfo ] -> Maybe ContextInfo
80- recFieldInfo ctxs = listToMaybe [ctx | ctx@ RecField {} <- ctxs]
81- declInfo ctxs = listToMaybe [ctx | ctx@ Decl {} <- ctxs]
82- valBindInfo ctxs = listToMaybe [ctx | ctx@ ValBind {} <- ctxs]
83- classTyDeclInfo ctxs = listToMaybe [ctx | ctx@ ClassTyDecl {} <- ctxs]
84- useInfo ctxs = listToMaybe [Use | Use <- ctxs]
85- patternBindInfo ctxs = listToMaybe [ctx | ctx@ PatternBind {} <- ctxs]
86- tyDeclInfo ctxs = listToMaybe [TyDecl | TyDecl <- ctxs]
82+ useInfo, patternBindInfo, tyDeclInfo, matchBindInfo
83+ :: [ContextInfo ] -> Maybe ContextInfo
84+ recFieldInfo ctxs = listToMaybe [ctx | ctx@ RecField {} <- ctxs]
85+ declInfo ctxs = listToMaybe [ctx | ctx@ Decl {} <- ctxs]
86+ valBindInfo ctxs = listToMaybe [ctx | ctx@ ValBind {} <- ctxs]
87+ classTyDeclInfo ctxs = listToMaybe [ctx | ctx@ ClassTyDecl {} <- ctxs]
88+ useInfo ctxs = listToMaybe [Use | Use <- ctxs]
89+ patternBindInfo ctxs = listToMaybe [ctx | ctx@ PatternBind {} <- ctxs]
90+ tyDeclInfo ctxs = listToMaybe [TyDecl | TyDecl <- ctxs]
91+ matchBindInfo ctxs = listToMaybe [MatchBind | MatchBind <- ctxs]
8792
8893construct :: NormalizedFilePath -> HieASTs a -> (Identifier , S. Set ContextInfo , Span ) -> Maybe CallHierarchyItem
8994construct nfp hf (ident, contexts, ssp)
@@ -93,6 +98,9 @@ construct nfp hf (ident, contexts, ssp)
9398 -- ignored type span
9499 = Just $ mkCallHierarchyItem' ident SkField ssp ssp
95100
101+ | isJust (matchBindInfo ctxList) && isNothing (valBindInfo ctxList)
102+ = Just $ mkCallHierarchyItem' ident SkFunction ssp ssp
103+
96104 | Just ctx <- valBindInfo ctxList
97105 = Just $ case ctx of
98106 ValBind _ _ span -> mkCallHierarchyItem' ident SkFunction (renderSpan span ) ssp
0 commit comments