44 "time"
55
66 "github.com/microsoft/typescript-go/internal/ast"
7+ "github.com/microsoft/typescript-go/internal/collections"
78 "github.com/microsoft/typescript-go/internal/compiler"
89 "github.com/microsoft/typescript-go/internal/ls"
910 "github.com/microsoft/typescript-go/internal/project/logging"
@@ -22,24 +23,49 @@ type compilerHost struct {
2223 fs * snapshotFSBuilder
2324 compilerFS * compilerFS
2425 configFileRegistry * ConfigFileRegistry
26+ seenFiles * collections.SyncSet [tspath.Path ]
2527
2628 project * Project
2729 builder * projectCollectionBuilder
2830 logger * logging.LogTree
2931}
3032
33+ type builderFileSource struct {
34+ seenFiles * collections.SyncSet [tspath.Path ]
35+ snapshotFSBuilder * snapshotFSBuilder
36+ }
37+
38+ func (c * builderFileSource ) GetFile (fileName string ) FileHandle {
39+ path := c .snapshotFSBuilder .toPath (fileName )
40+ c .seenFiles .Add (path )
41+ return c .snapshotFSBuilder .GetFileByPath (fileName , path )
42+ }
43+
44+ func (c * builderFileSource ) FS () vfs.FS {
45+ return c .snapshotFSBuilder .FS ()
46+ }
47+
3148func newCompilerHost (
3249 currentDirectory string ,
3350 project * Project ,
3451 builder * projectCollectionBuilder ,
3552 logger * logging.LogTree ,
3653) * compilerHost {
54+ seenFiles := & collections.SyncSet [tspath.Path ]{}
55+ compilerFS := & compilerFS {
56+ source : & builderFileSource {
57+ seenFiles : seenFiles ,
58+ snapshotFSBuilder : builder .fs ,
59+ },
60+ }
61+
3762 return & compilerHost {
3863 configFilePath : project .configFilePath ,
3964 currentDirectory : currentDirectory ,
4065 sessionOptions : builder .sessionOptions ,
4166
42- compilerFS : & compilerFS {source : builder .fs },
67+ compilerFS : compilerFS ,
68+ seenFiles : seenFiles ,
4369
4470 fs : builder .fs ,
4571 project : project ,
@@ -88,6 +114,7 @@ func (c *compilerHost) GetResolvedProjectReference(fileName string, path tspath.
88114 if c .builder == nil {
89115 return c .configFileRegistry .GetConfig (path )
90116 } else {
117+ c .seenFiles .Add (path )
91118 return c .builder .configFileRegistryBuilder .acquireConfigForProject (fileName , path , c .project , c .logger )
92119 }
93120}
@@ -97,6 +124,7 @@ func (c *compilerHost) GetResolvedProjectReference(fileName string, path tspath.
97124// be a corresponding release for each call made.
98125func (c * compilerHost ) GetSourceFile (opts ast.SourceFileParseOptions ) * ast.SourceFile {
99126 c .ensureAlive ()
127+ c .seenFiles .Add (opts .Path )
100128 if fh := c .fs .GetFileByPath (opts .FileName , opts .Path ); fh != nil {
101129 return c .builder .parseCache .Acquire (fh , opts , fh .Kind ())
102130 }
0 commit comments