@@ -112,6 +112,7 @@ namespace ts.server {
112
112
private rootFiles : ScriptInfo [ ] = [ ] ;
113
113
private rootFilesMap : FileMap < ScriptInfo > = createFileMap < ScriptInfo > ( ) ;
114
114
private program : ts . Program ;
115
+ private externalFiles : SortedReadonlyArray < string > ;
115
116
116
117
private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap ( ) ;
117
118
private lastCachedUnresolvedImportsList : SortedReadonlyArray < string > ;
@@ -267,8 +268,8 @@ namespace ts.server {
267
268
abstract getProjectRootPath ( ) : string | undefined ;
268
269
abstract getTypeAcquisition ( ) : TypeAcquisition ;
269
270
270
- getExternalFiles ( ) : string [ ] {
271
- return [ ] ;
271
+ getExternalFiles ( ) : SortedReadonlyArray < string > {
272
+ return emptyArray as SortedReadonlyArray < string > ;
272
273
}
273
274
274
275
getSourceFile ( path : Path ) {
@@ -567,6 +568,24 @@ namespace ts.server {
567
568
}
568
569
}
569
570
}
571
+
572
+ const oldExternalFiles = this . externalFiles || emptyArray as SortedReadonlyArray < string > ;
573
+ this . externalFiles = this . getExternalFiles ( ) ;
574
+ enumerateInsertsAndDeletes ( this . externalFiles , oldExternalFiles ,
575
+ // Ensure a ScriptInfo is created for new external files. This is performed indirectly
576
+ // by the LSHost for files in the program when the program is retrieved above but
577
+ // the program doesn't contain external files so this must be done explicitly.
578
+ inserted => {
579
+ const scriptInfo = this . projectService . getOrCreateScriptInfo ( inserted , /*openedByClient*/ false ) ;
580
+ scriptInfo . attachToProject ( this ) ;
581
+ } ,
582
+ removed => {
583
+ const scriptInfoToDetach = this . projectService . getScriptInfo ( removed ) ;
584
+ if ( scriptInfoToDetach ) {
585
+ scriptInfoToDetach . detachFromProject ( this ) ;
586
+ }
587
+ } ) ;
588
+
570
589
return hasChanges ;
571
590
}
572
591
@@ -947,7 +966,7 @@ namespace ts.server {
947
966
return this . typeAcquisition ;
948
967
}
949
968
950
- getExternalFiles ( ) : string [ ] {
969
+ getExternalFiles ( ) : SortedReadonlyArray < string > {
951
970
const items : string [ ] = [ ] ;
952
971
for ( const plugin of this . plugins ) {
953
972
if ( typeof plugin . getExternalFiles === "function" ) {
@@ -959,7 +978,7 @@ namespace ts.server {
959
978
}
960
979
}
961
980
}
962
- return items ;
981
+ return toSortedReadonlyArray ( items ) ;
963
982
}
964
983
965
984
watchConfigFile ( callback : ( project : ConfiguredProject ) => void ) {
0 commit comments