extract initializeGHC.
This commit is contained in:
parent
ce1123395b
commit
3b6848d7a5
15
Check.hs
15
Check.hs
@ -23,20 +23,9 @@ checkSyntax _ file = unlines <$> check file
|
||||
|
||||
check :: String -> IO [String]
|
||||
check fileName = withGHC $ do
|
||||
file <- initializeGHC fileName options
|
||||
setTargetFile file
|
||||
ref <- newRef []
|
||||
(owdir,mdirfile) <- getDirs
|
||||
case mdirfile of
|
||||
Nothing -> do
|
||||
initSession options Nothing
|
||||
setTargetFile fileName
|
||||
Just (cdir,cfile) -> do
|
||||
midirs <- parseCabalFile cfile
|
||||
changeToCabalDirectory cdir
|
||||
let idirs = case midirs of
|
||||
Nothing -> [cdir,owdir]
|
||||
Just dirs -> dirs ++ [owdir]
|
||||
initSession options (Just idirs)
|
||||
setTargetFile (ajustFileName fileName owdir cdir)
|
||||
loadWithLogger (refLogger ref) LoadAllTargets `gcatch` handleParseError ref
|
||||
clearWarnings
|
||||
readRef ref
|
||||
|
17
Info.hs
17
Info.hs
@ -1,18 +1,19 @@
|
||||
module Info where
|
||||
|
||||
import Cabal
|
||||
import Control.Applicative hiding (empty)
|
||||
import Control.Exception
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import GHC
|
||||
import HscTypes
|
||||
import NameSet
|
||||
import Outputable
|
||||
import PprTyThing
|
||||
import Types
|
||||
import NameSet
|
||||
import HscTypes
|
||||
import Data.List
|
||||
import Control.Exception
|
||||
import StringBuffer
|
||||
import System.Time
|
||||
import Types
|
||||
|
||||
type Expression = String
|
||||
type ModuleString = String
|
||||
@ -71,12 +72,12 @@ inModuleContext :: FilePath -> ModuleString -> Ghc String -> IO String
|
||||
inModuleContext fileName modstr action = withGHC valid
|
||||
where
|
||||
valid = do
|
||||
initSession ["-w"] Nothing
|
||||
setTargetFile fileName
|
||||
file <- initializeGHC fileName ["-w"]
|
||||
setTargetFile file
|
||||
loadWithLogger (\_ -> return ()) LoadAllTargets
|
||||
mif setContextFromTarget action invalid
|
||||
invalid = do
|
||||
initSession ["-w"] Nothing
|
||||
initializeGHC fileName ["-w"]
|
||||
setTargetBuffer
|
||||
loadWithLogger defaultWarnErrLogger LoadAllTargets
|
||||
mif setContextFromTarget action (return errorMessage)
|
||||
|
Loading…
Reference in New Issue
Block a user