@@ -40,13 +40,17 @@ let projectsFiles: Map<
40
40
// ^ caching AND states AND distributed system. Why does LSP has to be stupid like this
41
41
42
42
// 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 = ( _ ) => { } ;
44
44
45
45
interface CreateInterfaceRequestParams {
46
46
uri : string ;
47
- } ;
47
+ }
48
48
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" ) ;
50
54
51
55
let sendUpdatedDiagnostics = ( ) => {
52
56
projectsFiles . forEach ( ( { filesWithDiagnostics } , projectRootPath ) => {
@@ -350,12 +354,10 @@ function onMessage(msg: m.Message) {
350
354
} else if ( msg . method === p . HoverRequest . method ) {
351
355
let params = msg . params as p . HoverParams ;
352
356
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 (
355
358
filePath ,
356
- params . position . line ,
357
- params . position . character ,
358
- ] ) ;
359
+ [ "hover" , filePath , params . position . line , params . position . character ]
360
+ ) ;
359
361
let hoverResponse : m . ResponseMessage = {
360
362
jsonrpc : c . jsonrpcVersion ,
361
363
id : msg . id ,
@@ -368,14 +370,15 @@ function onMessage(msg: m.Message) {
368
370
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
369
371
let params = msg . params as p . DefinitionParams ;
370
372
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
+ [
374
376
"definition" ,
375
377
filePath ,
376
378
params . position . line ,
377
379
params . position . character ,
378
- ] ) ;
380
+ ]
381
+ ) ;
379
382
let definitionResponse : m . ResponseMessage = {
380
383
jsonrpc : c . jsonrpcVersion ,
381
384
id : msg . id ,
@@ -387,7 +390,7 @@ function onMessage(msg: m.Message) {
387
390
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
388
391
let params = msg . params as p . ReferenceParams ;
389
392
let filePath = fileURLToPath ( params . textDocument . uri ) ;
390
- let result : Location | null = utils . runAnalysisAfterSanityCheck (
393
+ let result : typeof p . ReferencesRequest . type = utils . runAnalysisAfterSanityCheck (
391
394
filePath ,
392
395
[
393
396
"references" ,
@@ -407,12 +410,10 @@ function onMessage(msg: m.Message) {
407
410
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
408
411
let params = msg . params as p . DocumentSymbolParams ;
409
412
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
+ ) ;
416
417
let definitionResponse : m . ResponseMessage = {
417
418
jsonrpc : c . jsonrpcVersion ,
418
419
id : msg . id ,
@@ -425,15 +426,16 @@ function onMessage(msg: m.Message) {
425
426
let code = getOpenedFileContent ( params . textDocument . uri ) ;
426
427
let tmpname = utils . createFileInTempDir ( ) ;
427
428
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
+ [
431
432
"completion" ,
432
433
filePath ,
433
434
params . position . line ,
434
435
params . position . character ,
435
436
tmpname ,
436
- ] ) ;
437
+ ]
438
+ ) ;
437
439
fs . unlink ( tmpname , ( ) => null ) ;
438
440
let completionResponse : m . ResponseMessage = {
439
441
jsonrpc : c . jsonrpcVersion ,
@@ -554,14 +556,21 @@ function onMessage(msg: m.Message) {
554
556
555
557
send ( response ) ;
556
558
} 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
+ ) ;
559
568
let cmiAvailable = fs . existsSync ( cmiPath ) ;
560
569
561
570
if ( ! cmiAvailable ) {
562
571
let params : p . ShowMessageParams = {
563
572
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.` ,
565
574
} ;
566
575
567
576
let response : m . NotificationMessage = {
@@ -572,7 +581,11 @@ function onMessage(msg: m.Message) {
572
581
573
582
send ( response ) ;
574
583
} else {
575
- let intfResult = utils . createInterfaceFileUsingValidBscExePath ( filePath , cmiPath , bscNativePath )
584
+ let intfResult = utils . createInterfaceFileUsingValidBscExePath (
585
+ filePath ,
586
+ cmiPath ,
587
+ bscNativePath
588
+ ) ;
576
589
577
590
if ( intfResult . kind === "success" ) {
578
591
let response : m . ResponseMessage = {
@@ -588,8 +601,8 @@ function onMessage(msg: m.Message) {
588
601
id : msg . id ,
589
602
error : {
590
603
code : m . ErrorCodes . InternalError ,
591
- message : "Unable to create interface file."
592
- }
604
+ message : "Unable to create interface file." ,
605
+ } ,
593
606
} ;
594
607
595
608
send ( response ) ;
0 commit comments