@@ -411,7 +411,12 @@ namespace ts.server {
411
411
this . send ( ev ) ;
412
412
}
413
413
414
- public output ( info : { } | undefined , cmdName : string , reqSeq : number , success : boolean , message ?: string ) {
414
+ // For backwards-compatibility only.
415
+ public output ( info : any , cmdName : string , reqSeq ?: number , errorMsg ?: string ) : void {
416
+ this . doOutput ( info , cmdName , reqSeq , /*success*/ ! errorMsg , errorMsg ) ;
417
+ }
418
+
419
+ private doOutput ( info : { } | undefined , cmdName : string , reqSeq : number , success : boolean , message ?: string ) : void {
415
420
const res : protocol . Response = {
416
421
seq : 0 ,
417
422
type : "response" ,
@@ -1299,7 +1304,7 @@ namespace ts.server {
1299
1304
this . changeSeq ++ ;
1300
1305
// make sure no changes happen before this one is finished
1301
1306
if ( project . reloadScript ( file , tempFileName ) ) {
1302
- this . output ( undefined , CommandNames . Reload , reqSeq , /*success*/ true ) ;
1307
+ this . doOutput ( /*info*/ undefined , CommandNames . Reload , reqSeq , /*success*/ true ) ;
1303
1308
}
1304
1309
}
1305
1310
@@ -1539,7 +1544,7 @@ namespace ts.server {
1539
1544
1540
1545
private applyCodeActionCommand ( commandName : string , requestSeq : number , args : protocol . ApplyCodeActionCommandRequestArgs ) : void {
1541
1546
const { file, project } = this . getFileAndProject ( args ) ;
1542
- const output = ( success : boolean , message : string ) => this . output ( { } , commandName , requestSeq , success , message ) ;
1547
+ const output = ( success : boolean , message : string ) => this . doOutput ( { } , commandName , requestSeq , success , message ) ;
1543
1548
const command = args . command as CodeActionCommand ; // They should be sending back the command we sent them.
1544
1549
project . getLanguageService ( ) . applyCodeActionCommand ( file , command ) . then (
1545
1550
( { successMessage } ) => { output ( /*success*/ true , successMessage ) ; } ,
@@ -1845,7 +1850,7 @@ namespace ts.server {
1845
1850
} ,
1846
1851
[ CommandNames . Configure ] : ( request : protocol . ConfigureRequest ) => {
1847
1852
this . projectService . setHostConfiguration ( request . arguments ) ;
1848
- this . output ( undefined , CommandNames . Configure , request . seq , /*success*/ true ) ;
1853
+ this . doOutput ( /*info*/ undefined , CommandNames . Configure , request . seq , /*success*/ true ) ;
1849
1854
return this . notRequired ( ) ;
1850
1855
} ,
1851
1856
[ CommandNames . Reload ] : ( request : protocol . ReloadRequest ) => {
@@ -1966,7 +1971,7 @@ namespace ts.server {
1966
1971
}
1967
1972
else {
1968
1973
this . logger . msg ( `Unrecognized JSON command: ${ JSON . stringify ( request ) } ` , Msg . Err ) ;
1969
- this . output ( undefined , CommandNames . Unknown , request . seq , /*success*/ false , `Unrecognized JSON command: ${ request . command } ` ) ;
1974
+ this . doOutput ( /*info*/ undefined , CommandNames . Unknown , request . seq , /*success*/ false , `Unrecognized JSON command: ${ request . command } ` ) ;
1970
1975
return { responseRequired : false } ;
1971
1976
}
1972
1977
}
@@ -1997,21 +2002,21 @@ namespace ts.server {
1997
2002
}
1998
2003
1999
2004
if ( response ) {
2000
- this . output ( response , request . command , request . seq , /*success*/ true ) ;
2005
+ this . doOutput ( response , request . command , request . seq , /*success*/ true ) ;
2001
2006
}
2002
2007
else if ( responseRequired ) {
2003
- this . output ( undefined , request . command , request . seq , /*success*/ false , "No content available." ) ;
2008
+ this . doOutput ( /*info*/ undefined , request . command , request . seq , /*success*/ false , "No content available." ) ;
2004
2009
}
2005
2010
}
2006
2011
catch ( err ) {
2007
2012
if ( err instanceof OperationCanceledException ) {
2008
2013
// Handle cancellation exceptions
2009
- this . output ( { canceled : true } , request . command , request . seq , /*success*/ true ) ;
2014
+ this . doOutput ( { canceled : true } , request . command , request . seq , /*success*/ true ) ;
2010
2015
return ;
2011
2016
}
2012
2017
this . logError ( err , message ) ;
2013
- this . output (
2014
- undefined ,
2018
+ this . doOutput (
2019
+ /*info*/ undefined ,
2015
2020
request ? request . command : CommandNames . Unknown ,
2016
2021
request ? request . seq : 0 ,
2017
2022
/*success*/ false ,
0 commit comments