@@ -502,6 +502,7 @@ export class LSHost implements ts.LanguageServiceHost {
502
502
compilationSettings : ts . CompilerOptions ;
503
503
filenameToScript : Map < ts . Path , ScriptInfo > ;
504
504
roots : ScriptInfo [ ] = [ ] ;
505
+ version : number = 0 ;
505
506
506
507
private resolvedModuleNames : Map < ts . Path , ts . Map < TimestampedResolvedModule > > ;
507
508
private resolvedTypeReferenceDirectives : Map < ts . Path , ts . Map < TimestampedResolvedTypeReferenceDirective > > ;
@@ -577,6 +578,10 @@ export class LSHost implements ts.LanguageServiceHost {
577
578
}
578
579
}
579
580
581
+ getProjectVersion ( ) {
582
+ return this . version . toString ( ) ;
583
+ }
584
+
580
585
resolveTypeReferenceDirectives ( typeDirectiveNames : string [ ] , containingFile : string ) : ts . ResolvedTypeReferenceDirective [ ] {
581
586
return this . resolveNamesWithLocalCache ( typeDirectiveNames , containingFile , this . resolvedTypeReferenceDirectives , ts . resolveTypeReferenceDirective , m => m . resolvedTypeReferenceDirective ) ;
582
587
}
@@ -602,6 +607,7 @@ export class LSHost implements ts.LanguageServiceHost {
602
607
// conservatively assume that changing compiler options might affect module resolution strategy
603
608
this . resolvedModuleNames . clear ( ) ;
604
609
this . resolvedTypeReferenceDirectives . clear ( ) ;
610
+ this . modified ( ) ;
605
611
}
606
612
607
613
lineAffectsRefs ( filename : string , line : number ) {
@@ -651,6 +657,7 @@ export class LSHost implements ts.LanguageServiceHost {
651
657
this . filenameToScript . delete ( info . path ) ;
652
658
this . resolvedModuleNames . delete ( info . path ) ;
653
659
this . resolvedTypeReferenceDirectives . delete ( info . path ) ;
660
+ this . modified ( ) ;
654
661
}
655
662
}
656
663
@@ -670,6 +677,7 @@ export class LSHost implements ts.LanguageServiceHost {
670
677
if ( ! this . filenameToScript . has ( info . path ) ) {
671
678
this . filenameToScript . set ( info . path , info ) ;
672
679
this . roots . push ( info ) ;
680
+ this . modified ( ) ;
673
681
}
674
682
}
675
683
@@ -679,6 +687,7 @@ export class LSHost implements ts.LanguageServiceHost {
679
687
this . roots = copyListRemovingItem ( info , this . roots ) ;
680
688
this . resolvedModuleNames . delete ( info . path ) ;
681
689
this . resolvedTypeReferenceDirectives . delete ( info . path ) ;
690
+ this . modified ( ) ;
682
691
}
683
692
}
684
693
@@ -694,13 +703,15 @@ export class LSHost implements ts.LanguageServiceHost {
694
703
const script = this . getScriptInfo ( filename ) ;
695
704
if ( script ) {
696
705
script . svc . reloadFromFile ( tmpfilename , cb ) ;
706
+ this . modified ( ) ;
697
707
}
698
708
}
699
709
700
710
editScript ( filename : string , start : number , end : number , newText : string ) {
701
711
const script = this . getScriptInfo ( filename ) ;
702
712
if ( script ) {
703
713
script . editContent ( start , end , newText ) ;
714
+ this . modified ( ) ;
704
715
return ;
705
716
}
706
717
@@ -774,6 +785,10 @@ export class LSHost implements ts.LanguageServiceHost {
774
785
const script : ScriptInfo = this . filenameToScript . get ( path ) ;
775
786
return script . snap ( ) . index ;
776
787
}
788
+
789
+ private modified ( ) {
790
+ this . version ++ ;
791
+ }
777
792
}
778
793
779
794
export interface ProjectOptions {
@@ -1544,12 +1559,14 @@ export class ProjectService {
1544
1559
}
1545
1560
1546
1561
// Update Angular summaries
1562
+ let start = Date . now ( ) ;
1547
1563
for ( let project of this . configuredProjects ) {
1548
1564
project . compilerService . ngHost . updateModuleSummary ( ) ;
1549
1565
}
1550
1566
for ( let project of this . inferredProjects ) {
1551
1567
project . compilerService . ngHost . updateModuleSummary ( ) ;
1552
1568
}
1569
+ this . log ( `updated: ng - ${ Date . now ( ) - start } ms` , "Info" ) ;
1553
1570
1554
1571
this . printProjects ( ) ;
1555
1572
}
@@ -1997,7 +2014,7 @@ export class CompilerService {
1997
2014
1998
2015
this . ng = this . resolveLanguageServiceModule ( ) ;
1999
2016
this . ngHost = new this . ng . TypeScriptServiceHost ( ts , this . host , this . languageService ) ;
2000
- this . ngService = this . ng . createLanguageService ( this . ngHost ) ;
2017
+ this . ngService = logServiceTimes ( logger , this . ng . createLanguageService ( this . ngHost ) ) ;
2001
2018
this . ngHost . setSite ( this . ngService ) ;
2002
2019
this . classifier = ts . createClassifier ( ) ;
2003
2020
}
@@ -3006,3 +3023,27 @@ export class LineLeaf implements LineCollection {
3006
3023
return 1 ;
3007
3024
}
3008
3025
}
3026
+
3027
+
3028
+ function logServiceTimes ( logger : Logger , service : ng . LanguageService ) : ng . LanguageService {
3029
+ function time < T > ( name : string , cb : ( ) => T ) : T {
3030
+ const start = Date . now ( ) ;
3031
+ const result = cb ( ) ;
3032
+ logger . msg ( `${ name } : ${ Date . now ( ) - start } ms` ) ;
3033
+ return result ;
3034
+ }
3035
+ return {
3036
+ getCompletionsAt ( fileName , position ) {
3037
+ return time ( "getCompletions" , ( ) => service . getCompletionsAt ( fileName , position ) ) ;
3038
+ } ,
3039
+ getDiagnostics ( fileName ) {
3040
+ return time ( "getDiagnnostics" , ( ) => service . getDiagnostics ( fileName ) ) ;
3041
+ } ,
3042
+ getTemplateReferences ( ) {
3043
+ return time ( "getTemplateRefrences" , ( ) => service . getTemplateReferences ( ) ) ;
3044
+ } ,
3045
+ getPipesAt ( fileName , position ) {
3046
+ return service . getPipesAt ( fileName , position ) ;
3047
+ }
3048
+ } ;
3049
+ }
0 commit comments