File tree 3 files changed +22
-2
lines changed
ghcide/src/Development/IDE/Plugin/Completions
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
462
462
ValD _ PatBind {pat_lhs} ->
463
463
[mkComp id CiVariable Nothing
464
464
| VarPat _ id <- listify (\ (_ :: Pat GhcPs ) -> True ) pat_lhs]
465
- TyClD _ ClassDecl {tcdLName, tcdSigs} ->
465
+ TyClD _ ClassDecl {tcdLName, tcdSigs, tcdATs } ->
466
466
mkComp tcdLName CiInterface (Just $ showForSnippet tcdLName) :
467
467
[ mkComp id CiFunction (Just $ showForSnippet typ)
468
468
| L _ (ClassOpSig _ _ ids typ) <- tcdSigs
469
- , id <- ids]
469
+ , id <- ids] ++
470
+ [ mkComp fdLName CiStruct (Just $ showForSnippet fdLName)
471
+ | L _ (FamilyDecl {fdLName}) <- tcdATs]
470
472
TyClD _ x ->
471
473
let generalCompls = [mkComp id cl (Just $ showForSnippet $ tyClDeclLName x)
472
474
| id <- listify (\ (_ :: LIdP GhcPs ) -> True ) x
Original file line number Diff line number Diff line change @@ -147,6 +147,16 @@ tests = testGroup "completions" [
147
147
item ^. label @?= " liftA"
148
148
item ^. kind @?= Just CiFunction
149
149
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
+
150
160
, contextTests
151
161
, snippetTests
152
162
]
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