@@ -11,6 +11,7 @@ module Development.IDE.LSP.LanguageServer
11
11
, Log (.. )
12
12
, ThreadQueue
13
13
, runWithWorkerThreads
14
+ , Communication (.. )
14
15
) where
15
16
16
17
import Control.Concurrent.STM
@@ -27,16 +28,19 @@ import Ide.Types (traceWithSpan)
27
28
import Language.LSP.Protocol.Message
28
29
import Language.LSP.Protocol.Types
29
30
import qualified Language.LSP.Server as LSP
30
- import System.IO
31
31
import UnliftIO.Async
32
32
import UnliftIO.Concurrent
33
33
import UnliftIO.Directory
34
34
import UnliftIO.Exception
35
35
36
36
import qualified Colog.Core as Colog
37
37
import Control.Exception (BlockedIndefinitelyOnMVar (.. ))
38
+ import Control.Exception.Backtrace (BacktraceMechanism (.. ),
39
+ setBacktraceMechanismState )
38
40
import Control.Monad.IO.Unlift (MonadUnliftIO )
39
41
import Control.Monad.Trans.Cont (evalContT )
42
+ import Data.ByteString
43
+ import Data.ByteString.Lazy
40
44
import Development.IDE.Core.IdeConfiguration
41
45
import Development.IDE.Core.Shake hiding (Log )
42
46
import Development.IDE.Core.Tracing
@@ -82,13 +86,17 @@ instance Pretty Log where
82
86
LogLspServer msg -> pretty msg
83
87
LogServerShutdownMessage -> " Received shutdown message"
84
88
89
+ data Communication
90
+ = Communication
91
+ { inwards :: IO StrictByteString
92
+ , outwards :: LazyByteString -> IO ()
93
+ }
85
94
86
95
runLanguageServer
87
96
:: forall config a m . (Show config )
88
97
=> Recorder (WithPriority Log )
89
98
-> LSP. Options
90
- -> Handle -- input
91
- -> Handle -- output
99
+ -> Communication
92
100
-> config
93
101
-> (config -> Value -> Either T. Text config )
94
102
-> (config -> m config () )
@@ -97,7 +105,7 @@ runLanguageServer
97
105
LSP. Handlers (m config ),
98
106
(LanguageContextEnv config , a ) -> m config <~> IO ))
99
107
-> IO ()
100
- runLanguageServer recorder options inH outH defaultConfig parseConfig onConfigChange setup = do
108
+ runLanguageServer recorder options comm defaultConfig parseConfig onConfigChange setup = do
101
109
-- This MVar becomes full when the server thread exits or we receive exit message from client.
102
110
-- LSP server will be canceled when it's full.
103
111
clientMsgVar <- newEmptyMVar
@@ -120,11 +128,11 @@ runLanguageServer recorder options inH outH defaultConfig parseConfig onConfigCh
120
128
lspCologAction = toCologActionWithPrio (cmapWithPrio LogLspServer recorder)
121
129
122
130
void $ untilMVar clientMsgVar $
123
- void $ LSP. runServerWithHandles
131
+ void $ LSP. runServerWith
124
132
lspCologAction
125
133
lspCologAction
126
- inH
127
- outH
134
+ (inwards comm)
135
+ (outwards comm)
128
136
serverDefinition
129
137
130
138
setupLSP ::
0 commit comments