Use new hlint API
This commit is contained in:
parent
306cb939a9
commit
dfa0e7e31e
@ -6,11 +6,10 @@ import Language.Haskell.GhcMod.Logger (checkErrorPrefix)
|
||||
import Language.Haskell.GhcMod.Convert
|
||||
import Language.Haskell.GhcMod.Types
|
||||
import Language.Haskell.GhcMod.Monad
|
||||
import Language.Haskell.HLint (hlint)
|
||||
import Language.Haskell.HLint3
|
||||
|
||||
import Language.Haskell.GhcMod.Utils (withMappedFile)
|
||||
|
||||
import Data.List (stripPrefix)
|
||||
import Language.Haskell.Exts.Pretty (prettyPrint)
|
||||
|
||||
-- | Checking syntax of a target file using hlint.
|
||||
-- Warnings and errors are returned.
|
||||
@ -18,12 +17,14 @@ lint :: IOish m
|
||||
=> LintOpts -- ^ Configuration parameters
|
||||
-> FilePath -- ^ A target file.
|
||||
-> GhcModT m String
|
||||
lint opt file =
|
||||
withMappedFile file $ \tempfile ->
|
||||
liftIO (hlint $ tempfile : "--quiet" : optLintHlintOpts opt)
|
||||
>>= mapM (replaceFileName tempfile)
|
||||
>>= ghandle handler . pack
|
||||
where
|
||||
lint opt file = ghandle handler $
|
||||
withMappedFile file $ \tempfile -> do
|
||||
(flags, classify, hint) <- liftIO $ argsSettings $ optLintHlintOpts opt
|
||||
res <- liftIO $ parseModuleEx flags file =<< Just `fmap` readFile tempfile
|
||||
case res of
|
||||
Right m -> pack . map show $ applyHints classify hint [m]
|
||||
Left ParseError{parseErrorLocation=loc, parseErrorMessage=err} ->
|
||||
return $ prettyPrint loc ++ ":Error:" ++ err ++ "\n"
|
||||
where
|
||||
pack = convert' . map init -- init drops the last \n.
|
||||
handler (SomeException e) = return $ checkErrorPrefix ++ show e ++ "\n"
|
||||
replaceFileName fp s = return $ maybe (show s) (file++) $ stripPrefix fp (show s)
|
||||
|
@ -167,7 +167,7 @@ Library
|
||||
, ghc < 7.11
|
||||
, ghc-paths < 0.2
|
||||
, ghc-syb-utils < 0.3
|
||||
, hlint < 1.10 && >= 1.8.61
|
||||
, hlint < 1.10 && >= 1.9.26
|
||||
, monad-journal < 0.8 && >= 0.4
|
||||
, old-time < 1.2
|
||||
, pretty < 1.2
|
||||
|
Loading…
Reference in New Issue
Block a user