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.Convert
|
||||||
import Language.Haskell.GhcMod.Types
|
import Language.Haskell.GhcMod.Types
|
||||||
import Language.Haskell.GhcMod.Monad
|
import Language.Haskell.GhcMod.Monad
|
||||||
import Language.Haskell.HLint (hlint)
|
import Language.Haskell.HLint3
|
||||||
|
|
||||||
import Language.Haskell.GhcMod.Utils (withMappedFile)
|
import Language.Haskell.GhcMod.Utils (withMappedFile)
|
||||||
|
import Language.Haskell.Exts.Pretty (prettyPrint)
|
||||||
import Data.List (stripPrefix)
|
|
||||||
|
|
||||||
-- | Checking syntax of a target file using hlint.
|
-- | Checking syntax of a target file using hlint.
|
||||||
-- Warnings and errors are returned.
|
-- Warnings and errors are returned.
|
||||||
@ -18,12 +17,14 @@ lint :: IOish m
|
|||||||
=> LintOpts -- ^ Configuration parameters
|
=> LintOpts -- ^ Configuration parameters
|
||||||
-> FilePath -- ^ A target file.
|
-> FilePath -- ^ A target file.
|
||||||
-> GhcModT m String
|
-> GhcModT m String
|
||||||
lint opt file =
|
lint opt file = ghandle handler $
|
||||||
withMappedFile file $ \tempfile ->
|
withMappedFile file $ \tempfile -> do
|
||||||
liftIO (hlint $ tempfile : "--quiet" : optLintHlintOpts opt)
|
(flags, classify, hint) <- liftIO $ argsSettings $ optLintHlintOpts opt
|
||||||
>>= mapM (replaceFileName tempfile)
|
res <- liftIO $ parseModuleEx flags file =<< Just `fmap` readFile tempfile
|
||||||
>>= ghandle handler . pack
|
case res of
|
||||||
where
|
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.
|
pack = convert' . map init -- init drops the last \n.
|
||||||
handler (SomeException e) = return $ checkErrorPrefix ++ show e ++ "\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 < 7.11
|
||||||
, ghc-paths < 0.2
|
, ghc-paths < 0.2
|
||||||
, ghc-syb-utils < 0.3
|
, ghc-syb-utils < 0.3
|
||||||
, hlint < 1.10 && >= 1.8.61
|
, hlint < 1.10 && >= 1.9.26
|
||||||
, monad-journal < 0.8 && >= 0.4
|
, monad-journal < 0.8 && >= 0.4
|
||||||
, old-time < 1.2
|
, old-time < 1.2
|
||||||
, pretty < 1.2
|
, pretty < 1.2
|
||||||
|
Loading…
Reference in New Issue
Block a user