@@ -326,18 +326,16 @@ module ts {
326
326
}
327
327
}
328
328
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 ) {
333
331
logger . log ( actionDescription ) ;
332
+ var start = Date . now ( ) ;
334
333
}
335
334
336
- var start = Date . now ( ) ;
337
335
var result = action ( ) ;
338
- var end = Date . now ( ) ;
339
336
340
- if ( logger ) {
337
+ if ( ! noPerfLogging ) {
338
+ var end = Date . now ( ) ;
341
339
logger . log ( actionDescription + " completed in " + ( end - start ) + " msec" ) ;
342
340
if ( typeof ( result ) === "string" ) {
343
341
var str = < string > result ;
@@ -351,9 +349,9 @@ module ts {
351
349
return result ;
352
350
}
353
351
354
- function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any ) : string {
352
+ function forwardJSONCall ( logger : Logger , actionDescription : string , action : ( ) => any , noPerfLogging : boolean ) : string {
355
353
try {
356
- var result = simpleForwardCall ( logger , actionDescription , action ) ;
354
+ var result = simpleForwardCall ( logger , actionDescription , action , noPerfLogging ) ;
357
355
return JSON . stringify ( { result : result } ) ;
358
356
}
359
357
catch ( err ) {
@@ -401,7 +399,7 @@ module ts {
401
399
}
402
400
403
401
public forwardJSONCall ( actionDescription : string , action : ( ) => any ) : string {
404
- return forwardJSONCall ( this . logger , actionDescription , action ) ;
402
+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
405
403
}
406
404
407
405
/// DISPOSE
@@ -777,14 +775,15 @@ module ts {
777
775
class ClassifierShimObject extends ShimBase implements ClassifierShim {
778
776
public classifier : Classifier ;
779
777
780
- constructor ( factory : ShimFactory ) {
778
+ constructor ( factory : ShimFactory , private logger : Logger ) {
781
779
super ( factory ) ;
782
780
this . classifier = createClassifier ( ) ;
783
781
}
784
782
785
783
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 ) ;
788
787
}
789
788
790
789
/// COLORIZATION
@@ -808,7 +807,7 @@ module ts {
808
807
}
809
808
810
809
private forwardJSONCall ( actionDescription : string , action : ( ) => any ) : any {
811
- return forwardJSONCall ( this . logger , actionDescription , action ) ;
810
+ return forwardJSONCall ( this . logger , actionDescription , action , /*noPerfLogging:*/ false ) ;
812
811
}
813
812
814
813
public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
@@ -901,7 +900,7 @@ module ts {
901
900
902
901
public createClassifierShim ( logger : Logger ) : ClassifierShim {
903
902
try {
904
- return new ClassifierShimObject ( this ) ;
903
+ return new ClassifierShimObject ( this , logger ) ;
905
904
}
906
905
catch ( err ) {
907
906
logInternalError ( logger , err ) ;
0 commit comments