ide-backend-common 0.9.1.3 → 0.10.0
raw patch · 8 files changed
+94/−31 lines, 8 filesdep +monad-loggernew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies added: monad-logger
API changes (from Hackage documentation)
- IdeSession.GHC.API: ideSessionDistDir :: FilePath -> FilePath
+ IdeSession.GHC.Requests: ghcInitDistDir :: GhcInitRequest -> !FilePath
+ IdeSession.GHC.Requests: ghcInitSourceDir :: GhcInitRequest -> FilePath
+ IdeSession.GHC.Requests: instance Selector S1_0_6GhcInitRequest
+ IdeSession.GHC.Requests: instance Selector S1_0_7GhcInitRequest
+ IdeSession.Types.Progress: instance FromJSON Progress
+ IdeSession.Types.Progress: instance ToJSON Progress
+ IdeSession.Types.Public: UpdateStatusCrashRestart :: Text -> UpdateStatus
+ IdeSession.Types.Public: UpdateStatusDone :: UpdateStatus
+ IdeSession.Types.Public: UpdateStatusFailed :: Text -> UpdateStatus
+ IdeSession.Types.Public: UpdateStatusProgress :: Progress -> UpdateStatus
+ IdeSession.Types.Public: UpdateStatusRequiredRestart :: UpdateStatus
+ IdeSession.Types.Public: UpdateStatusServerDied :: Text -> UpdateStatus
+ IdeSession.Types.Public: data UpdateStatus
+ IdeSession.Types.Public: instance Constructor C1_0UpdateStatus
+ IdeSession.Types.Public: instance Constructor C1_1UpdateStatus
+ IdeSession.Types.Public: instance Constructor C1_2UpdateStatus
+ IdeSession.Types.Public: instance Constructor C1_3UpdateStatus
+ IdeSession.Types.Public: instance Constructor C1_4UpdateStatus
+ IdeSession.Types.Public: instance Constructor C1_5UpdateStatus
+ IdeSession.Types.Public: instance Datatype D1UpdateStatus
+ IdeSession.Types.Public: instance Eq UpdateStatus
+ IdeSession.Types.Public: instance FromJSON UpdateStatus
+ IdeSession.Types.Public: instance Generic UpdateStatus
+ IdeSession.Types.Public: instance PrettyVal UpdateStatus
+ IdeSession.Types.Public: instance Show UpdateStatus
+ IdeSession.Types.Public: instance ToJSON UpdateStatus
+ IdeSession.Types.Public: instance Typeable UpdateStatus
+ IdeSession.Util.Logger: logDebug :: Q Exp
+ IdeSession.Util.Logger: logError :: Q Exp
+ IdeSession.Util.Logger: logInfo :: Q Exp
+ IdeSession.Util.Logger: logOther :: Text -> Q Exp
+ IdeSession.Util.Logger: logWarn :: Q Exp
+ IdeSession.Util.Logger: type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- IdeSession.GHC.Requests: GhcInitRequest :: Int -> Bool -> [String] -> Bool -> [String] -> FilePath -> GhcInitRequest
+ IdeSession.GHC.Requests: GhcInitRequest :: Int -> Bool -> [String] -> Bool -> [String] -> FilePath -> FilePath -> !FilePath -> GhcInitRequest
Files
- IdeSession/GHC/API.hs +3/−6
- IdeSession/GHC/Requests.hs +6/−0
- IdeSession/RPC/Stream.hs +9/−6
- IdeSession/Types/Progress.hs +4/−1
- IdeSession/Types/Public.hs +32/−16
- IdeSession/Util/Logger.hs +31/−0
- README.md +5/−0
- ide-backend-common.cabal +4/−2
IdeSession/GHC/API.hs view
@@ -18,7 +18,6 @@ -- * Paths , ideSessionSourceDir , ideSessionDataDir- , ideSessionDistDir , ideSessionObjDir ) where @@ -32,7 +31,7 @@ -- We use a Unix timestamp for this so that these API versions have some -- semantics (http://www.epochconverter.com/, GMT). ideBackendApiVersion :: Int-ideBackendApiVersion = 1426765899+ideBackendApiVersion = 1438736884 {------------------------------------------------------------------------------ Configuration@@ -75,15 +74,13 @@ -- | The directory to use for managing source files. ideSessionSourceDir :: FilePath -> FilePath ideSessionSourceDir sessionDir = sessionDir </> "src"+{-# WARNING ideSessionSourceDir "If configLocalWorkingDir is set, then this does not yield the proper source directory" #-} -- | The directory to use for data files that may be accessed by the -- running program. The running program will have this as its CWD. ideSessionDataDir :: FilePath -> FilePath ideSessionDataDir sessionDir = sessionDir </> "data"---- | Cabal "dist" prefix.-ideSessionDistDir :: FilePath -> FilePath-ideSessionDistDir sessionDir = sessionDir </> "dist"+{-# WARNING ideSessionDataDir "If configLocalWorkingDir is set, then this does not yield the proper source directory" #-} -- | Directory where we store compiled C files (objects) ideSessionObjDir :: FilePath -> FilePath
IdeSession/GHC/Requests.hs view
@@ -32,6 +32,8 @@ , ghcInitUserPackageDB :: Bool , ghcInitSpecificPackageDBs :: [String] , ghcInitSessionDir :: FilePath+ , ghcInitSourceDir :: FilePath+ , ghcInitDistDir :: !FilePath } deriving (Typeable, Generic) @@ -105,8 +107,12 @@ put ghcInitUserPackageDB put ghcInitSpecificPackageDBs put ghcInitSessionDir+ put ghcInitSourceDir+ put ghcInitDistDir get = GhcInitRequest <$> get+ <*> get+ <*> get <*> get <*> get <*> get
IdeSession/RPC/Stream.hs view
@@ -25,20 +25,23 @@ return $ Stream h st nextInStream :: forall a. Stream a -> IO a-nextInStream (Stream h st) = readIORef st >>= go+nextInStream (Stream h st) = readIORef st >>= go False where- go :: Binary.Decoder a -> IO a- go decoder = case decoder of+ go :: Bool -> Binary.Decoder a -> IO a+ go atEnd decoder = case decoder of Binary.Fail _ _ err -> do writeIORef st decoder- Ex.throwIO (userError err)+ Ex.throwIO $ userError $+ if atEnd+ then "IdeSession.RPC.Stream ended, causing " ++ err+ else "IdeSession.RPC.Stream decode failure: " ++ err Binary.Partial k -> do mchunk <- Ex.try $ BSS.hGetSome h BSL.defaultChunkSize case mchunk of Left ex -> do writeIORef st decoder Ex.throwIO (ex :: Ex.SomeException)- Right chunk | BSS.null chunk -> go . k $ Nothing- | otherwise -> go . k $ Just chunk+ Right chunk | BSS.null chunk -> go True . k $ Nothing+ | otherwise -> go False . k $ Just chunk Binary.Done unused _numConsumed a -> do writeIORef st $ contDecoder unused return a
IdeSession/Types/Progress.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveGeneric, RecordWildCards #-}+{-# LANGUAGE DeriveGeneric, RecordWildCards, TemplateHaskell #-} module IdeSession.Types.Progress ( Progress(..) ) where@@ -10,6 +10,7 @@ import GHC.Generics (Generic) import qualified Data.Text as Text import Text.Show.Pretty (PrettyVal)+import Data.Aeson.TH (deriveJSON, defaultOptions) import IdeSession.Util () -- instance Binary Text @@ -59,3 +60,5 @@ where pad :: Maybe Text -> Maybe String pad = fmap $ \t -> " " ++ Text.unpack t++$(deriveJSON defaultOptions ''Progress)
IdeSession/Types/Public.hs view
@@ -27,6 +27,7 @@ , Value , VariableEnv , Targets(..)+ , UpdateStatus(..) -- * Util , idInfoQN --, idInfoAtLocation@@ -44,6 +45,7 @@ import IdeSession.Util () -- Binary instance for Text import IdeSession.Util.PrettyVal+import IdeSession.Types.Progress {------------------------------------------------------------------------------ Types@@ -251,6 +253,16 @@ data Targets = TargetsInclude [FilePath] | TargetsExclude [FilePath] deriving (Typeable, Generic, Eq, Show) +-- | This type represents the status of the compilation from an IDE update.+data UpdateStatus =+ UpdateStatusFailed Text+ | UpdateStatusRequiredRestart+ | UpdateStatusCrashRestart Text+ | UpdateStatusServerDied Text+ | UpdateStatusProgress Progress+ | UpdateStatusDone+ deriving (Typeable, Generic, Eq, Show)+ {------------------------------------------------------------------------------ Show instances ------------------------------------------------------------------------------}@@ -482,22 +494,25 @@ internally. ------------------------------------------------------------------------------} -$(deriveJSON defaultOptions ''IdNameSpace)-$(deriveJSON defaultOptions ''SourceErrorKind)-$(deriveJSON defaultOptions ''ImportEntities)-$(deriveJSON defaultOptions ''Import)-$(deriveJSON defaultOptions ''SourceError)-$(deriveJSON defaultOptions ''IdProp)-$(deriveJSON defaultOptions ''IdScope)-$(deriveJSON defaultOptions ''SourceSpan)-$(deriveJSON defaultOptions ''EitherSpan)-$(deriveJSON defaultOptions ''ModuleId)-$(deriveJSON defaultOptions ''PackageId)-$(deriveJSON defaultOptions ''IdInfo)-$(deriveJSON defaultOptions ''SpanInfo)-$(deriveJSON defaultOptions ''BreakInfo)-$(deriveJSON defaultOptions ''RunResult)-$(deriveJSON defaultOptions ''RunBufferMode)+$(concat <$> mapM (deriveJSON defaultOptions)+ [ ''BreakInfo+ , ''EitherSpan+ , ''IdInfo+ , ''IdNameSpace+ , ''IdProp+ , ''IdScope+ , ''Import+ , ''ImportEntities+ , ''ModuleId+ , ''PackageId+ , ''RunBufferMode+ , ''RunResult+ , ''SourceError+ , ''SourceErrorKind+ , ''SourceSpan+ , ''SpanInfo+ , ''UpdateStatus+ ]) {------------------------------------------------------------------------------ PrettyVal instances (these rely on Generics)@@ -520,6 +535,7 @@ instance PrettyVal RunResult instance PrettyVal BreakInfo instance PrettyVal Targets+instance PrettyVal UpdateStatus {------------------------------------------------------------------------------ Util
+ IdeSession/Util/Logger.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE TemplateHaskell #-}++module IdeSession.Util.Logger+ ( LogFunc+ , logDebug+ , logInfo+ , logWarn+ , logError+ , logOther+ ) where++import qualified Control.Monad.Logger as L+import Data.Text (Text)+import Language.Haskell.TH++type LogFunc = L.Loc -> L.LogSource -> L.LogLevel -> L.LogStr -> IO ()++logDebug :: Q Exp+logDebug = [| \msg -> L.runLoggingT ($(L.logDebug) msg) $(varE (mkName "logFunc")) |]++logInfo :: Q Exp+logInfo = [| \msg -> L.runLoggingT ($(L.logInfo) msg) $(varE (mkName "logFunc")) |]++logWarn :: Q Exp+logWarn = [| \msg -> L.runLoggingT ($(L.logWarn) msg) $(varE (mkName "logFunc")) |]++logError :: Q Exp+logError = [| \msg -> L.runLoggingT ($(L.logError) msg) $(varE (mkName "logFunc")) |]++logOther :: Text -> Q Exp+logOther level = [| \msg -> L.runLoggingT ($(L.logOther level) msg) $(varE (mkName "logFunc")) |]
README.md view
@@ -1,3 +1,8 @@ ## ide-backend-common Common shared library for ide-backend ide-backend-server++It can be compiled using [GHCJS](https://github.com/ghcjs/ghcjs).+This comes in handy because it's also used by+[stack-ide's API](https://github.com/commercialhaskell/stack-ide/tree/master/stack-ide-api).+This allows us to easily talk to stack-ide from GHCJS!
ide-backend-common.cabal view
@@ -1,5 +1,5 @@ name: ide-backend-common-version: 0.9.1.3+version: 0.10.0 synopsis: Shared library used be ide-backend and ide-backend-server description: Should not be used by end users license: MIT@@ -15,6 +15,7 @@ library exposed-modules: IdeSession.Util IdeSession.Util.BlockingOps+ IdeSession.Util.Logger IdeSession.Util.PrettyVal IdeSession.GHC.API IdeSession.GHC.Requests@@ -59,7 +60,8 @@ transformers >= 0.3 && < 0.5, attoparsec >= 0.10 && < 0.14, template-haskell,- pretty-show >= 1.3 && < 1.7+ pretty-show >= 1.3 && < 1.7,+ monad-logger -- GHC.Generics lived in `ghc-prim` for GHC 7.2 & GHC 7.4 if impl(ghc < 7.6)