@@ -341,43 +341,24 @@ function onMessage(msg: m.Message) {
341
341
send ( response ) ;
342
342
}
343
343
} else if ( msg . method === p . HoverRequest . method ) {
344
- let emptyHoverResponse : m . ResponseMessage = {
344
+ let hoverResponse : m . ResponseMessage = {
345
345
jsonrpc : c . jsonrpcVersion ,
346
346
id : msg . id ,
347
347
// type result = Hover | null
348
348
// type Hover = {contents: MarkedString | MarkedString[] | MarkupContent, range?: Range}
349
- result : null ,
349
+ result : runHoverCommand ( msg ) ,
350
350
} ;
351
- let result = runHoverCommand ( msg ) ;
352
- if ( result !== null ) {
353
- let hoverResponse : m . ResponseMessage = {
354
- ...emptyHoverResponse ,
355
- result,
356
- } ;
357
- send ( hoverResponse ) ;
358
- } else {
359
- send ( emptyHoverResponse ) ;
360
- }
351
+ send ( hoverResponse ) ;
361
352
} else if ( msg . method === p . DefinitionRequest . method ) {
362
353
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
363
- let emptyDefinitionResponse : m . ResponseMessage = {
354
+ let definitionResponse : m . ResponseMessage = {
364
355
jsonrpc : c . jsonrpcVersion ,
365
356
id : msg . id ,
366
357
// result should be: Location | Array<Location> | Array<LocationLink> | null
367
- result : null ,
358
+ result : runDefinitionCommand ( msg ) ,
368
359
// error: code and message set in case an exception happens during the definition request.
369
360
} ;
370
-
371
- let result = runDefinitionCommand ( msg ) ;
372
- if ( result !== null ) {
373
- let definitionResponse : m . ResponseMessage = {
374
- ...emptyDefinitionResponse ,
375
- result : result ,
376
- } ;
377
- send ( definitionResponse ) ;
378
- } else {
379
- send ( emptyDefinitionResponse ) ;
380
- }
361
+ send ( definitionResponse ) ;
381
362
} else if ( msg . method === p . CompletionRequest . method ) {
382
363
let code = getOpenedFileContent ( msg . params . textDocument . uri ) ;
383
364
let completionResponse : m . ResponseMessage = {
0 commit comments