phoityne-vscode 0.0.15.0 → 0.0.16.0
raw patch · 8 files changed
+128/−38 lines, 8 files
Files
- Changelog.md +5/−0
- README.md +6/−8
- app/Phoityne/GHCi/Command.hs +28/−6
- app/Phoityne/GHCi/Process.hs +23/−13
- app/Phoityne/VSCode/Argument.hs +11/−3
- app/Phoityne/VSCode/Control.hs +12/−7
- app/Phoityne/VSCode/Core.hs +42/−0
- phoityne-vscode.cabal +1/−1
Changelog.md view
@@ -1,4 +1,9 @@ +20170910 phoityne-vscode-0.0.16.0+ * [ADD] supported ghc-8.2.0.+ * [ADD] check hackage phoityen version, and show message for needs of updating.++ 20170816 phoityne-vscode-0.0.15.0 * [ADD] supported break-on-exception and break-on-error. * [ADD] [5](https://github.com/phoityne/phoityne-vscode/issues/5) :adding ghci run enviroment variable setting.
README.md view
@@ -7,15 +7,12 @@ ## Information -* [2017/08/16] phoityne-vscode released. - * Marketplace [phoityne-vscode-0.0.13](https://marketplace.visualstudio.com/items?itemName=phoityne.phoityne-vscode)- * hackage [phoityne-vscode-0.0.15.0](https://hackage.haskell.org/package/phoityne-vscode) +* [2017/09/10] phoityne-vscode released. + * Marketplace [phoityne-vscode-0.0.14](https://marketplace.visualstudio.com/items?itemName=phoityne.phoityne-vscode)+ * hackage [phoityne-vscode-0.0.16.0](https://hackage.haskell.org/package/phoityne-vscode) __Need update from hackage !!.__ * Release Summary- * [ADD] supported break-on-exception and break-on-error.- * [ADD] [5](https://github.com/phoityne/phoityne-vscode/issues/5) : adding ghci run enviroment variable setting. - __Check!! that there is a ""ghciEnv": {}," setting in the launch.json.__- * [MODIFY] [21](https://github.com/phoityne/phoityne-vscode/issues/21) : support evaluateName attribute for watch variable.+ * [ADD] supported ghc-8.2.0.  @@ -24,7 +21,8 @@ ## Important -* __LIMITATION__: Breakpoint can be set in a .hs file which defineds "module ... where".+* __LIMITATION__: Breakpoint can be set in a .hs file which defineds "module ... where". + Phoityne can handle modules which match its folder hierarchy and file name. * __LIMITATION__: Source file extension must be ".hs" * __LIMITATION__: Can not use STDIN handle while debugging. * __LIMITATION__: Changing ghci prompt is not allowed in the .ghci file.
app/Phoityne/GHCi/Command.hs view
@@ -6,7 +6,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-}- module Phoityne.GHCi.Command ( SourcePosition(..)@@ -45,7 +44,7 @@ import qualified Data.Map as M import qualified System.Exit as S import qualified Data.String.Utils as U-+import qualified Data.Version as V -- | --@@ -96,6 +95,7 @@ , endColNoSourcePosition :: Int } deriving (Show, Read, Eq, Ord) + -- | -- data StackFrame = StackFrame {@@ -133,16 +133,26 @@ setupGHCi _ (Left err) = return $ Left err setupGHCi ghci (Right msg) = do outHdl msg- setPrompt ghci+ case getGHCiVersion msg of+ Right v -> setPrompt ghci{versionGHCiProcess = v}+ Left m -> do+ outHdl "\n------------------------------------\n"+ outHdl m+ outHdl "\n------------------------------------\n"+ setPrompt ghci - setPrompt ghci@(GHCiProcess _ _ _ _ pmt) = set ghci outHdl ("prompt \"" ++ pmt ++ "\"") >>= \case+ setPrompt ghci@(GHCiProcess _ _ _ _ pmt v) = set ghci outHdl ("prompt \"" ++ pmt ++ "\"") >>= \case Left err -> return $ Left err- Right _ -> setPrompt2 ghci+ Right _ -> if v >= (V.Version [8, 2, 0] []) then setPromptCont ghci else setPrompt2 ghci - setPrompt2 ghci@(GHCiProcess _ _ _ _ pmt) = set ghci outHdl ("prompt2 \"" ++ pmt ++ "\"") >>= \case+ setPrompt2 ghci@(GHCiProcess _ _ _ _ pmt _) = set ghci outHdl ("prompt2 \"" ++ pmt ++ "\"") >>= \case Left err -> return $ Left err Right _ -> return $ Right ghci + setPromptCont ghci@(GHCiProcess _ _ _ _ pmt _) = set ghci outHdl ("prompt-cont \"" ++ pmt ++ "\"") >>= \case+ Left err -> return $ Left err+ Right _ -> return $ Right ghci+ endOfStartMsg msg | U.endswith _GHCI_PROMPT msg = True | endOfModLoadPrompt (last (lines msg)) = True@@ -156,6 +166,18 @@ char '*' >> manyTill anyChar (char '>') >> space >> eof return True + getGHCiVersion str = case parse getGHCiVersionParser "getGHCiVersion" str of+ Right v -> Right v+ Left e -> Left $ "can not parse ghci version. [" ++ show e ++ "] assumes " ++ V.showVersion _BASE_GHCI_VERSION ++ "."++ getGHCiVersionParser = do+ _ <- manyTill anyChar (try (string "GHCi, version "))+ v1 <- manyTill digit (char '.')+ v2 <- manyTill digit (char '.')+ v3 <- manyTill digit (char ':')+ return $ V.makeVersion [read v1, read v2, read v3]++ -- | -- quit :: GHCiProcess -> OutputHandler -> IO (Either ErrorData S.ExitCode)
app/Phoityne/GHCi/Process.hs view
@@ -8,6 +8,7 @@ module Phoityne.GHCi.Process ( ErrorData , GHCiProcess (..)+ , _BASE_GHCI_VERSION , runProcess , exitProcess , writeLine@@ -28,6 +29,7 @@ import qualified Control.Exception as E import qualified Data.String.Utils as U import qualified Data.Map as M+import qualified Data.Version as V -- | -- command error message.@@ -35,15 +37,23 @@ type ErrorData = String -- |+-- command error message.+--+_BASE_GHCI_VERSION :: V.Version+_BASE_GHCI_VERSION = V.Version [8, 0, 0] []+++-- | -- GHCi process data. -- data GHCiProcess = GHCiProcess {- inGHCiProcess :: S.Handle- , outGHCiProcess :: S.Handle- , errGHCiProcess :: S.Handle- , procGHCiProcess :: S.ProcessHandle- , promptGHCiProcess :: String+ inGHCiProcess :: S.Handle+ , outGHCiProcess :: S.Handle+ , errGHCiProcess :: S.Handle+ , procGHCiProcess :: S.ProcessHandle+ , promptGHCiProcess :: String+ , versionGHCiProcess :: V.Version } -- |@@ -82,7 +92,7 @@ ghciProc <- S.runProcess cmd opts (Just cwd) runEnvs (Just fromPhoityneHandle) (Just toPhoityneHandle) (Just toPhoityneHandle) - return . Right $ GHCiProcess toGHCiHandle fromGHCiHandle fromGHCiHandle ghciProc pmt+ return . Right $ GHCiProcess toGHCiHandle fromGHCiHandle fromGHCiHandle ghciProc pmt _BASE_GHCI_VERSION where handlers = [ E.Handler someExcept ]@@ -109,7 +119,7 @@ -- exit ghci. -- exitProcess :: GHCiProcess -> IO (Either ErrorData S.ExitCode)-exitProcess (GHCiProcess _ _ _ proc _) = flip E.catches handlers $ do+exitProcess (GHCiProcess _ _ _ proc _ _) = flip E.catches handlers $ do code <- S.waitForProcess proc return . Right $ code where@@ -120,7 +130,7 @@ -- write to ghci. -- writeLine :: GHCiProcess -> String -> IO (Either ErrorData ())-writeLine (GHCiProcess ghciIn _ _ _ _) writeData = flip E.catches handlers $ S.hIsOpen ghciIn >>= \case+writeLine (GHCiProcess ghciIn _ _ _ _ _) writeData = flip E.catches handlers $ S.hIsOpen ghciIn >>= \case True -> do S.hPutStrLn ghciIn writeData return $ Right ()@@ -133,7 +143,7 @@ -- read char till prompt. -- readTillPrompt :: GHCiProcess -> IO (Either ErrorData String)-readTillPrompt proc@(GHCiProcess _ _ _ _ pmt) = readCharWhile proc (not . U.endswith pmt)+readTillPrompt proc@(GHCiProcess _ _ _ _ pmt _) = readCharWhile proc (not . U.endswith pmt) -- | -- read char till EOF.@@ -146,7 +156,7 @@ -- read char from ghci. -- readCharWhile :: GHCiProcess -> (String -> Bool) -> IO (Either ErrorData String)-readCharWhile (GHCiProcess _ ghciOut _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case+readCharWhile (GHCiProcess _ ghciOut _ _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case True -> go [] False -> return . Left $ "handle not open." where@@ -165,7 +175,7 @@ -- read char from ghci. -- readCharWhileIO :: GHCiProcess -> (String -> IO Bool) -> IO (Either ErrorData String)-readCharWhileIO (GHCiProcess _ ghciOut _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case+readCharWhileIO (GHCiProcess _ ghciOut _ _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case True -> go [] False -> return . Left $ "handle not open." where@@ -185,7 +195,7 @@ -- read line from ghci. -- readLineWhile :: GHCiProcess -> ([String] -> Bool) -> IO (Either ErrorData [String])-readLineWhile (GHCiProcess _ ghciOut _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case+readLineWhile (GHCiProcess _ ghciOut _ _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case True -> go [] False -> return . Left $ "handle not open." where@@ -205,7 +215,7 @@ -- read line from ghci. -- readLineWhileIO :: GHCiProcess -> ([String] -> IO Bool) -> IO (Either ErrorData [String])-readLineWhileIO (GHCiProcess _ ghciOut _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case+readLineWhileIO (GHCiProcess _ ghciOut _ _ _ _) condProc = flip E.catches handlers $ S.hIsOpen ghciOut >>= \case True -> go [] False -> return . Left $ "handle not open." where
app/Phoityne/VSCode/Argument.hs view
@@ -12,8 +12,9 @@ import Paths_phoityne_vscode (version) import System.Console.CmdArgs import qualified Control.Exception as E-import Data.Version (showVersion)+import Data.Version + -- | -- data HelpExitException = HelpExitException@@ -23,8 +24,11 @@ -- | ---data ArgData = ModeA deriving (Data, Typeable, Show, Read, Eq)+data ArgData = ModeA {+ hackageVersion :: String+ } deriving (Data, Typeable, Show, Read, Eq) + -- | -- config :: ArgData@@ -34,7 +38,11 @@ where confA = ModeA {-+ hackageVersion = showVersion version+ &= name "hackage-version"+ &= typ "VERSION"+ &= explicit+ &= help "hackage module version." } &= name "ModeA" &= details mdAMsg &= auto
app/Phoityne/VSCode/Control.hs view
@@ -9,24 +9,25 @@ module Phoityne.VSCode.Control where +import System.IO+import Control.Concurrent+import Text.Parsec+import qualified Data.ConfigFile as C+import qualified System.Log.Logger as L+ import Phoityne.VSCode.Constant import Phoityne.VSCode.Utility import qualified Phoityne.VSCode.Argument as A import qualified Phoityne.VSCode.Core as GUI import qualified Data.ByteString.Lazy as BSL -import System.IO-import Control.Concurrent-import Text.Parsec-import qualified Data.ConfigFile as C-import qualified System.Log.Logger as L -- | -- run :: A.ArgData -> C.ConfigParser -> IO Int-run _ _ = do+run args _ = do hSetBuffering stdin NoBuffering hSetEncoding stdin utf8@@ -34,11 +35,15 @@ hSetBuffering stdout NoBuffering hSetEncoding stdout utf8 - mvarDat <- newMVar GUI.defaultDebugContextData {GUI.responseHandlerDebugContextData = sendResponse}+ mvarDat <- newMVar GUI.defaultDebugContextData {+ GUI.responseHandlerDebugContextData = sendResponse+ , GUI.hackagePackageVersionDebugContextData = A.hackageVersion args+ } wait mvarDat return 1+ -- | --
app/Phoityne/VSCode/Core.hs view
@@ -17,6 +17,7 @@ import qualified Phoityne.GHCi as G +import Paths_phoityne_vscode (version) import Control.Concurrent import Control.Monad import Data.List.Split@@ -39,6 +40,7 @@ import qualified System.Log.Formatter as L import qualified System.Log.Handler as LH import qualified System.Log.Handler.Simple as LHS+import qualified Data.Version as V import Phoityne.VSCode.Constant import Phoityne.VSCode.Utility@@ -128,6 +130,7 @@ , ghciProcessDebugContextData :: Maybe G.GHCiProcess , responseHandlerDebugContextData :: BSL.ByteString -> IO () , stopOnEntryDebugContextData :: Bool+ , hackagePackageVersionDebugContextData :: String } @@ -259,9 +262,22 @@ , " " ] + -- | -- --+_NEW_VERSION_MSG :: [String]+_NEW_VERSION_MSG = [+ ""+ , " New hackage module has been released."+ , " `stack update` and install new phoityen-vscode."+ , " "+ ]+++-- |+--+-- _NOT_PERMIT_REPL_COMMANDS :: [String] _NOT_PERMIT_REPL_COMMANDS = [ ":{"@@ -286,6 +302,7 @@ , ghciProcessDebugContextData = Nothing , responseHandlerDebugContextData = BSL.putStr , stopOnEntryDebugContextData = False+ , hackagePackageVersionDebugContextData = "" } @@ -663,6 +680,9 @@ withProcess (Just ghciProc) = do sendConsoleEvent mvarCtx $ L.intercalate "\n" _DEBUG_START_MSG++ checkVersion+ sendStdoutEvent mvarCtx $ G.promptGHCiProcess ghciProc resSeq <- getIncreasedResponseSequence mvarCtx@@ -677,6 +697,28 @@ stopEvtStr = J.encode stopEvt sendEvent mvarCtx stopEvtStr + checkVersion = do+ verStr <- hackagePackageVersionDebugContextData <$> (readMVar mvarCtx) + verArg <- case getVersion verStr of+ Right v -> return v+ Left err -> do+ sendErrorEvent mvarCtx $ "[checkVersion] argument version parse error. " ++ err+ return version++ when (version < verArg) $ do+ sendErrorEvent mvarCtx $ L.intercalate "\n" _NEW_VERSION_MSG+ + getVersion :: String -> Either String V.Version+ getVersion str = case parse getVersionParser "getVersionParser" str of+ Right v -> Right v+ Left e -> Left $ "can not parse hackage module version. " ++ show e++ getVersionParser = do+ v1 <- manyTill digit (char '.')+ v2 <- manyTill digit (char '.')+ v3 <- manyTill digit (char '.')+ v4 <- manyTill digit eof+ return $ V.makeVersion [read v1, read v2, read v3, read v4] -- | --
phoityne-vscode.cabal view
@@ -1,5 +1,5 @@ name: phoityne-vscode-version: 0.0.15.0+version: 0.0.16.0 synopsis: ghci debug viewer on Visual Studio Code description: Please see README.md license: BSD3