@@ -106,6 +106,7 @@ namespace ts.server {
106
106
private rootFiles : ScriptInfo [ ] = [ ] ;
107
107
private rootFilesMap : FileMap < ScriptInfo > = createFileMap < ScriptInfo > ( ) ;
108
108
private program : ts . Program ;
109
+ private externalFiles : SortedReadonlyArray < string > ;
109
110
110
111
private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap ( ) ;
111
112
private lastCachedUnresolvedImportsList : SortedReadonlyArray < string > ;
@@ -261,8 +262,8 @@ namespace ts.server {
261
262
abstract getProjectRootPath ( ) : string | undefined ;
262
263
abstract getTypeAcquisition ( ) : TypeAcquisition ;
263
264
264
- getExternalFiles ( ) : string [ ] {
265
- return [ ] ;
265
+ getExternalFiles ( ) : SortedReadonlyArray < string > {
266
+ return emptyArray as SortedReadonlyArray < string > ;
266
267
}
267
268
268
269
getSourceFile ( path : Path ) {
@@ -561,6 +562,24 @@ namespace ts.server {
561
562
}
562
563
}
563
564
}
565
+
566
+ const oldExternalFiles = this . externalFiles || emptyArray as SortedReadonlyArray < string > ;
567
+ this . externalFiles = this . getExternalFiles ( ) ;
568
+ enumerateInsertsAndDeletes ( this . externalFiles , oldExternalFiles ,
569
+ // Ensure a ScriptInfo is created for new external files. This is performed indirectly
570
+ // by the LSHost for files in the program when the program is retrieved above but
571
+ // the program doesn't contain external files so this must be done explicitly.
572
+ inserted => {
573
+ const scriptInfo = this . projectService . getOrCreateScriptInfo ( inserted , /*openedByClient*/ false ) ;
574
+ scriptInfo . attachToProject ( this ) ;
575
+ } ,
576
+ removed => {
577
+ const scriptInfoToDetach = this . projectService . getScriptInfo ( removed ) ;
578
+ if ( scriptInfoToDetach ) {
579
+ scriptInfoToDetach . detachFromProject ( this ) ;
580
+ }
581
+ } ) ;
582
+
564
583
return hasChanges ;
565
584
}
566
585
@@ -956,7 +975,7 @@ namespace ts.server {
956
975
return this . typeAcquisition ;
957
976
}
958
977
959
- getExternalFiles ( ) : string [ ] {
978
+ getExternalFiles ( ) : SortedReadonlyArray < string > {
960
979
const items : string [ ] = [ ] ;
961
980
for ( const plugin of this . plugins ) {
962
981
if ( typeof plugin . getExternalFiles === "function" ) {
@@ -968,7 +987,7 @@ namespace ts.server {
968
987
}
969
988
}
970
989
}
971
- return items ;
990
+ return toSortedReadonlyArray ( items ) ;
972
991
}
973
992
974
993
watchConfigFile ( callback : ( project : ConfiguredProject ) => void ) {
0 commit comments