Load all mapped targets
This commit is contained in:
parent
e70988e15f
commit
f8a0325617
@ -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
|
||||
|
@ -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,11 +165,14 @@ 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)
|
||||
liftM (nubBy ((==) `on` targetId))
|
||||
(mapM ((`guessTarget` Nothing) >=> mapFile env) targetStrs)
|
||||
>>= mapM relativize
|
||||
loadTargets targets
|
||||
action
|
||||
|
Loading…
Reference in New Issue
Block a user