Skip to content

Commit aad6401

Browse files
fwcdAilrun
andauthored
Use CiInterface/SkInterface for typeclass symbols (#1592)
* Use CiInterface instead of CiClass for completion items * Use SkInterface instead of SkClass for typeclass symbols * Fix SkClass icon for type family symbol * Use SkFunction for type families Co-authored-by: Junyoung/Clare Jang <[email protected]>
1 parent b3cf33f commit aad6401

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

ghcide/src/Development/IDE/LSP/Outline.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ documentSymbolForDecl (L (RealSrcSpan l) (TyClD _ FamDecl { tcdFam = FamilyDecl
6969
t -> " " <> t
7070
)
7171
, _detail = Just $ pprText fdInfo
72-
, _kind = SkClass
72+
, _kind = SkFunction
7373
}
7474
documentSymbolForDecl (L (RealSrcSpan l) (TyClD _ ClassDecl { tcdLName = L _ name, tcdSigs, tcdTyVars }))
7575
= Just (defDocumentSymbol l :: DocumentSymbol)
@@ -78,7 +78,7 @@ documentSymbolForDecl (L (RealSrcSpan l) (TyClD _ ClassDecl { tcdLName = L _ nam
7878
"" -> ""
7979
t -> " " <> t
8080
)
81-
, _kind = SkClass
81+
, _kind = SkInterface
8282
, _detail = Just "class"
8383
, _children =
8484
Just $ List

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ occNameToComKind ty oc
145145
| isTcOcc oc = case ty of
146146
Just t
147147
| "Constraint" `T.isSuffixOf` t
148-
-> CiClass
148+
-> CiInterface
149149
_ -> CiStruct
150150
| isDataOcc oc = CiConstructor
151151
| otherwise = CiVariable
@@ -406,7 +406,7 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
406406
[mkComp id CiVariable Nothing
407407
| VarPat _ id <- listify (\(_ :: Pat GhcPs) -> True) pat_lhs]
408408
TyClD _ ClassDecl{tcdLName, tcdSigs} ->
409-
mkComp tcdLName CiClass Nothing :
409+
mkComp tcdLName CiInterface Nothing :
410410
[ mkComp id CiFunction (Just $ ppr typ)
411411
| L _ (TypeSig _ ids typ) <- tcdSigs
412412
, id <- ids]
@@ -428,7 +428,7 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
428428
]
429429

430430
mkComp n ctyp ty =
431-
CI ctyp pn (Right thisModName) ty pn Nothing doc (ctyp `elem` [CiStruct, CiClass]) Nothing
431+
CI ctyp pn (Right thisModName) ty pn Nothing doc (ctyp `elem` [CiStruct, CiInterface]) Nothing
432432
where
433433
pn = ppr n
434434
doc = SpanDocText (getDocumentation [pm] n) (SpanDocUris Nothing Nothing)

ghcide/test/exe/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,7 +3768,7 @@ topLevelCompletionTests = [
37683768
"class"
37693769
["bar :: Xx", "xxx = ()", "-- | haddock", "class Xxx a"]
37703770
(Position 0 9)
3771-
[("Xxx", CiClass, "Xxx", False, True, Nothing)],
3771+
[("Xxx", CiInterface, "Xxx", False, True, Nothing)],
37723772
completionTest
37733773
"records"
37743774
["data Person = Person { _personName:: String, _personAge:: Int}", "bar = Person { _pers }" ]
@@ -3862,7 +3862,7 @@ nonLocalCompletionTests =
38623862
"type"
38633863
["{-# OPTIONS_GHC -Wall #-}", "module A () where", "f :: Bo", "f = True"]
38643864
(Position 2 7)
3865-
[ ("Bounded", CiClass, "Bounded ${1:*}", True, True, Nothing),
3865+
[ ("Bounded", CiInterface, "Bounded ${1:*}", True, True, Nothing),
38663866
("Bool", CiStruct, "Bool ", True, True, Nothing)
38673867
],
38683868
completionTest
@@ -4163,7 +4163,7 @@ outlineTests = testGroup
41634163
let source = T.unlines ["{-# language TypeFamilies #-}", "type family A"]
41644164
docId <- createDoc "A.hs" "haskell" source
41654165
symbols <- getDocumentSymbols docId
4166-
liftIO $ symbols @?= Left [docSymbolD "A" "type family" SkClass (R 1 0 1 13)]
4166+
liftIO $ symbols @?= Left [docSymbolD "A" "type family" SkFunction (R 1 0 1 13)]
41674167
, testSessionWait "type family instance " $ do
41684168
let source = T.unlines
41694169
[ "{-# language TypeFamilies #-}"
@@ -4173,14 +4173,14 @@ outlineTests = testGroup
41734173
docId <- createDoc "A.hs" "haskell" source
41744174
symbols <- getDocumentSymbols docId
41754175
liftIO $ symbols @?= Left
4176-
[ docSymbolD "A a" "type family" SkClass (R 1 0 1 15)
4176+
[ docSymbolD "A a" "type family" SkFunction (R 1 0 1 15)
41774177
, docSymbol "A ()" SkInterface (R 2 0 2 23)
41784178
]
41794179
, testSessionWait "data family" $ do
41804180
let source = T.unlines ["{-# language TypeFamilies #-}", "data family A"]
41814181
docId <- createDoc "A.hs" "haskell" source
41824182
symbols <- getDocumentSymbols docId
4183-
liftIO $ symbols @?= Left [docSymbolD "A" "data family" SkClass (R 1 0 1 11)]
4183+
liftIO $ symbols @?= Left [docSymbolD "A" "data family" SkFunction (R 1 0 1 11)]
41844184
, testSessionWait "data family instance " $ do
41854185
let source = T.unlines
41864186
[ "{-# language TypeFamilies #-}"
@@ -4190,7 +4190,7 @@ outlineTests = testGroup
41904190
docId <- createDoc "A.hs" "haskell" source
41914191
symbols <- getDocumentSymbols docId
41924192
liftIO $ symbols @?= Left
4193-
[ docSymbolD "A a" "data family" SkClass (R 1 0 1 11)
4193+
[ docSymbolD "A a" "data family" SkFunction (R 1 0 1 11)
41944194
, docSymbol "A ()" SkInterface (R 2 0 2 25)
41954195
]
41964196
, testSessionWait "constant" $ do
@@ -4304,7 +4304,7 @@ outlineTests = testGroup
43044304
(Just $ List cc)
43054305
classSymbol name loc cc = DocumentSymbol name
43064306
(Just "class")
4307-
SkClass
4307+
SkInterface
43084308
Nothing
43094309
loc
43104310
loc

0 commit comments

Comments
 (0)