@@ -7,7 +7,7 @@
77
88-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
99-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
10−module Development.IDE.Functions.Compile
10+module Development.IDE.Core.Compile
1111 ( GhcModule(..)
1212 , TcModuleResult(..)
1313 , LoadPackageResult(..)
@@ -20,21 +20,21 @@ module Development.IDE.Functions.Compile
2020 , computePackageDeps
2121 ) where
2222
23−import Development.IDE.Functions.Warnings
24−import Development.IDE.Functions.CPP
23+import Development.IDE.GHC.Warnings
24+import Development.IDE.GHC.CPP
2525import Development.IDE.Types.Diagnostics
26−import qualified Development.IDE.Functions.FindImports as FindImports
27−import Development.IDE.Functions.GHCError
28−import Development.IDE.Functions.SpanInfo
29−import Development.IDE.UtilGHC
30−import Development.IDE.Compat
26+import qualified Development.IDE.Import.FindImports as FindImports
27+import Development.IDE.GHC.Error
28+import Development.IDE.Spans.Calculate
29+import Development.IDE.GHC.Util
30+import Development.IDE.GHC.Compat
3131import Development.IDE.Types.Options
3232import Development.IDE.Types.Location
3333
3434import GHC hiding (parseModule, typecheckModule)
3535import qualified Parser
3636import Lexer
37−import Bag
37+import ErrUtils
3838
3939import qualified GHC
4040import Panic
@@ -56,7 +56,7 @@ import Data.List.Extra
5656import Data.Maybe
5757import Data.Tuple.Extra
5858import qualified Data.Map.Strict as Map
59−import Development.IDE.Types.SpanInfo
59+import Development.IDE.Spans.Type
6060import GHC.Generics (Generic)
6161import System.FilePath
6262import System.Directory
@@ -143,7 +143,7 @@ typecheckModule opt packageState deps pm =
143143 runGhcSessionExcept opt (Just pm) packageState $
144144 catchSrcErrors $ do
145145 setupEnv deps
146− (warnings, tcm) <- withWarnings "Typechecker" $ \tweak ->
146+ (warnings, tcm) <- withWarnings $ \tweak ->
147147 GHC.typecheckModule pm{pm_mod_summary = tweak $ pm_mod_summary pm}
148148 tcm2 <- mkTcModuleResult (WriteInterface $ optWriteIface opt) tcm
149149 return (warnings, tcm2)
@@ -182,7 +182,7 @@ compileModule opt mod packageState deps tmr =
182182
183183 let tm = tmrModule tmr
184184 session <- getSession
185− (warnings,desugar) <- withWarnings "Desugarer" $ \tweak -> do
185+ (warnings,desugar) <- withWarnings $ \tweak -> do
186186 let pm = tm_parsed_module tm
187187 let pm' = pm{pm_mod_summary = tweak $ pm_mod_summary pm}
188188 let tm' = tm{tm_parsed_module = pm'}
@@ -395,7 +395,7 @@ parseFileContents preprocessor filename contents = do
395395
396396 case unP Parser.parseModule (mkPState dflags contents loc) of
397397 PFailed _ locErr msgErr ->
398− Ex.throwE $ mkErrorDoc dflags locErr msgErr
398+ Ex.throwE $ diagFromErrMsg dflags $ mkPlainErrMsg dflags locErr msgErr
399399 POk pst rdr_module ->
400400 let hpm_annotations =
401401 (Map.fromListWith (++) $ annotations pst,
@@ -414,11 +414,11 @@ parseFileContents preprocessor filename contents = do
414414 -- errors are those from which a parse tree just can't
415415 -- be produced.
416416 unless (null errs) $
417− Ex.throwE $ toDiagnostics dflags $ snd $ getMessages pst dflags
417+ Ex.throwE $ diagFromErrMsgs dflags $ snd $ getMessages pst dflags
418418
419419 -- Ok, we got here. It's safe to continue.
420420 let (errs, parsed) = preprocessor rdr_module
421− unless (null errs) $ Ex.throwE $ mkErrors dflags errs
421+ unless (null errs) $ Ex.throwE $ diagFromStrings errs
422422 ms <- getModSummaryFromBuffer filename contents dflags parsed
423423 let pm =
424424 ParsedModule {
@@ -427,7 +427,7 @@ parseFileContents preprocessor filename contents = do
427427 , pm_extra_src_files=[] -- src imports not allowed
428428 , pm_annotations = hpm_annotations
429429 }
430− warnings = mapMaybe (mkDiag dflags "Parser") $ bagToList warns
430+ warnings = diagFromErrMsgs dflags warns
431431 pure (warnings, pm)
432432
433433
@@ -453,5 +453,5 @@ catchSrcErrors ghcM = do
453453 handleSourceError (sourceErrorToDiagnostics dflags) $
454454 Right <$> ghcM
455455 where
456− ghcExceptionToDiagnostics dflags = return . Left . mkErrorsGhcException dflags
457− sourceErrorToDiagnostics dflags = return . Left . toDiagnostics dflags . srcErrorMessages
456+ ghcExceptionToDiagnostics dflags = return . Left . diagFromGhcException dflags
457+ sourceErrorToDiagnostics dflags = return . Left . diagFromErrMsgs dflags . srcErrorMessages