Skip to content

Commit 33f788c

Browse files
authored
Merge branch 'master' into batch-load-multi-read
2 parents bb78a36 + df24af6 commit 33f788c

File tree

53 files changed

+1217
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1217
-413
lines changed

.github/actions/setup-build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ runs:
3131
sudo chown -R $USER /usr/local/.ghcup
3232
shell: bash
3333

34-
- uses: haskell-actions/[email protected].6
34+
- uses: haskell-actions/[email protected].8
3535
id: HaskEnvSetup
3636
with:
3737
ghc-version : ${{ inputs.ghc }}

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
example: ['cabal', 'lsp-types']
128128

129129
steps:
130-
- uses: haskell-actions/[email protected].6
130+
- uses: haskell-actions/[email protected].8
131131
with:
132132
ghc-version : ${{ matrix.ghc }}
133133
cabal-version: ${{ matrix.cabal }}

ghcide-bench/src/Experiments.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ experiments =
266266
flip allM docs $ \DocumentPositions{..} -> do
267267
bottom <- pred . length . T.lines <$> documentContents doc
268268
diags <- getCurrentDiagnostics doc
269-
case requireDiagnostic diags (DiagnosticSeverity_Error, (fromIntegral bottom, 8), "Found hole", Nothing) of
269+
case requireDiagnostic diags (DiagnosticSeverity_Error, (fromIntegral bottom, 8), "Found hole", Just "GHC-88464", Nothing) of
270270
Nothing -> pure True
271271
Just _err -> pure False
272272
),

ghcide/ghcide.cabal

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ library
8585
, hls-plugin-api == 2.9.0.1
8686
, implicit-hie >= 0.1.4.0 && < 0.1.5
8787
, lens
88+
, lens-aeson
8889
, list-t
8990
, lsp ^>=2.7
9091
, lsp-types ^>=2.3
@@ -151,7 +152,9 @@ library
151152
Development.IDE.GHC.Compat
152153
Development.IDE.GHC.Compat.Core
153154
Development.IDE.GHC.Compat.CmdLine
155+
Development.IDE.GHC.Compat.Driver
154156
Development.IDE.GHC.Compat.Env
157+
Development.IDE.GHC.Compat.Error
155158
Development.IDE.GHC.Compat.Iface
156159
Development.IDE.GHC.Compat.Logger
157160
Development.IDE.GHC.Compat.Outputable

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,11 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
594594
this_flags = (this_error_env, this_dep_info)
595595
this_error_env = ([this_error], Nothing)
596596
this_error = ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) _cfp
597-
$ T.unlines
598-
[ "No cradle target found. Is this file listed in the targets of your cradle?"
599-
, "If you are using a .cabal file, please ensure that this module is listed in either the exposed-modules or other-modules section"
600-
]
597+
(T.unlines
598+
[ "No cradle target found. Is this file listed in the targets of your cradle?"
599+
, "If you are using a .cabal file, please ensure that this module is listed in either the exposed-modules or other-modules section"
600+
])
601+
Nothing
601602

602603
let insertAll m xs = mapM_ (flip (uncurry STM.insert) m) xs
603604
newLoaded = Set.fromList $ fromNormalizedFilePath <$> HM.keys this_flags_map
@@ -918,10 +919,10 @@ setNameCache nc hsc = hsc { hsc_NC = nc }
918919
-- GHC had an implementation of this function, but it was horribly inefficient
919920
-- We should move back to the GHC implementation on compilers where
920921
-- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12162 is included
921-
checkHomeUnitsClosed' :: UnitEnv -> OS.Set UnitId -> [DriverMessages]
922+
checkHomeUnitsClosed' :: UnitEnv -> OS.Set UnitId -> Maybe (Compat.MsgEnvelope DriverMessage)
922923
checkHomeUnitsClosed' ue home_id_set
923-
| OS.null bad_unit_ids = []
924-
| otherwise = [singleMessage $ GHC.mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (OS.toList bad_unit_ids)]
924+
| OS.null bad_unit_ids = Nothing
925+
| otherwise = Just (GHC.mkPlainErrorMsgEnvelope rootLoc $ DriverHomePackagesNotClosed (OS.toList bad_unit_ids))
925926
where
926927
bad_unit_ids = upwards_closure OS.\\ home_id_set
927928
rootLoc = mkGeneralSrcSpan (Compat.fsLit "<command line>")
@@ -996,10 +997,19 @@ newComponentCache recorder exts _cfp hsc_env old_cis new_cis = do
996997
hscEnv' <- -- Set up a multi component session with the other units on GHC 9.4
997998
Compat.initUnits dfs hsc_env
998999

999-
let closure_errs = checkHomeUnitsClosed' (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv')
1000-
multi_errs = map (ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Warning) _cfp . T.pack . Compat.printWithoutUniques) closure_errs
1000+
let closure_errs = maybeToList $ checkHomeUnitsClosed' (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv')
1001+
closure_err_to_multi_err err =
1002+
ideErrorWithSource
1003+
(Just "cradle") (Just DiagnosticSeverity_Warning) _cfp
1004+
(T.pack (Compat.printWithoutUniques (singleMessage err)))
1005+
#if MIN_VERSION_ghc(9,5,0)
1006+
(Just (fmap GhcDriverMessage err))
1007+
#else
1008+
Nothing
1009+
#endif
1010+
multi_errs = map closure_err_to_multi_err closure_errs
10011011
bad_units = OS.fromList $ concat $ do
1002-
x <- bagToList $ mapBag errMsgDiagnostic $ unionManyBags $ map Compat.getMessages closure_errs
1012+
x <- map errMsgDiagnostic closure_errs
10031013
DriverHomePackagesNotClosed us <- pure x
10041014
pure us
10051015
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units
@@ -1345,6 +1355,6 @@ showPackageSetupException PackageSetupException{..} = unwords
13451355
, "failed to load packages:", message <> "."
13461356
, "\nPlease ensure that ghcide is compiled with the same GHC installation as the project."]
13471357

1348-
renderPackageSetupException :: FilePath -> PackageSetupException -> (NormalizedFilePath, ShowDiagnostic, Diagnostic)
1358+
renderPackageSetupException :: FilePath -> PackageSetupException -> FileDiagnostic
13491359
renderPackageSetupException fp e =
1350-
ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) (toNormalizedFilePath' fp) (T.pack $ showPackageSetupException e)
1360+
ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) (toNormalizedFilePath' fp) (T.pack $ showPackageSetupException e) Nothing

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module Development.IDE.Session.Diagnostics where
44
import Control.Applicative
5+
import Control.Lens
56
import Control.Monad
67
import qualified Data.Aeson as Aeson
78
import Data.List
@@ -27,11 +28,13 @@ data CradleErrorDetails =
2728
Depicts the cradle error in a user-friendly way.
2829
-}
2930
renderCradleError :: CradleError -> Cradle a -> NormalizedFilePath -> FileDiagnostic
30-
renderCradleError (CradleError deps _ec ms _attemptToLoadFiles) cradle nfp
31-
| HieBios.isCabalCradle cradle =
32-
let (fp, showDiag, diag) = ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) nfp $ T.unlines $ map T.pack userFriendlyMessage in
33-
(fp, showDiag, diag{_data_ = Just $ Aeson.toJSON CradleErrorDetails{cabalProjectFiles=absDeps}})
34-
| otherwise = ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) nfp $ T.unlines $ map T.pack userFriendlyMessage
31+
renderCradleError (CradleError deps _ec ms _attemptToLoadFiles) cradle nfp =
32+
let noDetails =
33+
ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) nfp (T.unlines $ map T.pack userFriendlyMessage) Nothing
34+
in
35+
if HieBios.isCabalCradle cradle
36+
then noDetails & fdLspDiagnosticL %~ \diag -> diag{_data_ = Just $ Aeson.toJSON CradleErrorDetails{cabalProjectFiles=absDeps}}
37+
else noDetails
3538
where
3639
absDeps = fmap (cradleRootDir cradle </>) deps
3740
userFriendlyMessage :: [String]

0 commit comments

Comments
 (0)