@@ -47,7 +47,7 @@ prepareCallHierarchy state pluginId param
47
47
liftIO (runAction " CallHierarchy.prepareHierarchy" state (prepareCallHierarchyItem nfp pos)) >>=
48
48
\ case
49
49
Just items -> pure $ Right $ Just $ List items
50
- Nothing -> pure $ Left $ responseError " Call Hierarchy: No result "
50
+ Nothing -> pure $ Right Nothing
51
51
| otherwise = pure $ Left $ responseError $ T. pack $ " Call Hierarchy: uriToNormalizedFilePath failed for: " <> show uri
52
52
where
53
53
uri = param ^. (L. textDocument . L. uri)
@@ -67,23 +67,28 @@ constructFromAst nfp pos =
67
67
resolveIntoCallHierarchy :: Applicative f => HieASTs a -> Position -> NormalizedFilePath -> f (Maybe [CallHierarchyItem ])
68
68
resolveIntoCallHierarchy hf pos nfp =
69
69
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
72
75
73
76
extract :: HieAST a -> [(Identifier , S. Set ContextInfo , Span )]
74
77
extract ast = let span = nodeSpan ast
75
78
infos = M. toList $ M. map identInfo (Compat. getNodeIds ast)
76
79
in [ (ident, contexts, span ) | (ident, contexts) <- infos ]
77
80
78
81
recFieldInfo, 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]
87
92
88
93
construct :: NormalizedFilePath -> HieASTs a -> (Identifier , S. Set ContextInfo , Span ) -> Maybe CallHierarchyItem
89
94
construct nfp hf (ident, contexts, ssp)
@@ -93,6 +98,9 @@ construct nfp hf (ident, contexts, ssp)
93
98
-- ignored type span
94
99
= Just $ mkCallHierarchyItem' ident SkField ssp ssp
95
100
101
+ | isJust (matchBindInfo ctxList) && isNothing (valBindInfo ctxList)
102
+ = Just $ mkCallHierarchyItem' ident SkFunction ssp ssp
103
+
96
104
| Just ctx <- valBindInfo ctxList
97
105
= Just $ case ctx of
98
106
ValBind _ _ span -> mkCallHierarchyItem' ident SkFunction (renderSpan span ) ssp
0 commit comments