Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 8f9a38a

Browse files
authored
Share DocumentRegistry (#287)
1 parent bbb482c commit 8f9a38a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/project-manager.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ export class ProjectManager implements Disposable {
121121
this.strict = strict;
122122
this.traceModuleResolution = traceModuleResolution || false;
123123

124+
// Share DocumentRegistry between all ProjectConfigurations
125+
const documentRegistry = ts.createDocumentRegistry();
126+
124127
// Create catch-all fallback configs in case there are no tsconfig.json files
125128
// They are removed once at least one tsconfig.json is found
126129
const trimmedRootPath = this.rootPath.replace(/\/+$/, '');
@@ -137,6 +140,7 @@ export class ProjectManager implements Disposable {
137140
};
138141
const config = new ProjectConfiguration(
139142
this.localFs,
143+
documentRegistry,
140144
trimmedRootPath,
141145
this.versions,
142146
'',
@@ -165,6 +169,7 @@ export class ProjectManager implements Disposable {
165169
const configs = this.configs[configType];
166170
configs.set(dir, new ProjectConfiguration(
167171
this.localFs,
172+
documentRegistry,
168173
dir,
169174
this.versions,
170175
filePath,
@@ -767,12 +772,14 @@ export class ProjectConfiguration {
767772

768773
/**
769774
* @param fs file system to use
775+
* @param documentRegistry Shared DocumentRegistry that manages SourceFile objects
770776
* @param rootFilePath root file path, absolute
771777
* @param configFilePath configuration file path, absolute
772778
* @param configContent optional configuration content to use instead of reading configuration file)
773779
*/
774780
constructor(
775781
fs: InMemoryFileSystem,
782+
private documentRegistry: ts.DocumentRegistry,
776783
rootFilePath: string,
777784
versions: Map<string, number>,
778785
configFilePath: string,
@@ -887,7 +894,7 @@ export class ProjectConfiguration {
887894
this.versions,
888895
this.logger
889896
);
890-
this.service = ts.createLanguageService(this.host, ts.createDocumentRegistry());
897+
this.service = ts.createLanguageService(this.host, this.documentRegistry);
891898
this.initialized = true;
892899
}
893900

0 commit comments

Comments
 (0)