@@ -326,18 +326,16 @@ module ts {
326326 }
327327 }
328328
329- function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : any {
330- return action ( ) ;
331-
332- if ( logger ) {
329+ function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : any {
330+ if ( ! noPerfLogging ) {
333331 logger . log ( actionDescription ) ;
332+ var start = Date . now ( ) ;
334333 }
335334
336- var start = Date . now ( ) ;
337335 var result = action ( ) ;
338- var end = Date . now ( ) ;
339336
340- if ( logger ) {
337+ if ( ! noPerfLogging ) {
338+ var end = Date . now ( ) ;
341339 logger . log ( actionDescription + " completed in " + ( end - start ) + " msec" ) ;
342340 if ( typeof ( result ) === "string" ) {
343341 var str = < string > result ;
@@ -351,9 +349,9 @@ module ts {
351349 return result ;
352350 }
353351
354- function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : string {
352+ function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : string {
355353 try {
356- var result = simpleForwardCall ( logger , actionDescription , action ) ;
354+ var result = simpleForwardCall ( logger , actionDescription , action , noPerfLogging ) ;
357355 return JSON . stringify ( { result : result } ) ;
358356 }
359357 catch ( err ) {
@@ -401,7 +399,7 @@ module ts {
401399 }
402400
403401 public forwardJSONCall ( actionDescription : string , action : ( ) => any ) : string {
404- return forwardJSONCall ( this . logger , actionDescription , action ) ;
402+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
405403 }
406404
407405 /// DISPOSE
@@ -777,14 +775,15 @@ module ts {
777775 class ClassifierShimObject extends ShimBase implements ClassifierShim {
778776 public classifier : Classifier ;
779777
780- constructor ( factory : ShimFactory ) {
778+ constructor ( factory : ShimFactory , private logger : Logger ) {
781779 super ( factory ) ;
782780 this . classifier = createClassifier ( ) ;
783781 }
784782
785783 public getLexicalClassifications2 ( text : string , lexState : EndOfLineState , syntacticClassifierAbsent ?: boolean ) : string {
786- return forwardJSONCall ( /*logger:*/ undefined , "getLexicalClassifications2" ,
787- ( ) => convertClassifications ( this . classifier . getLexicalClassifications2 ( text , lexState , syntacticClassifierAbsent ) ) ) ;
784+ return forwardJSONCall ( this . logger , "getLexicalClassifications2" ,
785+ ( ) => convertClassifications ( this . classifier . getLexicalClassifications2 ( text , lexState , syntacticClassifierAbsent ) ) ,
786+ /*noPerfLogging:*/ true ) ;
788787 }
789788
790789 /// COLORIZATION
@@ -808,7 +807,7 @@ module ts {
808807 }
809808
810809 private forwardJSONCall ( actionDescription : string , action : ( ) => any ) : any {
811- return forwardJSONCall ( this . logger , actionDescription , action ) ;
810+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
812811 }
813812
814813 public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
@@ -901,7 +900,7 @@ module ts {
901900
902901 public createClassifierShim ( logger : Logger ) : ClassifierShim {
903902 try {
904- return new ClassifierShimObject ( this ) ;
903+ return new ClassifierShimObject ( this , logger ) ;
905904 }
906905 catch ( err ) {
907906 logInternalError ( logger , err ) ;
0 commit comments