Skip to content

Commit 0a479aa

Browse files
committed
Add tests for references to record fields and update symbol retrieval
1 parent 8d96270 commit 0a479aa

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

ghcide-test/data/references/References.hs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
{-# LANGUAGE RecordWildCards #-}
12
module References where
2-
33
import OtherModule
44

55
foo = bar
@@ -23,3 +23,19 @@ bobHasChecking = case bobsAccount of
2323
x = symbolDefinedInOtherModule
2424

2525
y = symbolDefinedInOtherOtherModule
26+
27+
data Foo = MkFoo
28+
{
29+
barr :: Int,
30+
bazz :: String
31+
}
32+
33+
fooUse0 :: Foo -> Int
34+
fooUse0 MkFoo{barr} = 5
35+
36+
fooUse1 :: Foo -> Int
37+
fooUse1 MkFoo{..} = 6
38+
39+
fooUse2 :: Int -> String -> Foo
40+
fooUse2 bar baz =
41+
MkFoo{..}

ghcide-test/exe/ReferenceTests.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ tests = testGroup "references"
155155
, ("References.hs", 12, 5)
156156
, ("References.hs", 16, 0)
157157
]
158+
, referenceTest "references record fields"
159+
("References.hs", 29, 5)
160+
YesIncludeDeclaration
161+
[ ("References.hs", 29, 4)
162+
, ("References.hs", 36, 14)
163+
]
158164
]
159165
]
160166

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ foiReferencesAtPoint file pos (FOIReferences asts) =
113113

114114
getNamesAtPoint :: HieASTs a -> Position -> PositionMapping -> [Name]
115115
getNamesAtPoint hf pos mapping =
116-
concat $ pointCommand hf posFile (rights . M.keys . getNodeIds)
116+
concat $ pointCommand hf posFile (rights . M.keys . getSourceNodeIds)
117117
where
118118
posFile = fromMaybe pos $ fromCurrentPosition mapping pos
119119

0 commit comments

Comments
 (0)