@@ -450,88 +450,88 @@ function createInterface(msg: p.RequestMessage): m.Message {
450450 } ;
451451
452452 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 ) {
455494 let params : p . ShowMessageParams = {
456495 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 .` ,
458497 } ;
459498
460499 let response : m . NotificationMessage = {
461500 jsonrpc : c . jsonrpcVersion ,
462501 method : "window/showMessage" ,
463- params : params ,
502+ params,
464503 } ;
465504
466505 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+ ) ;
473512
474- let response : m . NotificationMessage = {
513+ if ( intfResult . kind === "success" ) {
514+ let response : m . ResponseMessage = {
475515 jsonrpc : c . jsonrpcVersion ,
476- method : "window/showMessage" ,
477- params : params ,
516+ id : msg . id ,
517+ result : intfResult . result ,
478518 } ;
479519
480520 return response ;
481521 } 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+ } ;
512530
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 ;
534532 }
533+ }
534+ }
535535}
536536
537537function onMessage ( msg : m . Message ) {
0 commit comments