Skip to content

Commit b79ff61

Browse files
committed
Fix broken tests for signatures
1 parent a66a6c5 commit b79ff61

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

plugins/hls-call-hierarchy-plugin/src/Ide/Plugin/CallHierarchy/Internal.hs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import qualified Data.HashMap.Strict as HM
2323
import Data.List (groupBy, sortBy)
2424
import qualified Data.Map as M
2525
import Data.Maybe
26+
import Data.Monoid
2627
import qualified Data.Set as S
2728
import qualified Data.Text as T
2829
import qualified Data.Text.Encoding as T
@@ -146,12 +147,27 @@ construct nfp hf (ident, contexts, ssp)
146147

147148
renderTyDecl = case ident of
148149
Left _ -> Nothing
149-
Right name -> case getNameBindingInClass name ssp (getAsts hf) of
150+
Right name -> case getNameBindingInClass' name ssp (getAsts hf) of
150151
Nothing -> Nothing
151152
Just sp -> case resolveIntoCallHierarchy hf (realSrcSpanToRange sp ^. L.start) nfp of
152153
Just (Just items) -> listToMaybe items
153154
_ -> Nothing
154155

156+
getNameBindingInClass'
157+
:: Name
158+
-> Span
159+
-> M.Map HiePath (HieAST a)
160+
-> Maybe Span
161+
getNameBindingInClass' n sp asts = do
162+
ast <- M.lookup (HiePath (srcSpanFile sp)) asts
163+
clsNode <- selectSmallestContaining sp ast
164+
getFirst $ foldMap First $ do
165+
child <- flattenAst ast
166+
dets <- maybeToList
167+
$ M.lookup (Right n) $ sourcedNodeIdents $ sourcedNodeInfo child
168+
let binding = foldMap (First . getBindSiteFromContext) (identInfo dets)
169+
return (getFirst binding)
170+
155171
mkCallHierarchyItem :: NormalizedFilePath -> Identifier -> SymbolKind -> Span -> Span -> CallHierarchyItem
156172
mkCallHierarchyItem nfp ident kind span selSpan =
157173
CallHierarchyItem

plugins/hls-call-hierarchy-plugin/test/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ prepareCallHierarchyTests =
166166
expected = mkCallHierarchyItemC "A" SkConstructor range selRange
167167
oneCaseWithCreate contents 1 13 expected
168168
, testGroup "type signature"
169-
[ knownBrokenForGhcVersions [GHC94] "type signature broken" $ testCase "next line" $ do
169+
[ testCase "next line" $ do
170170
let contents = T.unlines ["a::Int", "a=3"]
171171
range = mkRange 1 0 1 3
172172
selRange = mkRange 1 0 1 1
173173
expected = mkCallHierarchyItemV "a" SkFunction range selRange
174174
oneCaseWithCreate contents 0 0 expected
175-
, knownBrokenForGhcVersions [GHC94] "type signature broken" $ testCase "multi functions" $ do
175+
, testCase "multi functions" $ do
176176
let contents = T.unlines [ "a,b::Int", "a=3", "b=4"]
177177
range = mkRange 2 0 2 3
178178
selRange = mkRange 2 0 2 1

0 commit comments

Comments
 (0)