@@ -308,18 +308,16 @@ module ts {
308
308
}
309
309
}
310
310
311
- function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : any {
312
- return action ( ) ;
313
-
314
- if ( logger ) {
311
+ function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : any {
312
+ if ( ! noPerfLogging ) {
315
313
logger . log ( actionDescription ) ;
314
+ var start = Date . now ( ) ;
316
315
}
317
316
318
- var start = Date . now ( ) ;
319
317
var result = action ( ) ;
320
- var end = Date . now ( ) ;
321
318
322
- if ( logger ) {
319
+ if ( ! noPerfLogging ) {
320
+ var end = Date . now ( ) ;
323
321
logger . log ( actionDescription + " completed in " + ( end - start ) + " msec" ) ;
324
322
if ( typeof ( result ) === "string" ) {
325
323
var str = < string > result ;
@@ -333,9 +331,9 @@ module ts {
333
331
return result ;
334
332
}
335
333
336
- function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : string {
334
+ function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : string {
337
335
try {
338
- var result = simpleForwardCall ( logger , actionDescription , action ) ;
336
+ var result = simpleForwardCall ( logger , actionDescription , action , noPerfLogging ) ;
339
337
return JSON . stringify ( { result : result } ) ;
340
338
}
341
339
catch ( err ) {
@@ -383,7 +381,7 @@ module ts {
383
381
}
384
382
385
383
public forwardJSONCall ( actionDescription : string , action : ( ) => any ) : string {
386
- return forwardJSONCall ( this . logger , actionDescription , action ) ;
384
+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
387
385
}
388
386
389
387
/// DISPOSE
@@ -759,14 +757,15 @@ module ts {
759
757
class ClassifierShimObject extends ShimBase implements ClassifierShim {
760
758
public classifier : Classifier ;
761
759
762
- constructor ( factory : ShimFactory ) {
760
+ constructor ( factory : ShimFactory , private logger : Logger ) {
763
761
super ( factory ) ;
764
762
this . classifier = createClassifier ( ) ;
765
763
}
766
764
767
765
public getLexicalClassifications2 ( text : string , lexState : EndOfLineState , syntacticClassifierAbsent ?: boolean ) : string {
768
- return forwardJSONCall ( /*logger:*/ undefined , "getLexicalClassifications2" ,
769
- ( ) => convertClassifications ( this . classifier . getLexicalClassifications2 ( text , lexState , syntacticClassifierAbsent ) ) ) ;
766
+ return forwardJSONCall ( this . logger , "getLexicalClassifications2" ,
767
+ ( ) => convertClassifications ( this . classifier . getLexicalClassifications2 ( text , lexState , syntacticClassifierAbsent ) ) ,
768
+ /*noPerfLogging:*/ true ) ;
770
769
}
771
770
772
771
/// COLORIZATION
@@ -789,7 +788,7 @@ module ts {
789
788
}
790
789
791
790
private forwardJSONCall ( actionDescription : string , action : ( ) => any ) : any {
792
- return forwardJSONCall ( this . logger , actionDescription , action ) ;
791
+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
793
792
}
794
793
795
794
public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
@@ -856,7 +855,7 @@ module ts {
856
855
857
856
public createClassifierShim ( logger : Logger ) : ClassifierShim {
858
857
try {
859
- return new ClassifierShimObject ( this ) ;
858
+ return new ClassifierShimObject ( this , logger ) ;
860
859
}
861
860
catch ( err ) {
862
861
logInternalError ( logger , err ) ;
0 commit comments