Skip to content

Commit aff67c0

Browse files
committed
Merge remote-tracking branch 'upstream/master' into batch-load-multi-read
2 parents 1aa1e2c + 29b2ecb commit aff67c0

File tree

8 files changed

+52
-7
lines changed

8 files changed

+52
-7
lines changed

ghcide-test/data/references/Fields.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{-# LANGUAGE RecordWildCards #-}
2+
module Fields where
3+
4+
data Foo = MkFoo
5+
{
6+
barr :: String,
7+
bazz :: String
8+
}
9+
10+
fooUse0 :: Foo -> String
11+
fooUse0 MkFoo{barr} = "5"
12+
13+
fooUse1 :: Foo -> String
14+
fooUse1 MkFoo{..} = "6"
15+
16+
fooUse2 :: String -> String -> Foo
17+
fooUse2 bar baz =
18+
MkFoo{..}

ghcide-test/data/references/Main.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Main where
22

33
import References
4-
4+
import Fields
55
main :: IO ()
66
main = return ()
77

@@ -12,3 +12,6 @@ b = a + 1
1212

1313
acc :: Account
1414
acc = Savings
15+
16+
fooUse3 :: String -> String -> Foo
17+
fooUse3 bar baz = MkFoo{barr = bar, bazz = baz}

ghcide-test/data/references/hie.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cradle: {direct: {arguments: ["Main","OtherModule","OtherOtherModule","References"]}}
1+
cradle: {direct: {arguments: ["Main","OtherModule","OtherOtherModule","References", "Fields"]}}

ghcide-test/exe/ReferenceTests.hs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,28 @@ tests = testGroup "references"
156156
, ("References.hs", 16, 0)
157157
]
158158
]
159+
-- Fields.hs does not depend on Main.hs
160+
-- so we can only find references in Fields.hs
161+
, testGroup "references to record fields"
162+
[ referenceTest "references record fields in the same file"
163+
("Fields.hs", 5, 4)
164+
YesIncludeDeclaration
165+
[ ("Fields.hs", 5, 4)
166+
, ("Fields.hs", 10, 14)
167+
, ("Fields.hs", 13, 14)
168+
]
169+
170+
-- Main.hs depends on Fields.hs, so we can find references
171+
-- from Main.hs to Fields.hs
172+
, referenceTest "references record fields cross modules"
173+
("Main.hs", 16, 24)
174+
YesIncludeDeclaration
175+
[ ("Fields.hs", 5, 4)
176+
, ("Fields.hs", 10, 14)
177+
, ("Fields.hs", 13, 14)
178+
, ("Main.hs", 16, 24)
179+
]
180+
]
159181
]
160182

161183
-- | When we ask for all references to symbol "foo", should the declaration "foo

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ instance Pretty Log where
208208

209209
-- | Bump this version number when making changes to the format of the data stored in hiedb
210210
hiedbDataVersion :: String
211-
hiedbDataVersion = "1"
211+
hiedbDataVersion = "2"
212212

213213
data SessionLoadingOptions = SessionLoadingOptions
214214
{ findCradle :: FilePath -> IO (Maybe FilePath)
@@ -705,7 +705,7 @@ type SessionM = ReaderT SessionEnv IO
705705
-- 2. Check in the cache, whether the given 'hie.yaml' was already loaded before
706706
-- 3.1. If it wasn't, initialise a new session and continue with step 4.
707707
-- 3.2. If it is loaded, check whether we need to reload the session, e.g. because the `.cabal` file was modified
708-
-- 3.2.1. If we need to reload, remove the
708+
-- 3.2.1. If we need to reload, remove the
709709
getOptionsLoop :: Recorder (WithPriority Log) -> SessionShake -> SessionState -> TVar (Hashed KnownTargets) -> SessionM ()
710710
getOptionsLoop recorder sessionShake sessionState knownTargetsVar = forever $ do
711711
-- Get the next file to load

ghcide/session-loader/Development/IDE/Session/Ghc.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ CallStack (from HasCallStack):
357357
expectJust, called at compiler\\typecheck\\FamInst.hs:461:30 in ghc:FamInst
358358
```
359359
360+
and many more.
361+
360362
To mitigate this, we set the cache directory for each component dependent
361363
on the components of the current `HscEnv`, additionally to the component options
362364
of the respective components.

ghcide/src/Development/IDE/GHC/Compat/Error.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ _MismatchMessage _ report = pure report
104104

105105
-- | Focus 'teq_mismatch_expected' from 'TypeEqMismatch'.
106106
_TypeEqMismatchExpected :: Traversal' MismatchMsg Type
107-
#if MIN_VERSION_ghc(9,12,0)
107+
#if MIN_VERSION_ghc(9,10,2)
108108
_TypeEqMismatchExpected focus mismatch@(TypeEqMismatch _ _ _ expected _ _ _) =
109109
(\expected' -> mismatch { teq_mismatch_expected = expected' }) <$> focus expected
110110
#else
@@ -115,7 +115,7 @@ _TypeEqMismatchExpected _ mismatch = pure mismatch
115115

116116
-- | Focus 'teq_mismatch_actual' from 'TypeEqMismatch'.
117117
_TypeEqMismatchActual :: Traversal' MismatchMsg Type
118-
#if MIN_VERSION_ghc(9,12,0)
118+
#if MIN_VERSION_ghc(9,10,2)
119119
_TypeEqMismatchActual focus mismatch@(TypeEqMismatch _ _ _ _ actual _ _) =
120120
(\actual' -> mismatch { teq_mismatch_actual = actual' }) <$> focus actual
121121
#else

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)