Load all mapped targets

This commit is contained in:
Nikolay Yakimov 2015-06-16 11:28:46 +03:00
parent e70988e15f
commit f8a0325617
2 changed files with 12 additions and 3 deletions

View File

@ -53,6 +53,7 @@ module Language.Haskell.GhcMod.Monad.Types (
, addMMappedFile
, delMMappedFile
, lookupMMappedFile
, getMMappedFilePaths
-- * Re-exporting convenient stuff
, MonadIO
, liftIO
@ -464,6 +465,9 @@ lookupMMappedFile :: GmState m => FilePath -> m (Maybe FileMapping)
lookupMMappedFile t =
M.lookup t `liftM` getMMappedFiles
getMMappedFilePaths :: GmState m => m [FilePath]
getMMappedFilePaths = M.keys `liftM` getMMappedFiles
withOptions :: GmEnv m => (Options -> Options) -> m a -> m a
withOptions changeOpt action = gmeLocal changeEnv action
where

View File

@ -53,6 +53,8 @@ import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.List (nubBy)
import Data.Function (on)
import Distribution.Helper
import Prelude hiding ((.))
@ -163,12 +165,15 @@ runGmlTWith efnmns' mdf wrapper action = do
initSession opts' $
setModeSimple >>> setEmptyLogger >>> mdf
mappedStrs <- getMMappedFilePaths
let targetStrs = mappedStrs ++ map moduleNameString mns ++ cfns
unGmlT $ wrapper $ do
targets <-
withLightHscEnv opts $ \env ->
mapM (`guessTarget` Nothing) (map moduleNameString mns ++ cfns)
>>= mapM (mapFile env)
>>= mapM relativize
liftM (nubBy ((==) `on` targetId))
(mapM ((`guessTarget` Nothing) >=> mapFile env) targetStrs)
>>= mapM relativize
loadTargets targets
action
where