@@ -246,16 +246,22 @@ namespace ts {
246246
247247 export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
248248 private files : string [ ] ;
249+ private loggingEnabled = false ;
250+ private tracingEnabled = false ;
249251
250252 constructor ( private shimHost : LanguageServiceShimHost ) {
251253 }
252254
253255 public log ( s : string ) : void {
254- this . shimHost . log ( s ) ;
256+ if ( this . loggingEnabled ) {
257+ this . shimHost . log ( s ) ;
258+ }
255259 }
256260
257261 public trace ( s : string ) : void {
258- this . shimHost . trace ( s ) ;
262+ if ( this . tracingEnabled ) {
263+ this . shimHost . trace ( s ) ;
264+ }
259265 }
260266
261267 public error ( s : string ) : void {
@@ -349,15 +355,15 @@ namespace ts {
349355 }
350356 }
351357
352- function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : any {
353- if ( ! noPerfLogging ) {
358+ function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any , logPerformance : boolean ) : any {
359+ if ( logPerformance ) {
354360 logger . log ( actionDescription ) ;
355361 var start = Date . now ( ) ;
356362 }
357363
358364 var result = action ( ) ;
359365
360- if ( ! noPerfLogging ) {
366+ if ( logPerformance ) {
361367 var end = Date . now ( ) ;
362368 logger . log ( actionDescription + " completed in " + ( end - start ) + " msec" ) ;
363369 if ( typeof ( result ) === "string" ) {
@@ -372,9 +378,9 @@ namespace ts {
372378 return result ;
373379 }
374380
375- function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : string {
381+ function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , logPerformance : boolean ) : string {
376382 try {
377- var result = simpleForwardCall ( logger , actionDescription , action , noPerfLogging ) ;
383+ var result = simpleForwardCall ( logger , actionDescription , action , logPerformance ) ;
378384 return JSON . stringify ( { result : result } ) ;
379385 }
380386 catch ( err ) {
@@ -413,6 +419,7 @@ namespace ts {
413419
414420 class LanguageServiceShimObject extends ShimBase implements LanguageServiceShim {
415421 private logger : Logger ;
422+ private logPerformance = false ;
416423
417424 constructor ( factory : ShimFactory ,
418425 private host : LanguageServiceShimHost ,
@@ -422,7 +429,7 @@ namespace ts {
422429 }
423430
424431 public forwardJSONCall ( actionDescription : string , action : ( ) => any ) : string {
425- return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
432+ return forwardJSONCall ( this . logger , actionDescription , action , this . logPerformance ) ;
426433 }
427434
428435 /// DISPOSE
@@ -811,6 +818,7 @@ namespace ts {
811818
812819 class ClassifierShimObject extends ShimBase implements ClassifierShim {
813820 public classifier : Classifier ;
821+ private logPerformance = false ;
814822
815823 constructor ( factory : ShimFactory , private logger : Logger ) {
816824 super ( factory ) ;
@@ -820,7 +828,7 @@ namespace ts {
820828 public getEncodedLexicalClassifications ( text : string , lexState : EndOfLineState , syntacticClassifierAbsent ?: boolean ) : string {
821829 return forwardJSONCall ( this . logger , "getEncodedLexicalClassifications" ,
822830 ( ) => convertClassifications ( this . classifier . getEncodedLexicalClassifications ( text , lexState , syntacticClassifierAbsent ) ) ,
823- /*noPerfLogging:*/ true ) ;
831+ this . logPerformance ) ;
824832 }
825833
826834 /// COLORIZATION
@@ -838,13 +846,14 @@ namespace ts {
838846 }
839847
840848 class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
849+ private logPerformance = false ;
841850
842851 constructor ( factory : ShimFactory , public logger : Logger , private host : CoreServicesShimHostAdapter ) {
843852 super ( factory ) ;
844853 }
845854
846855 private forwardJSONCall ( actionDescription : string , action : ( ) => any ) : any {
847- return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
856+ return forwardJSONCall ( this . logger , actionDescription , action , this . logPerformance ) ;
848857 }
849858
850859 public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
0 commit comments