4
4
"time"
5
5
6
6
"github.com/microsoft/typescript-go/internal/ast"
7
+ "github.com/microsoft/typescript-go/internal/collections"
7
8
"github.com/microsoft/typescript-go/internal/compiler"
8
9
"github.com/microsoft/typescript-go/internal/ls"
9
10
"github.com/microsoft/typescript-go/internal/project/logging"
@@ -22,24 +23,49 @@ type compilerHost struct {
22
23
fs * snapshotFSBuilder
23
24
compilerFS * compilerFS
24
25
configFileRegistry * ConfigFileRegistry
26
+ seenFiles * collections.SyncSet [tspath.Path ]
25
27
26
28
project * Project
27
29
builder * projectCollectionBuilder
28
30
logger * logging.LogTree
29
31
}
30
32
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
+
31
48
func newCompilerHost (
32
49
currentDirectory string ,
33
50
project * Project ,
34
51
builder * projectCollectionBuilder ,
35
52
logger * logging.LogTree ,
36
53
) * compilerHost {
54
+ seenFiles := & collections.SyncSet [tspath.Path ]{}
55
+ compilerFS := & compilerFS {
56
+ source : & builderFileSource {
57
+ seenFiles : seenFiles ,
58
+ snapshotFSBuilder : builder .fs ,
59
+ },
60
+ }
61
+
37
62
return & compilerHost {
38
63
configFilePath : project .configFilePath ,
39
64
currentDirectory : currentDirectory ,
40
65
sessionOptions : builder .sessionOptions ,
41
66
42
- compilerFS : & compilerFS {source : builder .fs },
67
+ compilerFS : compilerFS ,
68
+ seenFiles : seenFiles ,
43
69
44
70
fs : builder .fs ,
45
71
project : project ,
@@ -88,6 +114,7 @@ func (c *compilerHost) GetResolvedProjectReference(fileName string, path tspath.
88
114
if c .builder == nil {
89
115
return c .configFileRegistry .GetConfig (path )
90
116
} else {
117
+ c .seenFiles .Add (path )
91
118
return c .builder .configFileRegistryBuilder .acquireConfigForProject (fileName , path , c .project , c .logger )
92
119
}
93
120
}
@@ -97,6 +124,7 @@ func (c *compilerHost) GetResolvedProjectReference(fileName string, path tspath.
97
124
// be a corresponding release for each call made.
98
125
func (c * compilerHost ) GetSourceFile (opts ast.SourceFileParseOptions ) * ast.SourceFile {
99
126
c .ensureAlive ()
127
+ c .seenFiles .Add (opts .Path )
100
128
if fh := c .fs .GetFileByPath (opts .FileName , opts .Path ); fh != nil {
101
129
return c .builder .parseCache .Acquire (fh , opts , fh .Kind ())
102
130
}
0 commit comments