check + expand: Allow passing in multiple files

This commit is contained in:
Niklas Hambüchen
2013-08-21 17:21:49 +09:00
parent e7d746f115
commit 4758a6043c
7 changed files with 30 additions and 22 deletions

View File

@@ -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