@@ -147,21 +147,25 @@ runLanguageServer options userHandlers onInitialConfig onConfigChange getIdeStat
147
147
-- We dispatch notifications synchronously and requests asynchronously
148
148
-- This is to ensure that all file edits and config changes are applied before a request is handled
149
149
case msg of
150
- Notification x@ NotificationMessage {_params, _method} act -> otTracedHandler " Notification" (show _method) $ do
151
- catch (act lspFuncs ide _params) $ \ (e :: SomeException ) ->
150
+ Notification x@ NotificationMessage {_params, _method} act ->
151
+ otTracedHandler " Notification" (show _method) $ \ sp -> do
152
+ traceWithSpan sp _params
153
+ catch (act lspFuncs ide _params) $ \ (e :: SomeException ) ->
152
154
logError (ideLogger ide) $ T. pack $
153
155
" Unexpected exception on notification, please report!\n " ++
154
156
" Message: " ++ show x ++ " \n " ++
155
157
" Exception: " ++ show e
156
158
Response x@ RequestMessage {_id, _method, _params} wrap act -> void $ async $
157
- otTracedHandler " Request" (show _method) $
158
- checkCancelled ide clearReqId waitForCancel lspFuncs wrap act x _id _params $
159
+ otTracedHandler " Request" (show _method) $ \ sp -> do
160
+ traceWithSpan sp _params
161
+ checkCancelled ide clearReqId waitForCancel lspFuncs wrap act x _id _params $
159
162
\ case
160
163
Left e -> sendFunc $ wrap $ ResponseMessage " 2.0" (responseId _id) (Left e)
161
164
Right r -> sendFunc $ wrap $ ResponseMessage " 2.0" (responseId _id) (Right r)
162
165
ResponseAndRequest x@ RequestMessage {_id, _method, _params} wrap wrapNewReq act -> void $ async $
163
- otTracedHandler " Request" (show _method) $
164
- checkCancelled ide clearReqId waitForCancel lspFuncs wrap act x _id _params $
166
+ otTracedHandler " Request" (show _method) $ \ sp -> do
167
+ traceWithSpan sp _params
168
+ checkCancelled ide clearReqId waitForCancel lspFuncs wrap act x _id _params $
165
169
\ (res, newReq) -> do
166
170
case res of
167
171
Left e -> sendFunc $ wrap $ ResponseMessage " 2.0" (responseId _id) (Left e)
@@ -170,8 +174,9 @@ runLanguageServer options userHandlers onInitialConfig onConfigChange getIdeStat
170
174
reqId <- getNextReqId
171
175
sendFunc $ wrapNewReq $ RequestMessage " 2.0" reqId rm newReqParams
172
176
InitialParams x@ RequestMessage {_id, _method, _params} act ->
173
- otTracedHandler " Initialize" (show _method) $
174
- catch (act lspFuncs ide _params) $ \ (e :: SomeException ) ->
177
+ otTracedHandler " Initialize" (show _method) $ \ sp -> do
178
+ traceWithSpan sp _params
179
+ catch (act lspFuncs ide _params) $ \ (e :: SomeException ) ->
175
180
logError (ideLogger ide) $ T. pack $
176
181
" Unexpected exception on InitializeRequest handler, please report!\n " ++
177
182
" Message: " ++ show x ++ " \n " ++
@@ -238,14 +243,17 @@ exitHandler exit = PartialHandlers $ \_ x -> return x
238
243
-- | A message that we need to deal with - the pieces are split up with existentials to gain additional type safety
239
244
-- and defer precise processing until later (allows us to keep at a higher level of abstraction slightly longer)
240
245
data Message c
241
- = forall m req resp . (Show m , Show req ) => Response (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (LSP. LspFuncs c -> IdeState -> req -> IO (Either ResponseError resp ))
242
- -- | Used for cases in which we need to send not only a response,
246
+ = forall m req resp . (Show m , Show req , HasTracing req ) =>
247
+ Response (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (LSP. LspFuncs c -> IdeState -> req -> IO (Either ResponseError resp ))
248
+ | -- | Used for cases in which we need to send not only a response,
243
249
-- but also an additional request to the client.
244
250
-- For example, 'executeCommand' may generate an 'applyWorkspaceEdit' request.
245
- | forall m rm req resp newReqParams newReqBody . (Show m , Show rm , Show req ) => ResponseAndRequest (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (RequestMessage rm newReqParams newReqBody -> FromServerMessage ) (LSP. LspFuncs c -> IdeState -> req -> IO (Either ResponseError resp , Maybe (rm , newReqParams )))
246
- | forall m req . (Show m , Show req ) => Notification (NotificationMessage m req ) (LSP. LspFuncs c -> IdeState -> req -> IO () )
247
- -- | Used for the InitializeRequest only, where the response is generated by the LSP core handler.
248
- | InitialParams InitializeRequest (LSP. LspFuncs c -> IdeState -> InitializeParams -> IO () )
251
+ forall m rm req resp newReqParams newReqBody . (Show m , Show rm , Show req , HasTracing req ) =>
252
+ ResponseAndRequest (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (RequestMessage rm newReqParams newReqBody -> FromServerMessage ) (LSP. LspFuncs c -> IdeState -> req -> IO (Either ResponseError resp , Maybe (rm , newReqParams )))
253
+ | forall m req . (Show m , Show req , HasTracing req ) =>
254
+ Notification (NotificationMessage m req ) (LSP. LspFuncs c -> IdeState -> req -> IO () )
255
+ | -- | Used for the InitializeRequest only, where the response is generated by the LSP core handler.
256
+ InitialParams InitializeRequest (LSP. LspFuncs c -> IdeState -> InitializeParams -> IO () )
249
257
250
258
modifyOptions :: LSP. Options -> LSP. Options
251
259
modifyOptions x = x{ LSP. textDocumentSync = Just $ tweakTDS origTDS
0 commit comments