{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
module Development.IDE.Core.Service(
getIdeOptions, getIdeOptionsIO,
IdeState, initialise, shutdown,
runAction,
writeProfile,
getDiagnostics, unsafeClearDiagnostics,
ideLogger,
updatePositionMapping,
) where
import Data.Maybe
import Development.IDE.Types.Options (IdeOptions(..))
import Development.IDE.Core.Debouncer
import Development.IDE.Core.FileStore (VFSHandle, fileStoreRules)
import Development.IDE.Core.FileExists (fileExistsRules)
import Development.IDE.Core.OfInterest
import Development.IDE.Types.Logger as Logger
import Development.Shake
import qualified Language.Haskell.LSP.Messages as LSP
import qualified Language.Haskell.LSP.Types as LSP
import qualified Language.Haskell.LSP.Types.Capabilities as LSP
import Development.IDE.Core.Shake
import Control.Monad
initialise :: LSP.ClientCapabilities
-> Rules ()
-> IO LSP.LspId
-> (LSP.FromServerMessage -> IO ())
-> WithProgressFunc
-> WithIndefiniteProgressFunc
-> Logger
-> Debouncer LSP.NormalizedUri
-> IdeOptions
-> VFSHandle
-> IO IdeState
initialise caps mainRule getLspId toDiags wProg wIndefProg logger debouncer options vfs =
shakeOpen
getLspId
toDiags
wProg
wIndefProg
logger
debouncer
(optShakeProfiling options)
(optReportProgress options)
(optTesting options)
shakeOptions
{ shakeThreads = optThreads options
, shakeFiles = fromMaybe "/dev/null" (optShakeFiles options)
} $ do
addIdeGlobal $ GlobalIdeOptions options
fileStoreRules vfs
ofInterestRules
fileExistsRules getLspId caps vfs
mainRule
writeProfile :: IdeState -> FilePath -> IO ()
writeProfile = shakeProfile
shutdown :: IdeState -> IO ()
shutdown = shakeShut
runAction :: String -> IdeState -> Action a -> IO a
runAction herald ide act =
join $ shakeEnqueue ide (mkDelayedAction herald Logger.Info act)