@@ -151,7 +151,10 @@ export interface IServerRequestHandler<
151151 T extends keyof IServerRequestParams = keyof IServerRequestParams
152152> {
153153 setHandler (
154- handler : ( params : IServerRequestParams [ T ] ) => Promise < IServerResult [ T ] >
154+ handler : (
155+ params : IServerRequestParams [ T ] ,
156+ connection ?: LSPConnection
157+ ) => Promise < IServerResult [ T ] >
155158 ) : void ;
156159 clearHandler ( ) : void ;
157160}
@@ -183,10 +186,15 @@ class ServerRequestHandler<
183186 T extends keyof IServerRequestParams = keyof IServerRequestParams
184187> implements IServerRequestHandler {
185188 private _handler : (
186- params : IServerRequestParams [ T ]
189+ params : IServerRequestParams [ T ] ,
190+ connection ?: LSPConnection
187191 ) => Promise < IServerResult [ T ] > ;
188192
189- constructor ( protected connection : MessageConnection , protected method : T ) {
193+ constructor (
194+ protected connection : MessageConnection ,
195+ protected method : T ,
196+ protected emitter : LSPConnection
197+ ) {
190198 // on request accepts "thenable"
191199 this . connection . onRequest ( method , this . handle ) ;
192200 this . _handler = null ;
@@ -196,11 +204,14 @@ class ServerRequestHandler<
196204 if ( ! this . _handler ) {
197205 return ;
198206 }
199- return this . _handler ( request ) ;
207+ return this . _handler ( request , this . emitter ) ;
200208 }
201209
202210 setHandler (
203- handler : ( params : IServerRequestParams [ T ] ) => Promise < IServerResult [ T ] >
211+ handler : (
212+ params : IServerRequestParams [ T ] ,
213+ connection ?: LSPConnection
214+ ) => Promise < IServerResult [ T ] >
204215 ) {
205216 this . _handler = handler ;
206217 }
@@ -281,7 +292,8 @@ export class LSPConnection extends LspWsConnection {
281292 for ( let method of Object . values ( methods ) ) {
282293 result [ method as U ] = new ServerRequestHandler (
283294 this . connection ,
284- ( method as U ) as any
295+ ( method as U ) as any ,
296+ this
285297 ) ;
286298 }
287299 return result as T ;
0 commit comments