implement includes options for check

This commit is contained in:
Andrew Sackville-West 2011-08-02 11:18:07 -07:00
parent b09a8fb2ee
commit b6d99e279c
4 changed files with 21 additions and 4 deletions

View File

@ -31,7 +31,7 @@ check opt fileName = withGHC $ do
clearWarnings clearWarnings
readRef ref readRef ref
where where
options = ["-Wall","-fno-warn-unused-do-bind"] options = ["-Wall","-fno-warn-unused-do-bind"] ++ map ((++) "-i") (checkIncludes opt)
handleParseError ref e = do handleParseError ref e = do
liftIO . writeIORef ref $ errBagToStrList . srcErrorMessages $ e liftIO . writeIORef ref $ errBagToStrList . srcErrorMessages $ e
return Succeeded return Succeeded

View File

@ -26,7 +26,7 @@ usage = "ghc-mod version 0.6.0\n"
++ "\t ghc-mod list [-l]\n" ++ "\t ghc-mod list [-l]\n"
++ "\t ghc-mod lang [-l]\n" ++ "\t ghc-mod lang [-l]\n"
++ "\t ghc-mod browse [-l] [-o] <module> [<module> ...]\n" ++ "\t ghc-mod browse [-l] [-o] <module> [<module> ...]\n"
++ "\t ghc-mod check <HaskellFile>\n" ++ "\t ghc-mod check [-i inc] <HaskellFile>\n"
++ "\t ghc-mod type <HaskellFile> <module> <expression>\n" ++ "\t ghc-mod type <HaskellFile> <module> <expression>\n"
++ "\t ghc-mod info <HaskellFile> <module> <expression>\n" ++ "\t ghc-mod info <HaskellFile> <module> <expression>\n"
++ "\t ghc-mod lint [-h opt] <HaskellFile>\n" ++ "\t ghc-mod lint [-h opt] <HaskellFile>\n"
@ -39,6 +39,7 @@ defaultOptions :: Options
defaultOptions = Options { defaultOptions = Options {
convert = toPlain convert = toPlain
, hlintOpts = [] , hlintOpts = []
, checkIncludes = []
, operators = False , operators = False
, packageConfs = [] , packageConfs = []
, useUserPackageConf = True , useUserPackageConf = True
@ -60,6 +61,9 @@ argspec = [ Option "l" ["tolisp"]
, Option "" ["no-user-package-conf"] , Option "" ["no-user-package-conf"]
(NoArg (\opts -> opts{ useUserPackageConf = False })) (NoArg (\opts -> opts{ useUserPackageConf = False }))
"do not read the user package database" "do not read the user package database"
, Option "i" ["include"]
(ReqArg (\i opts -> opts{ checkIncludes = i : (checkIncludes opts)}) "include")
"directory to include in search for modules"
] ]
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String]) parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])

View File

@ -11,6 +11,7 @@ import GHC.Paths (libdir)
data Options = Options { data Options = Options {
convert :: [String] -> String convert :: [String] -> String
, hlintOpts :: [String] , hlintOpts :: [String]
, checkIncludes :: [String]
, operators :: Bool , operators :: Bool
, packageConfs :: [FilePath] , packageConfs :: [FilePath]
, useUserPackageConf :: Bool , useUserPackageConf :: Bool

View File

@ -16,6 +16,15 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcustom ghc-flymake-check-includes nil
"list of directories to include when checking file"
:type '(repeat string)
:risky nil
:require 'ghc-flymake
:group 'ghc-flymake)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst ghc-error-buffer-name "*GHC Errors*") (defconst ghc-error-buffer-name "*GHC Errors*")
(defconst ghc-flymake-allowed-file-name-masks (defconst ghc-flymake-allowed-file-name-masks
@ -44,7 +53,10 @@
(if ghc-flymake-command (if ghc-flymake-command
(let ((hopts (ghc-mapconcat (lambda (x) (list "-h" x)) opts))) (let ((hopts (ghc-mapconcat (lambda (x) (list "-h" x)) opts)))
`(,@hopts "lint" ,file)) `(,@hopts "lint" ,file))
(list "check" file))) (if (null ghc-flymake-check-includes)
(list "check" file)
(let ((includes (ghc-mapconcat (lambda (x) (list "-i" x)) ghc-flymake-check-includes)))
`("check" ,@includes ,file)))))
(defun ghc-flymake-toggle-command () (defun ghc-flymake-toggle-command ()
(interactive) (interactive)