Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/harness/projectServiceStateLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export function patchServiceForStateBaseline(service: ProjectService) {
function baselineProjects(currentMappers: Set<DocumentPositionMapper>) {
const autoImportProviderProjects = [] as AutoImportProviderProject[];
const auxiliaryProjects = [] as AuxiliaryProject[];
const orphanConfiguredProjects = service.getOrphanConfiguredProjects(/*toRetainConfiguredProjects*/ undefined);
const noOpenRef = (project: Project) => isConfiguredProject(project) && (project.isClosed() || orphanConfiguredProjects.has(project));
return baselineState(
[service.externalProjects, service.configuredProjects, service.inferredProjects, autoImportProviderProjects, auxiliaryProjects],
projects,
Expand All @@ -118,7 +120,7 @@ export function patchServiceForStateBaseline(service: ProjectService) {
projectDiff = printProperty(PrintPropertyWhen.TruthyOrChangedOrNew, data, "dirty", project.dirty, projectDiff, projectPropertyLogs);
projectDiff = printProperty(PrintPropertyWhen.TruthyOrChangedOrNew, data, "isClosed", project.isClosed(), projectDiff, projectPropertyLogs);
projectDiff = printProperty(PrintPropertyWhen.TruthyOrChangedOrNew, data, "isOrphan", !isBackgroundProject(project) && project.isOrphan(), projectDiff, projectPropertyLogs);
projectDiff = printProperty(PrintPropertyWhen.TruthyOrChangedOrNew, data, "noOpenRef", isConfiguredProject(project) && !project.hasOpenRef(), projectDiff, projectPropertyLogs);
projectDiff = printProperty(PrintPropertyWhen.TruthyOrChangedOrNew, data, "noOpenRef", noOpenRef(project), projectDiff, projectPropertyLogs);
projectDiff = printProperty(PrintPropertyWhen.TruthyOrChangedOrNew, data, "deferredClose", isConfiguredProject(project) && project.deferredClose, projectDiff, projectPropertyLogs);
projectDiff = printMapPropertyValue(
PrintPropertyWhen.Changed,
Expand Down Expand Up @@ -149,7 +151,7 @@ export function patchServiceForStateBaseline(service: ProjectService) {
dirty: project.dirty,
isClosed: project.isClosed(),
isOrphan: !isBackgroundProject(project) && project.isOrphan(),
noOpenRef: isConfiguredProject(project) && !project.hasOpenRef(),
noOpenRef: noOpenRef(project),
deferredClose: isConfiguredProject(project) && project.deferredClose,
autoImportProviderHost: project.autoImportProviderHost,
noDtsResolutionProject: project.noDtsResolutionProject,
Expand Down
18 changes: 12 additions & 6 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4114,7 +4114,14 @@ export class ProjectService {
}

private removeOrphanConfiguredProjects(toRetainConfiguredProjects: readonly ConfiguredProject[] | ConfiguredProject | undefined) {
const toRemoveConfiguredProjects = new Map(this.configuredProjects);
const orphanConfiguredProjects = this.getOrphanConfiguredProjects(toRetainConfiguredProjects);
// Remove all the non marked projects
orphanConfiguredProjects.forEach(project => this.removeProject(project));
}

/** @internal */
getOrphanConfiguredProjects(toRetainConfiguredProjects: readonly ConfiguredProject[] | ConfiguredProject | undefined) {
const toRemoveConfiguredProjects = new Set(this.configuredProjects.values());
const markOriginalProjectsAsUsed = (project: Project) => {
if (project.originalConfiguredProjects && (isConfiguredProject(project) || !project.isOrphan())) {
project.originalConfiguredProjects.forEach(
Expand All @@ -4138,7 +4145,7 @@ export class ProjectService {
this.inferredProjects.forEach(markOriginalProjectsAsUsed);
this.externalProjects.forEach(markOriginalProjectsAsUsed);
this.configuredProjects.forEach(project => {
if (!toRemoveConfiguredProjects.has(project.canonicalConfigFilePath)) return;
if (!toRemoveConfiguredProjects.has(project)) return;
// If project has open ref (there are more than zero references from external project/open file), keep it alive as well as any project it references
if (project.hasOpenRef()) {
retainConfiguredProject(project);
Expand All @@ -4149,15 +4156,14 @@ export class ProjectService {
}
});

// Remove all the non marked projects
toRemoveConfiguredProjects.forEach(project => this.removeProject(project));
return toRemoveConfiguredProjects;

function isRetained(project: ConfiguredProject) {
return !toRemoveConfiguredProjects.has(project.canonicalConfigFilePath) || project.hasOpenRef();
return !toRemoveConfiguredProjects.has(project) || project.hasOpenRef();
}

function retainConfiguredProject(project: ConfiguredProject) {
if (toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath)) {
if (toRemoveConfiguredProjects.delete(project)) {
// Keep original projects used
markOriginalProjectsAsUsed(project);
// Keep all the references alive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ Projects::
projectStateVersion: 1
projectProgramVersion: 0
dirty: true
noOpenRef: true

ScriptInfos::
/node_modules/@angular/forms/forms.d.ts *new*
Expand Down Expand Up @@ -700,7 +699,6 @@ Projects::
/packages/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
originalConfiguredProjects: 3
/packages/b/tsconfig.json
/tsconfig.json
Expand All @@ -713,7 +711,6 @@ Projects::
projectStateVersion: 1
projectProgramVersion: 1 *changed*
dirty: false *changed*
noOpenRef: true
originalConfiguredProjects: 3 *changed*
/packages/b/tsconfig.json *new*
/tsconfig.json *new*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,6 @@ Projects::
/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -1059,10 +1058,10 @@ FsWatchesRecursive::
{}

Projects::
/a/tsconfig.json (Configured)
/a/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: true *changed*
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 2 *changed*
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,10 @@ FsWatchesRecursive::
{}

Projects::
/a/tsconfig.json (Configured)
/a/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: false *changed*
/b/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -639,7 +639,6 @@ Projects::
/a/tsconfig.json (Configured)
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ Projects::
/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -1093,10 +1092,10 @@ FsWatchesRecursive::
{}

Projects::
/a/tsconfig.json (Configured)
/a/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: true *changed*
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 2 *changed*
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,11 +907,11 @@ FsWatchesRecursive::
{}

Projects::
/b/tsconfig.json (Configured)
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
dirty: true
noOpenRef: true
noOpenRef: false *changed*
/user/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -1035,11 +1035,11 @@ FsWatchesRecursive::
{}

Projects::
/b/tsconfig.json (Configured)
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
dirty: true
noOpenRef: true
noOpenRef: true *changed*
/user/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -1212,15 +1212,15 @@ Projects::
/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
/b/tsconfig.json (Configured)
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
dirty: true
noOpenRef: true
/user/tsconfig.json (Configured)
noOpenRef: false *changed*
/user/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: false *changed*

ScriptInfos::
/a/a.ts (Open) *changed*
Expand Down Expand Up @@ -1294,15 +1294,15 @@ Projects::
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true *changed*
/b/tsconfig.json (Configured)
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
dirty: true
noOpenRef: true
/user/tsconfig.json (Configured)
noOpenRef: true *changed*
/user/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: true *changed*

ScriptInfos::
/a/a.ts *changed*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,10 @@ FsWatchesRecursive::
{}

Projects::
/b/tsconfig.json (Configured)
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: false *changed*
/user/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,10 @@ FsWatchesRecursive::
{}

Projects::
/b/tsconfig.json (Configured)
/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: false *changed*
/user/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,6 @@ Projects::
/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -1073,10 +1072,10 @@ FsWatchesRecursive::
{}

Projects::
/a/tsconfig.json (Configured)
/a/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: true *changed*
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 2 *changed*
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ Projects::
/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down Expand Up @@ -1034,10 +1033,10 @@ FsWatchesRecursive::
{}

Projects::
/a/tsconfig.json (Configured)
/a/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: true *changed*
/dev/null/inferredProject1* (Inferred) *changed*
projectStateVersion: 2 *changed*
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ Projects::
/user/username/projects/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/user/username/projects/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ Projects::
/user/username/projects/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/user/username/projects/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ Projects::
/user/username/projects/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/user/username/projects/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ Projects::
/user/username/projects/a/tsconfig.json (Configured) *new*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
/user/username/projects/b/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ watchedDirectoriesRecursive::
{}

Projects::
/common/tsconfig.json (Configured)
/common/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: false *changed*
/dev/null/inferredProject1* (Inferred)
projectStateVersion: 1
projectProgramVersion: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ Projects::
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: false *changed*
/packages/dep/tsconfig.json (Configured)
/packages/dep/tsconfig.json (Configured) *changed*
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true
noOpenRef: false *changed*

ScriptInfos::
/lib.d.ts
Expand Down Expand Up @@ -716,7 +716,6 @@ Projects::
/packages/dep/tsconfig.json (Configured)
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true

ScriptInfos::
/lib.d.ts
Expand Down Expand Up @@ -926,7 +925,6 @@ Projects::
/packages/dep/tsconfig.json (Configured)
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true

ScriptInfos::
/lib.d.ts
Expand Down Expand Up @@ -1139,7 +1137,6 @@ Projects::
/packages/dep/tsconfig.json (Configured)
projectStateVersion: 1
projectProgramVersion: 1
noOpenRef: true

ScriptInfos::
/lib.d.ts
Expand Down
Loading