Skip to content

Use CiInterface/SkInterface for typeclass symbols #1592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ghcide/src/Development/IDE/LSP/Outline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ documentSymbolForDecl (L (RealSrcSpan l) (TyClD _ FamDecl { tcdFam = FamilyDecl
t -> " " <> t
)
, _detail = Just $ pprText fdInfo
, _kind = SkClass
, _kind = SkFunction
}
documentSymbolForDecl (L (RealSrcSpan l) (TyClD _ ClassDecl { tcdLName = L _ name, tcdSigs, tcdTyVars }))
= Just (defDocumentSymbol l :: DocumentSymbol)
Expand All @@ -78,7 +78,7 @@ documentSymbolForDecl (L (RealSrcSpan l) (TyClD _ ClassDecl { tcdLName = L _ nam
"" -> ""
t -> " " <> t
)
, _kind = SkClass
, _kind = SkInterface
, _detail = Just "class"
, _children =
Just $ List
Expand Down
6 changes: 3 additions & 3 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ occNameToComKind ty oc
| isTcOcc oc = case ty of
Just t
| "Constraint" `T.isSuffixOf` t
-> CiClass
-> CiInterface
_ -> CiStruct
| isDataOcc oc = CiConstructor
| otherwise = CiVariable
Expand Down Expand Up @@ -406,7 +406,7 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
[mkComp id CiVariable Nothing
| VarPat _ id <- listify (\(_ :: Pat GhcPs) -> True) pat_lhs]
TyClD _ ClassDecl{tcdLName, tcdSigs} ->
mkComp tcdLName CiClass Nothing :
mkComp tcdLName CiInterface Nothing :
[ mkComp id CiFunction (Just $ ppr typ)
| L _ (TypeSig _ ids typ) <- tcdSigs
, id <- ids]
Expand All @@ -428,7 +428,7 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
]

mkComp n ctyp ty =
CI ctyp pn (Right thisModName) ty pn Nothing doc (ctyp `elem` [CiStruct, CiClass]) Nothing
CI ctyp pn (Right thisModName) ty pn Nothing doc (ctyp `elem` [CiStruct, CiInterface]) Nothing
where
pn = ppr n
doc = SpanDocText (getDocumentation [pm] n) (SpanDocUris Nothing Nothing)
Expand Down
14 changes: 7 additions & 7 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3768,7 +3768,7 @@ topLevelCompletionTests = [
"class"
["bar :: Xx", "xxx = ()", "-- | haddock", "class Xxx a"]
(Position 0 9)
[("Xxx", CiClass, "Xxx", False, True, Nothing)],
[("Xxx", CiInterface, "Xxx", False, True, Nothing)],
completionTest
"records"
["data Person = Person { _personName:: String, _personAge:: Int}", "bar = Person { _pers }" ]
Expand Down Expand Up @@ -3862,7 +3862,7 @@ nonLocalCompletionTests =
"type"
["{-# OPTIONS_GHC -Wall #-}", "module A () where", "f :: Bo", "f = True"]
(Position 2 7)
[ ("Bounded", CiClass, "Bounded ${1:*}", True, True, Nothing),
[ ("Bounded", CiInterface, "Bounded ${1:*}", True, True, Nothing),
("Bool", CiStruct, "Bool ", True, True, Nothing)
],
completionTest
Expand Down Expand Up @@ -4163,7 +4163,7 @@ outlineTests = testGroup
let source = T.unlines ["{-# language TypeFamilies #-}", "type family A"]
docId <- createDoc "A.hs" "haskell" source
symbols <- getDocumentSymbols docId
liftIO $ symbols @?= Left [docSymbolD "A" "type family" SkClass (R 1 0 1 13)]
liftIO $ symbols @?= Left [docSymbolD "A" "type family" SkFunction (R 1 0 1 13)]
, testSessionWait "type family instance " $ do
let source = T.unlines
[ "{-# language TypeFamilies #-}"
Expand All @@ -4173,14 +4173,14 @@ outlineTests = testGroup
docId <- createDoc "A.hs" "haskell" source
symbols <- getDocumentSymbols docId
liftIO $ symbols @?= Left
[ docSymbolD "A a" "type family" SkClass (R 1 0 1 15)
[ docSymbolD "A a" "type family" SkFunction (R 1 0 1 15)
, docSymbol "A ()" SkInterface (R 2 0 2 23)
]
, testSessionWait "data family" $ do
let source = T.unlines ["{-# language TypeFamilies #-}", "data family A"]
docId <- createDoc "A.hs" "haskell" source
symbols <- getDocumentSymbols docId
liftIO $ symbols @?= Left [docSymbolD "A" "data family" SkClass (R 1 0 1 11)]
liftIO $ symbols @?= Left [docSymbolD "A" "data family" SkFunction (R 1 0 1 11)]
, testSessionWait "data family instance " $ do
let source = T.unlines
[ "{-# language TypeFamilies #-}"
Expand All @@ -4190,7 +4190,7 @@ outlineTests = testGroup
docId <- createDoc "A.hs" "haskell" source
symbols <- getDocumentSymbols docId
liftIO $ symbols @?= Left
[ docSymbolD "A a" "data family" SkClass (R 1 0 1 11)
[ docSymbolD "A a" "data family" SkFunction (R 1 0 1 11)
, docSymbol "A ()" SkInterface (R 2 0 2 25)
]
, testSessionWait "constant" $ do
Expand Down Expand Up @@ -4304,7 +4304,7 @@ outlineTests = testGroup
(Just $ List cc)
classSymbol name loc cc = DocumentSymbol name
(Just "class")
SkClass
SkInterface
Nothing
loc
loc
Expand Down