@@ -450,88 +450,88 @@ function createInterface(msg: p.RequestMessage): m.Message {
450
450
} ;
451
451
452
452
return response ;
453
- } else
454
- if ( extension !== c . resExt ) {
453
+ }
454
+ if ( extension !== c . resExt ) {
455
+ let params : p . ShowMessageParams = {
456
+ type : p . MessageType . Error ,
457
+ message : `Not a ${ c . resExt } file. Cannot create an interface for it.` ,
458
+ } ;
459
+
460
+ let response : m . NotificationMessage = {
461
+ jsonrpc : c . jsonrpcVersion ,
462
+ method : "window/showMessage" ,
463
+ params : params ,
464
+ } ;
465
+
466
+ return response ;
467
+ }
468
+ if ( isReactComponent ) {
469
+ let params : p . ShowMessageParams = {
470
+ type : p . MessageType . Error ,
471
+ message : `Cannot create an interface for a file containing @react.component.` ,
472
+ } ;
473
+
474
+ let response : m . NotificationMessage = {
475
+ jsonrpc : c . jsonrpcVersion ,
476
+ method : "window/showMessage" ,
477
+ params : params ,
478
+ } ;
479
+
480
+ return response ;
481
+ } else {
482
+ let cmiPartialPath = utils . replaceFileExtension (
483
+ filePath . split ( projDir ) [ 1 ] ,
484
+ c . cmiExt
485
+ ) ;
486
+ let cmiPath = path . join (
487
+ projDir ,
488
+ c . compilerDirPartialPath ,
489
+ cmiPartialPath
490
+ ) ;
491
+ let cmiAvailable = fs . existsSync ( cmiPath ) ;
492
+
493
+ if ( ! cmiAvailable ) {
455
494
let params : p . ShowMessageParams = {
456
495
type : p . MessageType . Error ,
457
- message : `Not a ${ c . resExt } file. Cannot create an interface for it .` ,
496
+ message : `No compiled interface file found. Please compile your project first .` ,
458
497
} ;
459
498
460
499
let response : m . NotificationMessage = {
461
500
jsonrpc : c . jsonrpcVersion ,
462
501
method : "window/showMessage" ,
463
- params : params ,
502
+ params,
464
503
} ;
465
504
466
505
return response ;
467
- } else
468
- if ( isReactComponent ) {
469
- let params : p . ShowMessageParams = {
470
- type : p . MessageType . Error ,
471
- message : `Cannot create an interface for a file containing @react.component.` ,
472
- } ;
506
+ } else {
507
+ let intfResult = utils . createInterfaceFileUsingValidBscExePath (
508
+ filePath ,
509
+ cmiPath ,
510
+ bscNativePath
511
+ ) ;
473
512
474
- let response : m . NotificationMessage = {
513
+ if ( intfResult . kind === "success" ) {
514
+ let response : m . ResponseMessage = {
475
515
jsonrpc : c . jsonrpcVersion ,
476
- method : "window/showMessage" ,
477
- params : params ,
516
+ id : msg . id ,
517
+ result : intfResult . result ,
478
518
} ;
479
519
480
520
return response ;
481
521
} else {
482
- let cmiPartialPath = utils . replaceFileExtension (
483
- filePath . split ( projDir ) [ 1 ] ,
484
- c . cmiExt
485
- ) ;
486
- let cmiPath = path . join (
487
- projDir ,
488
- c . compilerDirPartialPath ,
489
- cmiPartialPath
490
- ) ;
491
- let cmiAvailable = fs . existsSync ( cmiPath ) ;
492
-
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.` ,
497
- } ;
498
-
499
- let response : m . NotificationMessage = {
500
- jsonrpc : c . jsonrpcVersion ,
501
- method : "window/showMessage" ,
502
- params,
503
- } ;
504
-
505
- return response ;
506
- } else {
507
- let intfResult = utils . createInterfaceFileUsingValidBscExePath (
508
- filePath ,
509
- cmiPath ,
510
- bscNativePath
511
- ) ;
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
+ } ;
512
530
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
- }
533
- }
531
+ return response ;
534
532
}
533
+ }
534
+ }
535
535
}
536
536
537
537
function onMessage ( msg : m . Message ) {
0 commit comments