refactoring.
This commit is contained in:
parent
8142ccbc64
commit
9c7c6a5cf9
@ -16,7 +16,7 @@ import Language.Haskell.GhcMod.GHCChoice
|
||||
import Language.Haskell.GhcMod.GhcPkg
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad (forM, void, unless)
|
||||
import Control.Monad (forM, void)
|
||||
import CoreMonad (liftIO)
|
||||
import Data.Maybe (isJust, fromJust)
|
||||
import Exception (ghandle, SomeException(..))
|
||||
@ -154,7 +154,6 @@ addCmdOpts cmdOpts df =
|
||||
setTargetFiles :: (GhcMonad m) => [FilePath] -> m ()
|
||||
setTargetFiles files = do
|
||||
targets <- forM files $ \file -> G.guessTarget file Nothing
|
||||
unless (null targets) $ do
|
||||
G.setTargets targets
|
||||
void $ G.load LoadAllTargets
|
||||
|
||||
@ -162,7 +161,8 @@ setTargetFiles files = do
|
||||
addTargetFiles :: (GhcMonad m) => [FilePath] -> m ()
|
||||
addTargetFiles files = do
|
||||
targets <- forM files $ \file -> G.guessTarget file Nothing
|
||||
unless (null targets) $ mapM_ G.addTarget targets
|
||||
mapM_ G.addTarget targets
|
||||
void $ G.load LoadAllTargets
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
|
@ -31,7 +31,7 @@ import qualified Data.Set as S
|
||||
import Data.Typeable (Typeable)
|
||||
import Data.Version (showVersion)
|
||||
import qualified Exception as GE
|
||||
import GHC (Ghc, LoadHowMuch(LoadAllTargets), TargetId(TargetFile))
|
||||
import GHC (Ghc, TargetId(TargetFile))
|
||||
import qualified GHC as G
|
||||
import HscTypes (SourceError)
|
||||
import Language.Haskell.GhcMod
|
||||
@ -169,9 +169,8 @@ checkStx :: Options
|
||||
checkStx opt set file = do
|
||||
GE.ghandle handler $ do
|
||||
(set',add) <- removeMainTarget file set
|
||||
ret <- withLogger opt $ do
|
||||
when add $ addTargetFiles [file]
|
||||
void $ G.load LoadAllTargets
|
||||
let files = if add then [file] else []
|
||||
ret <- withLogger opt $ addTargetFiles files
|
||||
return (ret, True, set')
|
||||
where
|
||||
handler :: SourceError -> Ghc (String, Bool, Set FilePath)
|
||||
|
Loading…
Reference in New Issue
Block a user