check + expand: Allow passing in multiple files
This commit is contained in:
@@ -16,9 +16,14 @@ import Prelude
|
||||
-- Warnings and errors are returned.
|
||||
checkSyntax :: Options
|
||||
-> Cradle
|
||||
-> FilePath -- ^ A target file
|
||||
-> [FilePath] -- ^ The target files
|
||||
-> IO String
|
||||
checkSyntax opt cradle file = unlines <$> withGHC file (check opt cradle file)
|
||||
checkSyntax _ _ [] = error "ghc-mod: checkSyntax: No files given"
|
||||
checkSyntax opt cradle files = unlines <$> withGHC sessionName (check opt cradle files)
|
||||
where
|
||||
sessionName = case files of
|
||||
[file] -> file
|
||||
_ -> "MultipleFiles"
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@@ -26,13 +31,14 @@ checkSyntax opt cradle file = unlines <$> withGHC file (check opt cradle file)
|
||||
-- Warnings and errors are returned.
|
||||
check :: Options
|
||||
-> Cradle
|
||||
-> FilePath -- ^ A target file
|
||||
-> [FilePath] -- ^ The target files
|
||||
-> Ghc [String]
|
||||
check opt cradle fileName = checkIt `gcatch` handleErrMsg ls
|
||||
check _ _ [] = error "ghc-mod: check: No files given"
|
||||
check opt cradle fileNames = checkIt `gcatch` handleErrMsg ls
|
||||
where
|
||||
checkIt = do
|
||||
readLog <- initializeFlagsWithCradle opt cradle options True
|
||||
setTargetFile fileName
|
||||
setTargetFiles fileNames
|
||||
checkSlowAndSet
|
||||
void $ load LoadAllTargets
|
||||
liftIO readLog
|
||||
|
||||
@@ -36,7 +36,7 @@ debug opt cradle ver fileName = do
|
||||
return (ghcOpts opt, [], [])
|
||||
[fast] <- do
|
||||
void $ initializeFlagsWithCradle opt cradle gopts True
|
||||
setTargetFile fileName
|
||||
setTargetFiles [fileName]
|
||||
pure . canCheckFast <$> depanal [] False
|
||||
return [
|
||||
"GHC version: " ++ ver
|
||||
|
||||
@@ -5,7 +5,7 @@ module Language.Haskell.GhcMod.GHCApi (
|
||||
, withGHCDummyFile
|
||||
, initializeFlags
|
||||
, initializeFlagsWithCradle
|
||||
, setTargetFile
|
||||
, setTargetFiles
|
||||
, getDynamicFlags
|
||||
, setSlowDynFlags
|
||||
, checkSlowAndSet
|
||||
@@ -154,11 +154,12 @@ modifyFlagsWithOpts dflags cmdOpts =
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- | Set the file that GHC will load / compile
|
||||
setTargetFile :: (GhcMonad m) => String -> m ()
|
||||
setTargetFile file = do
|
||||
target <- guessTarget file Nothing
|
||||
setTargets [target]
|
||||
-- | Set the files that GHC will load / compile
|
||||
setTargetFiles :: (GhcMonad m) => [String] -> m ()
|
||||
setTargetFiles [] = error "ghc-mod: setTargetFiles: No target files given"
|
||||
setTargetFiles files = do
|
||||
targets <- forM files $ \file -> guessTarget file Nothing
|
||||
setTargets targets
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ inModuleContext cmd opt cradle file modstr action errmsg =
|
||||
valid = do
|
||||
void $ initializeFlagsWithCradle opt cradle ["-w:"] False
|
||||
when (cmd == Info) setSlowDynFlags
|
||||
setTargetFile file
|
||||
setTargetFiles [file]
|
||||
checkSlowAndSet
|
||||
void $ load LoadAllTargets
|
||||
doif setContextFromTarget action
|
||||
|
||||
@@ -5,7 +5,7 @@ module Language.Haskell.GhcMod.Internal (
|
||||
LogReader
|
||||
, GHCOption
|
||||
, initializeFlagsWithCradle
|
||||
, setTargetFile
|
||||
, setTargetFiles
|
||||
, checkSlowAndSet
|
||||
, getDynamicFlags
|
||||
) where
|
||||
|
||||
Reference in New Issue
Block a user