File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
ghcide/src/Development/IDE/Plugin/Completions Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -462,11 +462,13 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
462462 ValD _ PatBind {pat_lhs} ->
463463 [mkComp id CiVariable Nothing
464464 | VarPat _ id <- listify (\ (_ :: Pat GhcPs ) -> True ) pat_lhs]
465- TyClD _ ClassDecl {tcdLName, tcdSigs} ->
465+ TyClD _ ClassDecl {tcdLName, tcdSigs, tcdATs } ->
466466 mkComp tcdLName CiInterface (Just $ showForSnippet tcdLName) :
467467 [ mkComp id CiFunction (Just $ showForSnippet typ)
468468 | L _ (ClassOpSig _ _ ids typ) <- tcdSigs
469- , id <- ids]
469+ , id <- ids] ++
470+ [ mkComp fdLName CiStruct (Just $ showForSnippet fdLName)
471+ | L _ (FamilyDecl {fdLName}) <- tcdATs]
470472 TyClD _ x ->
471473 let generalCompls = [mkComp id cl (Just $ showForSnippet $ tyClDeclLName x)
472474 | id <- listify (\ (_ :: LIdP GhcPs ) -> True ) x
Original file line number Diff line number Diff line change @@ -147,6 +147,16 @@ tests = testGroup "completions" [
147147 item ^. label @?= " liftA"
148148 item ^. kind @?= Just CiFunction
149149 item ^. detail @?= Just " Control.Applicative"
150+
151+ , testCase " completes locally defined associated type family" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
152+ doc <- openDoc " AssociatedTypeFamily.hs" " haskell"
153+
154+ compls <- getCompletions doc (Position 5 20 )
155+ item <- getCompletionByLabel " Fam" compls
156+ liftIO $ do
157+ item ^. label @?= " Fam"
158+ item ^. kind @?= Just CiStruct
159+
150160 , contextTests
151161 , snippetTests
152162 ]
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE TypeFamilies #-}
2+ module AssociatedTypeFamily () where
3+
4+ class C a where
5+ type Fam a
6+
7+ x :: C a => a -> Fam a
8+ x = undefined
You can’t perform that action at this time.
0 commit comments