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