Skip to content

Commit 440fc1f

Browse files
jacgaherrmann-da
authored andcommitted
Add goto def / hover tests for classes (#177)
+ internal class in instance declaration + internal class in type signature + external class in type signature Hover seems not to work for classes at all. Goto def works for internal classes, but not external ones. This leaves the table looking like this: | | find definition | hover | |-------------|-----------|---------| | field in record definition | ✔️ | ✔️ | | field in record construction | ❌ | ❌ | | field name as accessor | ✔️ | ✔️ | | top level name | ✔️ | ✔️ | | record data constructor | ❌ | ❌ | | plain data constructor | ✔️ | ✔️ | | type constructor | ✔️ | ❌ | | external type constructor | ❌ | ❌ | | external value | ❌ | ✔️ | | plain parameter | ✔️ | ✔️ | | pattern match name | ✔️ | ✔️ | | top level operator | ✔️ | ✔️ | | parameter operator | ✔️ | ✔️ | | name in backticks | ✔️ | ✔️ | | class in instance declaration | ✔️ | ❌ | | class in signature | ✔️ | ❌ | | external class in signature | ❌ | ❌ |
1 parent 5645a80 commit 440fc1f

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

test/data/GotoHover.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ a +! b = a - b
1919
hhh (Just a) (><) = a >< a
2020
iii a b = a `b` a
2121
jjj s = pack $ s <> s
22+
class Class a where
23+
method :: a -> Int
24+
instance Class Int where
25+
method = succ
26+
kkk :: Class a => Int -> a -> Int
27+
kkk n c = n + method c

test/exe/Main.hs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,9 @@ findDefinitionAndHoverTests = let
781781
aL18 = Position 18 20 ; apmp = [mkR 18 10 18 11]
782782
b'L19 = Position 19 13 ; bp = [mkR 19 6 19 7]
783783
xvL20 = Position 20 8 ; xvMsg = [ExpectHoverText ["Data.Text.pack", ":: String -> Text"], ExpectExternFail]
784-
784+
clL23 = Position 23 11 ; cls = [mkR 21 0 22 20]
785+
clL25 = Position 25 9
786+
eclL15 = Position 15 8 ; ecls = [ExpectHoverText ["Num"], ExpectExternFail]
785787
in
786788
mkFindTests
787789
-- def hover look expect
@@ -793,12 +795,15 @@ findDefinitionAndHoverTests = let
793795
, test yes yes dcL12 tcDC "plain data constructor" -- 121
794796
, test yes broken tcL6 tcData "type constructor" -- 147
795797
, test broken broken xtcL5 xtc "type constructor from other package"
796-
, test broken yes xvL20 xvMsg "value from other package"
797-
, test yes yes vvL16 vv "plain parameter"
798-
, test yes yes aL18 apmp "pattern match name"
799-
, test yes yes opL16 op "top-level operator" -- 123
800-
, test yes yes opL18 opp "parameter operator"
801-
, test yes yes b'L19 bp "name in backticks"
798+
, test broken yes xvL20 xvMsg "value from other package" -- 120
799+
, test yes yes vvL16 vv "plain parameter" -- 120
800+
, test yes yes aL18 apmp "pattern match name" -- 120
801+
, test yes yes opL16 op "top-level operator" -- 120, 123
802+
, test yes yes opL18 opp "parameter operator" -- 120
803+
, test yes yes b'L19 bp "name in backticks" -- 120
804+
, test yes broken clL23 cls "class in instance declaration"
805+
, test yes broken clL25 cls "class in signature" -- 147
806+
, test broken broken eclL15 ecls "external class in signature"
802807
]
803808
where yes, broken :: (TestTree -> Maybe TestTree)
804809
yes = Just -- test should run and pass

0 commit comments

Comments
 (0)