setTargetFiles now loads files.

This commit is contained in:
Kazu Yamamoto 2014-04-24 12:15:59 +09:00
parent 0c1469e53c
commit e49fef6765
4 changed files with 6 additions and 9 deletions

View File

@ -59,7 +59,6 @@ browse opt pkgmdl = do
fallback e = throwGhcException e
loadAndFind = do
setTargetFiles [mdl]
void $ G.load G.LoadAllTargets
G.findModule mdlname Nothing
-- |

View File

@ -1,8 +1,7 @@
module Language.Haskell.GhcMod.Check (checkSyntax, check) where
import Control.Monad (void)
import CoreMonad (liftIO)
import GHC (Ghc, LoadHowMuch(LoadAllTargets))
import GHC (Ghc)
import qualified GHC as G
import Language.Haskell.GhcMod.ErrMsg
import Language.Haskell.GhcMod.GHCApi
@ -37,7 +36,6 @@ check opt cradle fileNames = checkIt `G.gcatch` handleErrMsg opt
checkIt = do
(readLog,_) <- initializeFlagsWithCradle opt cradle options True
setTargetFiles fileNames
void $ G.load LoadAllTargets
liftIO readLog
options
| expandSplice opt = "-w:" : ghcOpts opt

View File

@ -16,13 +16,13 @@ import Language.Haskell.GhcMod.GHCChoice
import Language.Haskell.GhcMod.GhcPkg
import Control.Applicative ((<$>))
import Control.Monad (forM)
import Control.Monad (forM, void)
import CoreMonad (liftIO)
import Data.Maybe (isJust, fromJust)
import Distribution.PackageDescription (PackageDescription)
import DynFlags (dopt_set)
import Exception (ghandle, SomeException(..))
import GHC (Ghc, GhcMonad, DynFlags(..), GhcLink(..), HscTarget(..))
import GHC (Ghc, GhcMonad, DynFlags(..), GhcLink(..), HscTarget(..), LoadHowMuch(..))
import qualified GHC as G
import qualified Language.Haskell.GhcMod.Gap as Gap
import Language.Haskell.GhcMod.Types
@ -169,12 +169,13 @@ addCmdOpts cmdOpts df =
----------------------------------------------------------------
-- | Set the files that GHC will load / compile.
-- | Set the files and load
setTargetFiles :: (GhcMonad m) => [FilePath] -> m ()
setTargetFiles [] = error "ghc-mod: setTargetFiles: No target files given"
setTargetFiles files = do
targets <- forM files $ \file -> G.guessTarget file Nothing
G.setTargets targets
void $ G.load LoadAllTargets
-- | Adding the files to the targets.
addTargetFiles :: (GhcMonad m) => [FilePath] -> m ()

View File

@ -18,7 +18,7 @@ import Data.List (sortBy)
import Data.Maybe (catMaybes, fromMaybe)
import Data.Ord as O
import Exception (ghandle, SomeException(..))
import GHC (Ghc, LHsBind, LHsExpr, LPat, Id, TypecheckedModule(..), DynFlags, SrcSpan, Type, Located, TypecheckedSource, GenLocated(L), LoadHowMuch(..))
import GHC (Ghc, LHsBind, LHsExpr, LPat, Id, TypecheckedModule(..), DynFlags, SrcSpan, Type, Located, TypecheckedSource, GenLocated(L))
import qualified GHC as G
import GHC.SYB.Utils (Stage(TypeChecker), everythingStaged)
import Language.Haskell.GhcMod.Doc (showPage, showOneLine, getStyle)
@ -138,7 +138,6 @@ inModuleContext :: Options -> Cradle -> FilePath -> Ghc String -> Ghc String
inModuleContext opt cradle file action = do
void $ initializeFlagsWithCradle opt cradle noWaringOptions False
setTargetFiles [file]
void $ G.load LoadAllTargets
action
----------------------------------------------------------------