@@ -7,7 +7,7 @@
8-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
8-- | Based on https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/API.
9-- Given a list of paths to find libraries, and a file to compile, produce a list of 'CoreModule' values.
9-- 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
11 ( GhcModule(..)
11 ( GhcModule(..)
12 , TcModuleResult(..)
12 , TcModuleResult(..)
13 , LoadPackageResult(..)
13 , LoadPackageResult(..)
@@ -20,21 +20,21 @@ module Development.IDE.Functions.Compile
20 , computePackageDeps
20 , computePackageDeps
23−import Development.IDE.Functions.Warnings
23+import Development.IDE.GHC.Warnings
24−import Development.IDE.Functions.CPP
24+import Development.IDE.GHC.CPP
25import Development.IDE.Types.Diagnostics
25import Development.IDE.Types.Diagnostics
26−import qualified Development.IDE.Functions.FindImports as FindImports
26+import qualified Development.IDE.Import.FindImports as FindImports
27−import Development.IDE.Functions.GHCError
27+import Development.IDE.GHC.Error
28−import Development.IDE.Functions.SpanInfo
28+import Development.IDE.Spans.Calculate
29−import Development.IDE.UtilGHC
29+import Development.IDE.GHC.Util
30−import Development.IDE.Compat
30+import Development.IDE.GHC.Compat
31import Development.IDE.Types.Options
31import Development.IDE.Types.Options
32import Development.IDE.Types.Location
32import Development.IDE.Types.Location
34import GHC hiding (parseModule, typecheckModule)
34import GHC hiding (parseModule, typecheckModule)
35import qualified Parser
35import qualified Parser
36import Lexer
36import Lexer
37−import Bag
37+import ErrUtils
39import qualified GHC
39import qualified GHC
40import Panic
40import Panic
@@ -56,7 +56,7 @@ import Data.List.Extra
56import Data.Maybe
56import Data.Maybe
57import Data.Tuple.Extra
57import Data.Tuple.Extra
58import qualified Data.Map.Strict as Map
58import qualified Data.Map.Strict as Map
59−import Development.IDE.Types.SpanInfo
59+import Development.IDE.Spans.Type
60import GHC.Generics (Generic)
60import GHC.Generics (Generic)
61import System.FilePath
61import System.FilePath
62import System.Directory
62import System.Directory
@@ -143,7 +143,7 @@ typecheckModule opt packageState deps pm =
143 runGhcSessionExcept opt (Just pm) packageState $
143 runGhcSessionExcept opt (Just pm) packageState $
144 catchSrcErrors $ do
144 catchSrcErrors $ do
145 setupEnv deps
145 setupEnv deps
146− (warnings, tcm) <- withWarnings "Typechecker" $ \tweak ->
146+ (warnings, tcm) <- withWarnings $ \tweak ->
147 GHC.typecheckModule pm{pm_mod_summary = tweak $ pm_mod_summary pm}
147 GHC.typecheckModule pm{pm_mod_summary = tweak $ pm_mod_summary pm}
148 tcm2 <- mkTcModuleResult (WriteInterface $ optWriteIface opt) tcm
148 tcm2 <- mkTcModuleResult (WriteInterface $ optWriteIface opt) tcm
149 return (warnings, tcm2)
149 return (warnings, tcm2)
@@ -182,7 +182,7 @@ compileModule opt mod packageState deps tmr =
183 let tm = tmrModule tmr
183 let tm = tmrModule tmr
184 session <- getSession
184 session <- getSession
185− (warnings,desugar) <- withWarnings "Desugarer" $ \tweak -> do
185+ (warnings,desugar) <- withWarnings $ \tweak -> do
186 let pm = tm_parsed_module tm
186 let pm = tm_parsed_module tm
187 let pm' = pm{pm_mod_summary = tweak $ pm_mod_summary pm}
187 let pm' = pm{pm_mod_summary = tweak $ pm_mod_summary pm}
188 let tm' = tm{tm_parsed_module = pm'}
188 let tm' = tm{tm_parsed_module = pm'}
@@ -395,7 +395,7 @@ parseFileContents preprocessor filename contents = do
396 case unP Parser.parseModule (mkPState dflags contents loc) of
396 case unP Parser.parseModule (mkPState dflags contents loc) of
397 PFailed _ locErr msgErr ->
397 PFailed _ locErr msgErr ->
398− Ex.throwE $ mkErrorDoc dflags locErr msgErr
398+ Ex.throwE $ diagFromErrMsg dflags $ mkPlainErrMsg dflags locErr msgErr
399 POk pst rdr_module ->
399 POk pst rdr_module ->
400 let hpm_annotations =
400 let hpm_annotations =
401 (Map.fromListWith (++) $ annotations pst,
401 (Map.fromListWith (++) $ annotations pst,
@@ -414,11 +414,11 @@ parseFileContents preprocessor filename contents = do
414 -- errors are those from which a parse tree just can't
414 -- errors are those from which a parse tree just can't
415 -- be produced.
415 -- be produced.
416 unless (null errs) $
416 unless (null errs) $
417− Ex.throwE $ toDiagnostics dflags $ snd $ getMessages pst dflags
417+ Ex.throwE $ diagFromErrMsgs dflags $ snd $ getMessages pst dflags
419 -- Ok, we got here. It's safe to continue.
419 -- Ok, we got here. It's safe to continue.
420 let (errs, parsed) = preprocessor rdr_module
420 let (errs, parsed) = preprocessor rdr_module
421− unless (null errs) $ Ex.throwE $ mkErrors dflags errs
421+ unless (null errs) $ Ex.throwE $ diagFromStrings errs
422 ms <- getModSummaryFromBuffer filename contents dflags parsed
422 ms <- getModSummaryFromBuffer filename contents dflags parsed
424 ParsedModule {
424 ParsedModule {
@@ -427,7 +427,7 @@ parseFileContents preprocessor filename contents = do
427 , pm_extra_src_files=[] -- src imports not allowed
427 , pm_extra_src_files=[] -- src imports not allowed
428 , pm_annotations = hpm_annotations
428 , pm_annotations = hpm_annotations
430− warnings = mapMaybe (mkDiag dflags "Parser") $ bagToList warns
430+ warnings = diagFromErrMsgs dflags warns
431 pure (warnings, pm)
431 pure (warnings, pm)
@@ -453,5 +453,5 @@ catchSrcErrors ghcM = do
453 handleSourceError (sourceErrorToDiagnostics dflags) $
453 handleSourceError (sourceErrorToDiagnostics dflags) $
454 Right <$> ghcM
454 Right <$> ghcM
456− ghcExceptionToDiagnostics dflags = return . Left . mkErrorsGhcException dflags
456+ ghcExceptionToDiagnostics dflags = return . Left . diagFromGhcException dflags
457− sourceErrorToDiagnostics dflags = return . Left . toDiagnostics dflags . srcErrorMessages
457+ sourceErrorToDiagnostics dflags = return . Left . diagFromErrMsgs dflags . srcErrorMessages