Skip to content

Commit cd298fe

Browse files
committed
Merge remote-tracking branch 'batkot/master' into 4416-show-package-versions
2 parents d8b774c + 0a52558 commit cd298fe

File tree

37 files changed

+423
-178
lines changed

37 files changed

+423
-178
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ packages:
88
./hls-test-utils
99

1010

11-
index-state: 2025-06-07T14:57:40Z
11+
index-state: 2025-06-16T09:44:13Z
1212

1313
tests: True
1414
test-show-details: direct

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/ghcide.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ library
7575
, hashable
7676
, hie-bios ^>=0.15.0
7777
, hie-compat ^>=0.3.0.0
78-
, hiedb ^>= 0.6.0.2
78+
, hiedb ^>= 0.7.0.0
7979
, hls-graph == 2.11.0.0
8080
, hls-plugin-api == 2.11.0.0
8181
, implicit-hie >= 0.1.4.0 && < 0.1.5

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ instance Pretty Log where
223223

224224
-- | Bump this version number when making changes to the format of the data stored in hiedb
225225
hiedbDataVersion :: String
226-
hiedbDataVersion = "1"
226+
hiedbDataVersion = "2"
227227

228228
data CacheDirs = CacheDirs
229229
{ hiCacheDir, hieCacheDir, oCacheDir :: Maybe FilePath}
@@ -956,6 +956,8 @@ CallStack (from HasCallStack):
956956
expectJust, called at compiler\\typecheck\\FamInst.hs:461:30 in ghc:FamInst
957957
```
958958
959+
and many more.
960+
959961
To mitigate this, we set the cache directory for each component dependent
960962
on the components of the current `HscEnv`, additionally to the component options
961963
of the respective components.

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

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@ module Development.IDE.GHC.Compat.Error (
1717
DriverMessage (..),
1818
-- * General Diagnostics
1919
Diagnostic(..),
20-
-- * Prisms for error selection
20+
-- * Prisms and lenses for error selection
2121
_TcRnMessage,
2222
_TcRnMessageWithCtx,
2323
_GhcPsMessage,
2424
_GhcDsMessage,
2525
_GhcDriverMessage,
2626
_TcRnMissingSignature,
27+
_TcRnSolverReport,
28+
_TcRnMessageWithInfo,
29+
reportContextL,
30+
reportContentL,
31+
_MismatchMessage,
32+
_TypeEqMismatchActual,
33+
_TypeEqMismatchExpected,
2734
) where
2835

2936
import Control.Lens
37+
import Development.IDE.GHC.Compat (Type)
3038
import GHC.Driver.Errors.Types
3139
import GHC.HsToCore.Errors.Types
3240
import GHC.Tc.Errors.Types
@@ -82,3 +90,36 @@ msgEnvelopeErrorL :: Lens' (MsgEnvelope e) e
8290
msgEnvelopeErrorL = lens errMsgDiagnostic (\envelope e -> envelope { errMsgDiagnostic = e } )
8391

8492
makePrisms ''TcRnMessage
93+
94+
makeLensesWith
95+
(lensRules & lensField .~ mappingNamer (pure . (++ "L")))
96+
''SolverReportWithCtxt
97+
98+
-- | Focus 'MismatchMsg' from 'TcSolverReportMsg'. Currently, 'MismatchMsg' can be
99+
-- extracted from 'CannotUnifyVariable' and 'Mismatch' constructors.
100+
_MismatchMessage :: Traversal' TcSolverReportMsg MismatchMsg
101+
_MismatchMessage focus (Mismatch msg t a c) = (\msg' -> Mismatch msg' t a c) <$> focus msg
102+
_MismatchMessage focus (CannotUnifyVariable msg a) = flip CannotUnifyVariable a <$> focus msg
103+
_MismatchMessage _ report = pure report
104+
105+
-- | Focus 'teq_mismatch_expected' from 'TypeEqMismatch'.
106+
_TypeEqMismatchExpected :: Traversal' MismatchMsg Type
107+
#if MIN_VERSION_ghc(9,10,2)
108+
_TypeEqMismatchExpected focus mismatch@(TypeEqMismatch _ _ _ expected _ _ _) =
109+
(\expected' -> mismatch { teq_mismatch_expected = expected' }) <$> focus expected
110+
#else
111+
_TypeEqMismatchExpected focus mismatch@(TypeEqMismatch _ _ _ _ expected _ _ _) =
112+
(\expected' -> mismatch { teq_mismatch_expected = expected' }) <$> focus expected
113+
#endif
114+
_TypeEqMismatchExpected _ mismatch = pure mismatch
115+
116+
-- | Focus 'teq_mismatch_actual' from 'TypeEqMismatch'.
117+
_TypeEqMismatchActual :: Traversal' MismatchMsg Type
118+
#if MIN_VERSION_ghc(9,10,2)
119+
_TypeEqMismatchActual focus mismatch@(TypeEqMismatch _ _ _ _ actual _ _) =
120+
(\actual' -> mismatch { teq_mismatch_actual = actual' }) <$> focus actual
121+
#else
122+
_TypeEqMismatchActual focus mismatch@(TypeEqMismatch _ _ _ _ _ actual _ _) =
123+
(\actual' -> mismatch { teq_mismatch_expected = actual' }) <$> focus actual
124+
#endif
125+
_TypeEqMismatchActual _ mismatch = pure mismatch

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

haskell-language-server.cabal

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ library hls-cabal-plugin
284284
, transformers
285285
, unordered-containers >=0.2.10.0
286286
, containers
287-
, cabal-add
287+
, cabal-add ^>=0.1
288288
, process
289289
, aeson
290290
, Cabal
@@ -409,7 +409,7 @@ library hls-call-hierarchy-plugin
409409
, containers
410410
, extra
411411
, ghcide == 2.11.0.0
412-
, hiedb ^>= 0.6.0.2
412+
, hiedb ^>= 0.7.0.0
413413
, hls-plugin-api == 2.11.0.0
414414
, lens
415415
, lsp >=2.7
@@ -596,7 +596,7 @@ library hls-rename-plugin
596596
, containers
597597
, ghcide == 2.11.0.0
598598
, hashable
599-
, hiedb ^>= 0.6.0.2
599+
, hiedb ^>= 0.7.0.0
600600
, hie-compat
601601
, hls-plugin-api == 2.11.0.0
602602
, haskell-language-server:hls-refactor-plugin
@@ -1175,12 +1175,14 @@ library hls-change-type-signature-plugin
11751175
build-depends:
11761176
, ghcide == 2.11.0.0
11771177
, hls-plugin-api == 2.11.0.0
1178+
, lens
11781179
, lsp-types
11791180
, regex-tdfa
11801181
, syb
11811182
, text
11821183
, transformers
11831184
, containers
1185+
, ghc
11841186
default-extensions:
11851187
DataKinds
11861188
ExplicitNamespaces
@@ -1198,6 +1200,7 @@ test-suite hls-change-type-signature-plugin-tests
11981200
build-depends:
11991201
, filepath
12001202
, haskell-language-server:hls-change-type-signature-plugin
1203+
, hls-plugin-api
12011204
, hls-test-utils == 2.11.0.0
12021205
, regex-tdfa
12031206
, text

0 commit comments

Comments
 (0)