@@ -68,6 +68,10 @@ import GHC.Tc.Gen.Splice
68
68
import TcSplice
69
69
#endif
70
70
71
+ #if MIN_VERSION_ghc(9,2,0)
72
+ import qualified GHC.Types.Error as Error
73
+ #endif
74
+
71
75
import Control.Exception (evaluate )
72
76
import Control.Exception.Safe
73
77
import Control.Lens hiding (List )
@@ -80,6 +84,7 @@ import qualified Data.DList as DL
80
84
import Data.IORef
81
85
import Data.List.Extra
82
86
import qualified Data.Map.Strict as Map
87
+ import qualified Data.IntMap.Strict as IntMap
83
88
import Data.Maybe
84
89
import qualified Data.Text as T
85
90
import Data.Time (UTCTime , getCurrentTime )
@@ -102,6 +107,7 @@ import Data.Coerce
102
107
import Data.Functor
103
108
import qualified Data.HashMap.Strict as HashMap
104
109
import Data.Map (Map )
110
+ import Data.IntMap (IntMap )
105
111
import Data.Tuple.Extra (dupe )
106
112
import Data.Unique as Unique
107
113
import Development.IDE.Core.Tracing (withTrace )
@@ -676,14 +682,23 @@ mergeEnvs env extraModSummaries extraMods envs = do
676
682
prevFinderCache <- concatFC <$> mapM (readIORef . hsc_FC) envs
677
683
let ims = map (Compat. installedModule (homeUnitId_ $ hsc_dflags env) . moduleName . ms_mod) extraModSummaries
678
684
ifrs = zipWith (\ ms -> InstalledFound (ms_location ms)) extraModSummaries ims
685
+ -- We don't do any instantiation for backpack at this point of time, so it is OK to use
686
+ -- 'extendModSummaryNoDeps'.
687
+ -- This may have to change in the future.
688
+ module_graph_nodes =
689
+ #if MIN_VERSION_ghc(9,2,0)
690
+ map extendModSummaryNoDeps $
691
+ #endif
692
+ extraModSummaries ++ nubOrdOn ms_mod (concatMap (mgModSummaries . hsc_mod_graph) envs)
693
+
679
694
newFinderCache <- newIORef $
680
695
foldl'
681
696
(\ fc (im, ifr) -> Compat. extendInstalledModuleEnv fc im ifr) prevFinderCache
682
697
$ zip ims ifrs
683
698
return $ loadModulesHome extraMods $ env{
684
699
hsc_HPT = foldMapBy mergeUDFM emptyUDFM hsc_HPT envs,
685
700
hsc_FC = newFinderCache,
686
- hsc_mod_graph = mkModuleGraph $ extraModSummaries ++ nubOrdOn ms_mod ( concatMap (mgModSummaries . hsc_mod_graph) envs)
701
+ hsc_mod_graph = mkModuleGraph module_graph_nodes
687
702
}
688
703
where
689
704
mergeUDFM = plusUDFM_C combineModules
@@ -732,8 +747,9 @@ getModSummaryFromImports env fp modTime contents = do
732
747
implicit_prelude = xopt LangExt. ImplicitPrelude dflags
733
748
implicit_imports = mkPrelImports mod main_loc
734
749
implicit_prelude imps
750
+
735
751
convImport (L _ i) = (fmap sl_fs (ideclPkgQual i)
736
- , ideclName i)
752
+ , reLoc $ ideclName i)
737
753
738
754
srcImports = map convImport src_idecls
739
755
textualImports = map convImport (implicit_imports ++ ordinary_imps)
@@ -805,13 +821,23 @@ parseHeader dflags filename contents = do
805
821
case unP Compat. parseHeader (initParserState (initParserOpts dflags) contents loc) of
806
822
#if MIN_VERSION_ghc(8,10,0)
807
823
PFailed pst ->
808
- throwE $ diagFromErrMsgs " parser" dflags $ getErrorMessages pst dflags
824
+ throwE $ diagFromErrMsgs " parser" dflags
825
+ #if MIN_VERSION_ghc(9,2,0)
826
+ $ fmap pprError
827
+ #endif
828
+ $ getErrorMessages pst
829
+ #if !MIN_VERSION_ghc(9,2,0)
830
+ dflags
831
+ #endif
809
832
#else
810
833
PFailed _ locErr msgErr ->
811
834
throwE $ diagFromErrMsg " parser" dflags $ mkPlainErrMsg dflags locErr msgErr
812
835
#endif
813
836
POk pst rdr_module -> do
814
- let (warns, errs) = getMessages pst dflags
837
+ let (warns, errs) = getMessages pst
838
+ #if !MIN_VERSION_ghc(9,2,0)
839
+ dflags
840
+ #endif
815
841
-- Just because we got a `POk`, it doesn't mean there
816
842
-- weren't errors! To clarify, the GHC parser
817
843
-- distinguishes between fatal and non-fatal
@@ -842,15 +868,30 @@ parseFileContents env customPreprocessor filename ms = do
842
868
contents = fromJust $ ms_hspp_buf ms
843
869
case unP Compat. parseModule (initParserState (initParserOpts dflags) contents loc) of
844
870
#if MIN_VERSION_ghc(8,10,0)
845
- PFailed pst -> throwE $ diagFromErrMsgs " parser" dflags $ getErrorMessages pst dflags
871
+ PFailed pst -> throwE
872
+ $ diagFromErrMsgs " parser" dflags
873
+ #if MIN_VERSION_ghc(9,2,0)
874
+ $ fmap pprError
875
+ #endif
876
+ $ getErrorMessages pst
877
+ #if !MIN_VERSION_ghc(9,2,0)
878
+ $ dflags
879
+ #endif
846
880
#else
847
881
PFailed _ locErr msgErr ->
848
882
throwE $ diagFromErrMsg " parser" dflags $ mkPlainErrMsg dflags locErr msgErr
849
883
#endif
850
884
POk pst rdr_module ->
851
885
let
852
886
hpm_annotations = mkApiAnns pst
853
- (warns, errs) = getMessages pst dflags
887
+ (warns, errs) = id
888
+ #if MIN_VERSION_ghc(9,2,0)
889
+ $ bimap (fmap pprWarning) (fmap pprError)
890
+ #endif
891
+ $ getMessages pst
892
+ #if !MIN_VERSION_ghc(9,2,0)
893
+ $ dflags
894
+ #endif
854
895
in
855
896
do
856
897
-- Just because we got a `POk`, it doesn't mean there
@@ -977,23 +1018,31 @@ getDocsBatch
977
1018
:: HscEnv
978
1019
-> Module -- ^ a moudle where the names are in scope
979
1020
-> [Name ]
980
- -> IO [Either String (Maybe HsDocString , Map. Map Int HsDocString )]
1021
+ -> IO [Either String (Maybe HsDocString , IntMap HsDocString )]
981
1022
getDocsBatch hsc_env _mod _names = do
982
- ((_warns,errs) , res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ forM _names $ \ name ->
1023
+ (msgs , res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ forM _names $ \ name ->
983
1024
case nameModule_maybe name of
984
1025
Nothing -> return (Left $ NameHasNoModule name)
985
1026
Just mod -> do
986
1027
ModIface { mi_doc_hdr = mb_doc_hdr
987
1028
, mi_decl_docs = DeclDocMap dmap
988
1029
, mi_arg_docs = ArgDocMap amap
989
1030
} <- loadModuleInterface " getModuleInterface" mod
990
- if isNothing mb_doc_hdr && Map. null dmap && Map. null amap
1031
+ if isNothing mb_doc_hdr && Map. null dmap && null amap
991
1032
then pure (Left (NoDocsInIface mod $ compiled name))
992
- else pure (Right ( Map. lookup name dmap
993
- , Map. findWithDefault Map. empty name amap))
1033
+ else pure (Right ( Map. lookup name dmap ,
1034
+ #if !MIN_VERSION_ghc(9,2,0)
1035
+ IntMap. fromAscList $ Map. toAscList $
1036
+ #endif
1037
+ Map. findWithDefault mempty name amap))
994
1038
case res of
995
1039
Just x -> return $ map (first $ T. unpack . showGhc) x
996
- Nothing -> throwErrors errs
1040
+ Nothing -> throwErrors
1041
+ #if MIN_VERSION_ghc(9,2,0)
1042
+ $ Error. getErrorMessages msgs
1043
+ #else
1044
+ $ snd msgs
1045
+ #endif
997
1046
where
998
1047
throwErrors = liftIO . throwIO . mkSrcErr
999
1048
compiled n =
0 commit comments