Ghc -> GhcMod: Browse, Check

This commit is contained in:
Daniel Gröber
2014-05-10 15:10:34 +02:00
parent e5c6d3e472
commit f1535efcf2
10 changed files with 109 additions and 70 deletions

View File

@@ -9,6 +9,7 @@ import qualified Control.Exception as E
import Data.Typeable (Typeable)
import Data.Version (showVersion)
import Language.Haskell.GhcMod
import Language.Haskell.GhcMod.Monad
import Paths_ghc_mod
import System.Console.GetOpt (OptDescr(..), ArgDescr(..), ArgOrder(..))
import qualified System.Console.GetOpt as O
@@ -112,8 +113,8 @@ main = flip E.catches handlers $ do
"list" -> listModules opt cradle
"lang" -> listLanguages opt
"flag" -> listFlags opt
"browse" -> concat <$> mapM (browseModule opt cradle) remainingArgs
"check" -> checkSyntax opt cradle remainingArgs
"browse" -> runGhcMod opt $ concat <$> mapM browse remainingArgs
"check" -> runGhcMod opt $ checkSyntax remainingArgs
"expand" -> expandTemplate opt cradle remainingArgs
"debug" -> debugInfo opt cradle
"info" -> nArgs 3 infoExpr opt cradle cmdArg1 cmdArg3

View File

@@ -139,13 +139,13 @@ loop opt set mvar = do
let (cmd,arg') = break (== ' ') cmdArg
arg = dropWhile (== ' ') arg'
(ret,ok,set') <- case cmd of
"check" -> toGhcMod $ checkStx opt set arg
"check" -> checkStx opt set arg
"find" -> toGhcMod $ findSym opt set arg mvar
"lint" -> toGhcMod $ lintStx opt set arg
"info" -> toGhcMod $ showInfo opt set arg
"type" -> toGhcMod $ showType opt set arg
"boot" -> bootIt set
"browse" -> toGhcMod $ browseIt opt set arg
"browse" -> browseIt set arg
"quit" -> return ("quit", False, set)
"" -> return ("quit", False, set)
_ -> return ([], True, set)
@@ -162,11 +162,11 @@ loop opt set mvar = do
checkStx :: Options
-> Set FilePath
-> FilePath
-> Ghc (String, Bool, Set FilePath)
checkStx opt set file = do
set' <- newFileSet set file
-> GhcMod (String, Bool, Set FilePath)
checkStx _ set file = do
set' <- toGhcMod $ newFileSet set file
let files = S.toList set'
eret <- check opt files
eret <- check files
case eret of
Right ret -> return (ret, True, set')
Left ret -> return (ret, True, set) -- fxime: set
@@ -261,10 +261,9 @@ bootIt set = do
ret <- boot
return (ret, True, set)
browseIt :: Options
-> Set FilePath
browseIt :: Set FilePath
-> ModuleString
-> Ghc (String, Bool, Set FilePath)
browseIt opt set mdl = do
ret <- browse opt mdl
-> GhcMod (String, Bool, Set FilePath)
browseIt set mdl = do
ret <- browse mdl
return (ret, True, set)