@@ -308,18 +308,16 @@ module ts {
308308 }
309309 }
310310
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 ) {
315313 logger . log ( actionDescription ) ;
314+ var start = Date . now ( ) ;
316315 }
317316
318- var start = Date . now ( ) ;
319317 var result = action ( ) ;
320- var end = Date . now ( ) ;
321318
322- if ( logger ) {
319+ if ( ! noPerfLogging ) {
320+ var end = Date . now ( ) ;
323321 logger . log ( actionDescription + " completed in " + ( end - start ) + " msec" ) ;
324322 if ( typeof ( result ) === "string" ) {
325323 var str = < string > result ;
@@ -333,9 +331,9 @@ module ts {
333331 return result ;
334332 }
335333
336- function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : string {
334+ function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : string {
337335 try {
338- var result = simpleForwardCall ( logger , actionDescription , action ) ;
336+ var result = simpleForwardCall ( logger , actionDescription , action , noPerfLogging ) ;
339337 return JSON . stringify ( { result : result } ) ;
340338 }
341339 catch ( err ) {
@@ -383,7 +381,7 @@ module ts {
383381 }
384382
385383 public forwardJSONCall ( actionDescription : string , action : ( ) => any ) : string {
386- return forwardJSONCall ( this . logger , actionDescription , action ) ;
384+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
387385 }
388386
389387 /// DISPOSE
@@ -759,14 +757,15 @@ module ts {
759757 class ClassifierShimObject extends ShimBase implements ClassifierShim {
760758 public classifier : Classifier ;
761759
762- constructor ( factory : ShimFactory ) {
760+ constructor ( factory : ShimFactory , private logger : Logger ) {
763761 super ( factory ) ;
764762 this . classifier = createClassifier ( ) ;
765763 }
766764
767765 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 ) ;
770769 }
771770
772771 /// COLORIZATION
@@ -789,7 +788,7 @@ module ts {
789788 }
790789
791790 private forwardJSONCall ( actionDescription : string , action : ( ) => any ) : any {
792- return forwardJSONCall ( this . logger , actionDescription , action ) ;
791+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
793792 }
794793
795794 public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
@@ -856,7 +855,7 @@ module ts {
856855
857856 public createClassifierShim ( logger : Logger ) : ClassifierShim {
858857 try {
859- return new ClassifierShimObject ( this ) ;
858+ return new ClassifierShimObject ( this , logger ) ;
860859 }
861860 catch ( err ) {
862861 logInternalError ( logger , err ) ;
0 commit comments