@@ -40,13 +40,17 @@ let projectsFiles: Map<
4040// ^ caching AND states AND distributed system. Why does LSP has to be stupid like this
4141
4242// will be properly defined later depending on the mode (stdio/node-rpc)
43- let send : ( msg : m . Message ) => void = ( _ ) => { } ;
43+ let send : ( msg : m . Message ) => void = ( _ ) => { } ;
4444
4545interface CreateInterfaceRequestParams {
4646 uri : string ;
47- } ;
47+ }
4848
49- let createInterfaceRequest = new v . RequestType < CreateInterfaceRequestParams , string , void > ( "rescript-vscode.create_interface" ) ;
49+ let createInterfaceRequest = new v . RequestType <
50+ CreateInterfaceRequestParams ,
51+ string ,
52+ void
53+ > ( "rescript-vscode.create_interface" ) ;
5054
5155let sendUpdatedDiagnostics = ( ) => {
5256 projectsFiles . forEach ( ( { filesWithDiagnostics } , projectRootPath ) => {
@@ -350,12 +354,10 @@ function onMessage(msg: m.Message) {
350354 } else if ( msg . method === p . HoverRequest . method ) {
351355 let params = msg . params as p . HoverParams ;
352356 let filePath = fileURLToPath ( params . textDocument . uri ) ;
353- let result : Hover | null = utils . runAnalysisAfterSanityCheck ( filePath , [
354- "hover" ,
357+ let result : typeof p . HoverRequest . type = utils . runAnalysisAfterSanityCheck (
355358 filePath ,
356- params . position . line ,
357- params . position . character ,
358- ] ) ;
359+ [ "hover" , filePath , params . position . line , params . position . character ]
360+ ) ;
359361 let hoverResponse : m . ResponseMessage = {
360362 jsonrpc : c . jsonrpcVersion ,
361363 id : msg . id ,
@@ -368,14 +370,15 @@ function onMessage(msg: m.Message) {
368370 // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
369371 let params = msg . params as p . DefinitionParams ;
370372 let filePath = fileURLToPath ( params . textDocument . uri ) ;
371- let result :
372- | Location [ ]
373- | null = utils . runAnalysisAfterSanityCheck ( filePath , [
373+ let result : typeof p . DefinitionRequest . type = utils . runAnalysisAfterSanityCheck (
374+ filePath ,
375+ [
374376 "definition" ,
375377 filePath ,
376378 params . position . line ,
377379 params . position . character ,
378- ] ) ;
380+ ]
381+ ) ;
379382 let definitionResponse : m . ResponseMessage = {
380383 jsonrpc : c . jsonrpcVersion ,
381384 id : msg . id ,
@@ -387,7 +390,7 @@ function onMessage(msg: m.Message) {
387390 // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
388391 let params = msg . params as p . ReferenceParams ;
389392 let filePath = fileURLToPath ( params . textDocument . uri ) ;
390- let result : Location | null = utils . runAnalysisAfterSanityCheck (
393+ let result : typeof p . ReferencesRequest . type = utils . runAnalysisAfterSanityCheck (
391394 filePath ,
392395 [
393396 "references" ,
@@ -407,12 +410,10 @@ function onMessage(msg: m.Message) {
407410 // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
408411 let params = msg . params as p . DocumentSymbolParams ;
409412 let filePath = fileURLToPath ( params . textDocument . uri ) ;
410- let result :
411- | SymbolInformation [ ]
412- | null = utils . runAnalysisAfterSanityCheck ( filePath , [
413- "documentSymbol" ,
414- filePath ,
415- ] ) ;
413+ let result : typeof p . DocumentSymbolRequest . type = utils . runAnalysisAfterSanityCheck (
414+ filePath ,
415+ [ "documentSymbol" , filePath ]
416+ ) ;
416417 let definitionResponse : m . ResponseMessage = {
417418 jsonrpc : c . jsonrpcVersion ,
418419 id : msg . id ,
@@ -425,15 +426,16 @@ function onMessage(msg: m.Message) {
425426 let code = getOpenedFileContent ( params . textDocument . uri ) ;
426427 let tmpname = utils . createFileInTempDir ( ) ;
427428 fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
428- let result :
429- | CompletionItem [ ]
430- | null = utils . runAnalysisAfterSanityCheck ( filePath , [
429+ let result : typeof p . CompletionRequest . type = utils . runAnalysisAfterSanityCheck (
430+ filePath ,
431+ [
431432 "completion" ,
432433 filePath ,
433434 params . position . line ,
434435 params . position . character ,
435436 tmpname ,
436- ] ) ;
437+ ]
438+ ) ;
437439 fs . unlink ( tmpname , ( ) => null ) ;
438440 let completionResponse : m . ResponseMessage = {
439441 jsonrpc : c . jsonrpcVersion ,
@@ -554,14 +556,21 @@ function onMessage(msg: m.Message) {
554556
555557 send ( response ) ;
556558 } else {
557- let cmiPartialPath = utils . replaceFileExtension ( filePath . split ( projDir ) [ 1 ] , c . cmiExt ) ;
558- let cmiPath = path . join ( projDir , c . compilerDirPartialPath , cmiPartialPath ) ;
559+ let cmiPartialPath = utils . replaceFileExtension (
560+ filePath . split ( projDir ) [ 1 ] ,
561+ c . cmiExt
562+ ) ;
563+ let cmiPath = path . join (
564+ projDir ,
565+ c . compilerDirPartialPath ,
566+ cmiPartialPath
567+ ) ;
559568 let cmiAvailable = fs . existsSync ( cmiPath ) ;
560569
561570 if ( ! cmiAvailable ) {
562571 let params : p . ShowMessageParams = {
563572 type : p . MessageType . Error ,
564- message : `No compiled interface file found. Please compile your project first.`
573+ message : `No compiled interface file found. Please compile your project first.` ,
565574 } ;
566575
567576 let response : m . NotificationMessage = {
@@ -572,7 +581,11 @@ function onMessage(msg: m.Message) {
572581
573582 send ( response ) ;
574583 } else {
575- let intfResult = utils . createInterfaceFileUsingValidBscExePath ( filePath , cmiPath , bscNativePath )
584+ let intfResult = utils . createInterfaceFileUsingValidBscExePath (
585+ filePath ,
586+ cmiPath ,
587+ bscNativePath
588+ ) ;
576589
577590 if ( intfResult . kind === "success" ) {
578591 let response : m . ResponseMessage = {
@@ -588,8 +601,8 @@ function onMessage(msg: m.Message) {
588601 id : msg . id ,
589602 error : {
590603 code : m . ErrorCodes . InternalError ,
591- message : "Unable to create interface file."
592- }
604+ message : "Unable to create interface file." ,
605+ } ,
593606 } ;
594607
595608 send ( response ) ;
0 commit comments