Skip to content

Commit 80ba295

Browse files
committed
Real sharing across projects
1 parent ee741df commit 80ba295

File tree

643 files changed

+425
-9769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

643 files changed

+425
-9769
lines changed

src/server/editorServices.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
createDocumentRegistryInternal,
2121
createGetCanonicalFileName,
2222
createMultiMap,
23+
createSharedResolutionCache,
2324
Debug,
2425
Diagnostic,
2526
directorySeparator,
@@ -114,6 +115,7 @@ import {
114115
returnNoopFileWatcher,
115116
ScriptKind,
116117
SharedExtendedConfigFileWatcher,
118+
SharedResolutionCache,
117119
some,
118120
SourceFile,
119121
SourceFileLike,
@@ -1283,6 +1285,9 @@ export class ProjectService {
12831285
/** @internal */
12841286
readonly documentRegistry: DocumentRegistry;
12851287

1288+
/** @internal */
1289+
readonly sharedResolutionCache: SharedResolutionCache;
1290+
12861291
/**
12871292
* Container of all known scripts
12881293
*
@@ -1506,9 +1511,21 @@ export class ProjectService {
15061511
getDetailWatchInfo,
15071512
);
15081513
this.canUseWatchEvents = getCanUseWatchEvents(this, opts.canUseWatchEvents);
1514+
this.sharedResolutionCache = createSharedResolutionCache({
1515+
getCurrentDirectory: this.host.getCurrentDirectory.bind(this.host),
1516+
toPath: this.toPath.bind(this),
1517+
getCanonicalFileName: this.toCanonicalFileName,
1518+
preferNonRecursiveWatch: this.canUseWatchEvents || this.host.preferNonRecursiveWatch,
1519+
fileIsOpen: this.fileIsOpen.bind(this),
1520+
});
15091521
opts.incrementalVerifier?.(this);
15101522
}
15111523

1524+
/** @internal */
1525+
fileIsOpen(filePath: Path): boolean {
1526+
return this.openFiles.has(filePath);
1527+
}
1528+
15121529
toPath(fileName: string): Path {
15131530
return toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
15141531
}

src/server/project.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
639639
this.resolutionCache = createResolutionCache(
640640
this,
641641
this.currentDirectory,
642+
this.projectService.sharedResolutionCache,
642643
);
643644
this.languageService = createLanguageService(
644645
this,
@@ -989,7 +990,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
989990

990991
/** @internal */
991992
fileIsOpen(filePath: Path): boolean {
992-
return this.projectService.openFiles.has(filePath);
993+
return this.projectService.fileIsOpen(filePath);
993994
}
994995

995996
/** @internal */
@@ -2968,11 +2969,6 @@ export class AutoImportProviderProject extends Project {
29682969
override getSymlinkCache(): SymlinkCache {
29692970
return this.hostProject.getSymlinkCache();
29702971
}
2971-
2972-
/** @internal */
2973-
override getModuleResolutionCache(): ModuleResolutionCache | undefined {
2974-
return this.hostProject.getCurrentProgram()?.getModuleResolutionCache();
2975-
}
29762972
}
29772973

29782974
/**

tests/baselines/reference/tsserver/autoImportProvider/Auto-importable-file-is-in-inferred-project-until-imported.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,6 @@ Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /us
361361
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/project/tsconfig.json
362362
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Failed Lookup Locations
363363
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Failed Lookup Locations
364-
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/forms/package.json 2000 undefined Project: /user/username/projects/project/tsconfig.json WatchType: File location affecting resolution
365-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
366-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
367-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
368-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
369364
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/project/tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
370365
Info seq [hh:mm:ss:mss] Project '/user/username/projects/project/tsconfig.json' (Configured)
371366
Info seq [hh:mm:ss:mss] Files (3)

tests/baselines/reference/tsserver/autoImportProvider/Closes-AutoImportProviderProject-when-host-project-closes.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,6 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/project
365365
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
366366
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/random/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
367367
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/random/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
368-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
369-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
370-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
371-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
372368
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
373369
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
374370
Info seq [hh:mm:ss:mss] Files (2)
@@ -385,7 +381,6 @@ Info seq [hh:mm:ss:mss] -----------------------------------------------
385381
Info seq [hh:mm:ss:mss] AutoImportProviderProject: found 1 root files in 1 dependencies 0 referenced projects in * ms
386382
Info seq [hh:mm:ss:mss] Creating AutoImportProviderProject: /dev/null/autoImportProviderProject2*, currentDirectory: /user/username/projects/project/random
387383
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/autoImportProviderProject2*
388-
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/forms/package.json 2000 undefined Project: /dev/null/autoImportProviderProject2* WatchType: File location affecting resolution
389384
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/autoImportProviderProject2* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
390385
Info seq [hh:mm:ss:mss] Project '/dev/null/autoImportProviderProject2*' (AutoImportProvider)
391386
Info seq [hh:mm:ss:mss] Files (1)
@@ -416,11 +411,6 @@ Info seq [hh:mm:ss:mss] -----------------------------------------------
416411
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/project 1 undefined Config: /user/username/projects/project/tsconfig.json WatchType: Wild card directory
417412
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/project 1 undefined Config: /user/username/projects/project/tsconfig.json WatchType: Wild card directory
418413
Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/project/tsconfig.json 2000 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Config file
419-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
420-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
421-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
422-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
423-
Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/project/node_modules/@angular/forms/package.json 2000 undefined Project: /dev/null/autoImportProviderProject1* WatchType: File location affecting resolution
424414
Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /user/username/projects/project/index.ts 500 undefined WatchType: Closed Script info
425415
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
426416
Info seq [hh:mm:ss:mss] Files (2)

tests/baselines/reference/tsserver/autoImportProvider/Does-not-create-auto-import-providers-upon-opening-projects-for-find-all-references.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,6 @@ Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /us
369369
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages 0 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Failed Lookup Locations
370370
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages 0 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Failed Lookup Locations
371371
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/packages/b/package.json 2000 undefined Project: /user/username/projects/project/tsconfig.json WatchType: File location affecting resolution
372-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
373-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
374-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
375-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/tsconfig.json WatchType: Type roots
376372
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/project/tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
377373
Info seq [hh:mm:ss:mss] Project '/user/username/projects/project/tsconfig.json' (Configured)
378374
Info seq [hh:mm:ss:mss] Files (3)
@@ -463,17 +459,8 @@ Info seq [hh:mm:ss:mss] event:
463459
}
464460
}
465461
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/project/packages/a/tsconfig.json
466-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages 0 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Failed Lookup Locations
467-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages 0 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Failed Lookup Locations
468-
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/packages/b/package.json 2000 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: File location affecting resolution
469462
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages/a/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
470463
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages/a/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
471-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
472-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/packages/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
473-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
474-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
475-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
476-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /user/username/projects/project/packages/a/tsconfig.json WatchType: Type roots
477464
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/project/packages/a/tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
478465
Info seq [hh:mm:ss:mss] Project '/user/username/projects/project/packages/a/tsconfig.json' (Configured)
479466
Info seq [hh:mm:ss:mss] Files (3)

tests/baselines/reference/tsserver/autoImportProvider/Responds-to-manual-changes-in-node_modules.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,12 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/project
296296
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/tsconfig.json 2000 undefined WatchType: Config file for the inferred project root
297297
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/jsconfig.json 2000 undefined WatchType: Config file for the inferred project root
298298
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
299-
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/forms/package.json 2000 undefined Project: /dev/null/inferredProject1* WatchType: File location affecting resolution
300299
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/forms/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
301300
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/forms/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
302301
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
303302
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@angular/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
304303
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
305304
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
306-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
307-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
308-
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
309-
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
310305
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
311306
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
312307
Info seq [hh:mm:ss:mss] Files (2)

tests/baselines/reference/tsserver/autoImportProvider/Shared-source-files-between-AutoImportProvider-and-main-program.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/project
132132
Info seq [hh:mm:ss:mss] AutoImportProviderProject: found 1 root files in 1 dependencies 0 referenced projects in * ms
133133
Info seq [hh:mm:ss:mss] Creating AutoImportProviderProject: /dev/null/autoImportProviderProject1*, currentDirectory: /user/username/projects/project
134134
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/autoImportProviderProject1*
135-
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types/node/package.json 2000 undefined Project: /dev/null/autoImportProviderProject1* WatchType: File location affecting resolution
136135
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/memfs/lib/package.json 2000 undefined Project: /dev/null/autoImportProviderProject1* WatchType: File location affecting resolution
137136
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/memfs/package.json 2000 undefined Project: /dev/null/autoImportProviderProject1* WatchType: File location affecting resolution
138137
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/autoImportProviderProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms

0 commit comments

Comments
 (0)