Skip to content

Commit 2523c21

Browse files
jacgcocreature
authored andcommitted
Fix #246 (#252)
* Fix #246 `getTypeLHsBind` returned a single span corresponding to the overall function binding. The fix drills down into the individual matches and returns a span for each of them. Fixes #246. * Make it work on GHC 8.8 * Cosmetics
1 parent 26ddbbf commit 2523c21

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

Diff for: src/Development/IDE/Spans/Calculate.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ getTypeLHsBind :: (GhcMonad m)
9898
=> TypecheckedModule
9999
-> LHsBind GhcTc
100100
-> m [(SpanSource, SrcSpan, Maybe Type)]
101-
getTypeLHsBind _ (L _spn FunBind{fun_id = pid,fun_matches = MG{}}) =
102-
return [(Named $ getName (unLoc pid), getLoc pid, Just (varType (unLoc pid)))]
101+
getTypeLHsBind _ (L _spn FunBind{ fun_id = pid
102+
, fun_matches = MG{mg_alts=(L _ matches)}}) =
103+
return [(Named (getName (unLoc pid)), getLoc match, Just (varType (unLoc pid))) | match <- matches ]
103104
getTypeLHsBind _ _ = return []
104105

105106
-- | Get the name and type of an expression.

Diff for: test/exe/Main.hs

+18-18
Original file line numberDiff line numberDiff line change
@@ -796,28 +796,28 @@ findDefinitionAndHoverTests = let
796796
mkFindTests
797797
-- def hover look expect
798798
[ test yes yes fffL4 fff "field in record definition"
799-
, test broken broken fffL8 fff "field in record construction #71"
800-
, test yes yes fffL14 fff "field name used as accessor" -- 120 in Calculate.hs
801-
, test yes yes aaaL14 aaa "top-level name" -- 120
802-
, test broken broken dcL7 tcDC "record data constructor #247"
803-
, test yes yes dcL12 tcDC "plain data constructor" -- 121
804-
, test yes broken tcL6 tcData "type constructor #249" -- 147
805-
, test broken broken xtcL5 xtc "type constructor from other package #249"
806-
, test broken yes xvL20 xvMsg "value from other package #249" -- 120
807-
, test yes yes vvL16 vv "plain parameter" -- 120
808-
, test yes yes aL18 apmp "pattern match name" -- 120
809-
, test yes yes opL16 op "top-level operator" -- 120, 123
810-
, test yes yes opL18 opp "parameter operator" -- 120
811-
, test yes yes b'L19 bp "name in backticks" -- 120
812-
, test yes broken clL23 cls "class in instance declaration #250"
813-
, test yes broken clL25 cls "class in signature #250" -- 147
799+
, test broken broken fffL8 fff "field in record construction #71"
800+
, test yes yes fffL14 fff "field name used as accessor" -- 120 in Calculate.hs
801+
, test yes yes aaaL14 aaa "top-level name" -- 120
802+
, test broken broken dcL7 tcDC "data constructor record #247"
803+
, test yes yes dcL12 tcDC "data constructor plain" -- 121
804+
, test yes broken tcL6 tcData "type constructor #249" -- 147
805+
, test broken broken xtcL5 xtc "type constructor external #249"
806+
, test broken yes xvL20 xvMsg "value external package #249" -- 120
807+
, test yes yes vvL16 vv "plain parameter" -- 120
808+
, test yes yes aL18 apmp "pattern match name" -- 120
809+
, test yes yes opL16 op "top-level operator" -- 120, 123
810+
, test yes yes opL18 opp "parameter operator" -- 120
811+
, test yes yes b'L19 bp "name in backticks" -- 120
812+
, test yes broken clL23 cls "class in instance declaration #250"
813+
, test yes broken clL25 cls "class in signature #250" -- 147
814814
, test broken broken eclL15 ecls "external class in signature #249,250"
815-
, test yes yes dnbL29 dnb "do-notation bind" -- 137
815+
, test yes yes dnbL29 dnb "do-notation bind" -- 137
816816
, test yes yes dnbL30 dnb "do-notation lookup"
817-
, test yes yes lcbL33 lcb "listcomp bind" -- 137
817+
, test yes yes lcbL33 lcb "listcomp bind" -- 137
818818
, test yes yes lclL33 lcb "listcomp lookup"
819819
, test yes yes mclL36 mcl "top-level fn 1st clause"
820-
, test broken broken mclL37 mcl "top-level fn 2nd clause #245"
820+
, test yes yes mclL37 mcl "top-level fn 2nd clause #246"
821821
]
822822
where yes, broken :: (TestTree -> Maybe TestTree)
823823
yes = Just -- test should run and pass

0 commit comments

Comments
 (0)