@@ -246,16 +246,22 @@ module ts {
246
246
247
247
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
248
248
private files : string [ ] ;
249
+ private loggingEnabled = false ;
250
+ private tracingEnabled = false ;
249
251
250
252
constructor ( private shimHost : LanguageServiceShimHost ) {
251
253
}
252
254
253
255
public log ( s : string ) : void {
254
- this . shimHost . log ( s ) ;
256
+ if ( this . loggingEnabled ) {
257
+ this . shimHost . log ( s ) ;
258
+ }
255
259
}
256
260
257
261
public trace ( s : string ) : void {
258
- this . shimHost . trace ( s ) ;
262
+ if ( this . tracingEnabled ) {
263
+ this . shimHost . trace ( s ) ;
264
+ }
259
265
}
260
266
261
267
public error ( s : string ) : void {
@@ -349,15 +355,15 @@ module ts {
349
355
}
350
356
}
351
357
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 ) {
354
360
logger . log ( actionDescription ) ;
355
361
var start = Date . now ( ) ;
356
362
}
357
363
358
364
var result = action ( ) ;
359
365
360
- if ( ! noPerfLogging ) {
366
+ if ( logPerformance ) {
361
367
var end = Date . now ( ) ;
362
368
logger . log ( actionDescription + " completed in " + ( end - start ) + " msec" ) ;
363
369
if ( typeof ( result ) === "string" ) {
@@ -372,9 +378,9 @@ module ts {
372
378
return result ;
373
379
}
374
380
375
- function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : string {
381
+ function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , logPerformance : boolean ) : string {
376
382
try {
377
- var result = simpleForwardCall ( logger , actionDescription , action , noPerfLogging ) ;
383
+ var result = simpleForwardCall ( logger , actionDescription , action , logPerformance ) ;
378
384
return JSON . stringify ( { result : result } ) ;
379
385
}
380
386
catch ( err ) {
@@ -413,6 +419,7 @@ module ts {
413
419
414
420
class LanguageServiceShimObject extends ShimBase implements LanguageServiceShim {
415
421
private logger : Logger ;
422
+ private logPerformance = false ;
416
423
417
424
constructor ( factory : ShimFactory ,
418
425
private host : LanguageServiceShimHost ,
@@ -422,7 +429,7 @@ module ts {
422
429
}
423
430
424
431
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 ) ;
426
433
}
427
434
428
435
/// DISPOSE
@@ -811,6 +818,7 @@ module ts {
811
818
812
819
class ClassifierShimObject extends ShimBase implements ClassifierShim {
813
820
public classifier : Classifier ;
821
+ private logPerformance = false ;
814
822
815
823
constructor ( factory : ShimFactory , private logger : Logger ) {
816
824
super ( factory ) ;
@@ -820,7 +828,7 @@ module ts {
820
828
public getEncodedLexicalClassifications ( text : string , lexState : EndOfLineState , syntacticClassifierAbsent ?: boolean ) : string {
821
829
return forwardJSONCall ( this . logger , "getEncodedLexicalClassifications" ,
822
830
( ) => convertClassifications ( this . classifier . getEncodedLexicalClassifications ( text , lexState , syntacticClassifierAbsent ) ) ,
823
- /*noPerfLogging:*/ true ) ;
831
+ this . logPerformance ) ;
824
832
}
825
833
826
834
/// COLORIZATION
@@ -838,13 +846,14 @@ module ts {
838
846
}
839
847
840
848
class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
849
+ private logPerformance = false ;
841
850
842
851
constructor ( factory : ShimFactory , public logger : Logger , private host : CoreServicesShimHostAdapter ) {
843
852
super ( factory ) ;
844
853
}
845
854
846
855
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 ) ;
848
857
}
849
858
850
859
public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
0 commit comments