@@ -437,10 +437,10 @@ function createInterface(msg: p.RequestMessage): m.Message {
437
437
let code = getOpenedFileContent ( params . uri ) ;
438
438
let isReactComponent = code . includes ( "@react.component" ) ;
439
439
440
- if ( isReactComponent ) {
440
+ if ( bscNativePath === null || projDir === null ) {
441
441
let params : p . ShowMessageParams = {
442
442
type : p . MessageType . Error ,
443
- message : `Cannot create an interface for a file containing @react.component .` ,
443
+ message : `Cannot find a nearby bsc.exe to generate the interface file .` ,
444
444
} ;
445
445
446
446
let response : m . NotificationMessage = {
@@ -450,11 +450,11 @@ function createInterface(msg: p.RequestMessage): m.Message {
450
450
} ;
451
451
452
452
return response ;
453
- } else
454
- if ( bscNativePath === null || projDir === null ) {
453
+ } else
454
+ if ( isReactComponent ) {
455
455
let params : p . ShowMessageParams = {
456
456
type : p . MessageType . Error ,
457
- message : `Cannot find a nearby bsc.exe to generate the interface file .` ,
457
+ message : `Cannot create an interface for a file containing @react.component .` ,
458
458
} ;
459
459
460
460
let response : m . NotificationMessage = {
@@ -464,73 +464,74 @@ function createInterface(msg: p.RequestMessage): m.Message {
464
464
} ;
465
465
466
466
return response ;
467
- } else if ( extension !== c . resExt ) {
468
- let params : p . ShowMessageParams = {
469
- type : p . MessageType . Error ,
470
- message : `Not a ${ c . resExt } file. Cannot create an interface for it.` ,
471
- } ;
472
-
473
- let response : m . NotificationMessage = {
474
- jsonrpc : c . jsonrpcVersion ,
475
- method : "window/showMessage" ,
476
- params : params ,
477
- } ;
478
-
479
- return response ;
480
- } else {
481
- let cmiPartialPath = utils . replaceFileExtension (
482
- filePath . split ( projDir ) [ 1 ] ,
483
- c . cmiExt
484
- ) ;
485
- let cmiPath = path . join (
486
- projDir ,
487
- c . compilerDirPartialPath ,
488
- cmiPartialPath
489
- ) ;
490
- let cmiAvailable = fs . existsSync ( cmiPath ) ;
491
-
492
- if ( ! cmiAvailable ) {
467
+ } else
468
+ if ( extension !== c . resExt ) {
493
469
let params : p . ShowMessageParams = {
494
470
type : p . MessageType . Error ,
495
- message : `No compiled interface file found. Please compile your project first .` ,
471
+ message : `Not a ${ c . resExt } file. Cannot create an interface for it .` ,
496
472
} ;
497
473
498
474
let response : m . NotificationMessage = {
499
475
jsonrpc : c . jsonrpcVersion ,
500
476
method : "window/showMessage" ,
501
- params,
477
+ params : params ,
502
478
} ;
503
479
504
480
return response ;
505
481
} else {
506
- let intfResult = utils . createInterfaceFileUsingValidBscExePath (
507
- filePath ,
508
- cmiPath ,
509
- bscNativePath
482
+ let cmiPartialPath = utils . replaceFileExtension (
483
+ filePath . split ( projDir ) [ 1 ] ,
484
+ c . cmiExt
510
485
) ;
486
+ let cmiPath = path . join (
487
+ projDir ,
488
+ c . compilerDirPartialPath ,
489
+ cmiPartialPath
490
+ ) ;
491
+ let cmiAvailable = fs . existsSync ( cmiPath ) ;
511
492
512
- if ( intfResult . kind === "success" ) {
513
- let response : m . ResponseMessage = {
514
- jsonrpc : c . jsonrpcVersion ,
515
- id : msg . id ,
516
- result : intfResult . result ,
493
+ if ( ! cmiAvailable ) {
494
+ let params : p . ShowMessageParams = {
495
+ type : p . MessageType . Error ,
496
+ message : `No compiled interface file found. Please compile your project first.` ,
517
497
} ;
518
498
519
- return response ;
520
- } else {
521
- let response : m . ResponseMessage = {
499
+ let response : m . NotificationMessage = {
522
500
jsonrpc : c . jsonrpcVersion ,
523
- id : msg . id ,
524
- error : {
525
- code : m . ErrorCodes . InternalError ,
526
- message : "Unable to create interface file." ,
527
- } ,
501
+ method : "window/showMessage" ,
502
+ params,
528
503
} ;
529
504
530
505
return response ;
506
+ } else {
507
+ let intfResult = utils . createInterfaceFileUsingValidBscExePath (
508
+ filePath ,
509
+ cmiPath ,
510
+ bscNativePath
511
+ ) ;
512
+
513
+ if ( intfResult . kind === "success" ) {
514
+ let response : m . ResponseMessage = {
515
+ jsonrpc : c . jsonrpcVersion ,
516
+ id : msg . id ,
517
+ result : intfResult . result ,
518
+ } ;
519
+
520
+ return response ;
521
+ } else {
522
+ let response : m . ResponseMessage = {
523
+ jsonrpc : c . jsonrpcVersion ,
524
+ id : msg . id ,
525
+ error : {
526
+ code : m . ErrorCodes . InternalError ,
527
+ message : "Unable to create interface file." ,
528
+ } ,
529
+ } ;
530
+
531
+ return response ;
532
+ }
531
533
}
532
534
}
533
- }
534
535
}
535
536
536
537
function onMessage ( msg : m . Message ) {
0 commit comments