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
28 changes: 15 additions & 13 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1775,11 +1775,9 @@ namespace ts.server {
const project = configFileName &&
this.findConfiguredProjectByProjectName(configFileName);

return project?.isSolution() ?
project.getDefaultChildProjectFromSolution(info) :
project && projectContainsInfoDirectly(project, info) ?
project :
undefined;
return project && projectContainsInfoDirectly(project, info) ?
project :
project?.getDefaultChildProjectFromProjectWithReferences(info);
}

/**
Expand Down Expand Up @@ -2826,8 +2824,8 @@ namespace ts.server {
else {
// reload from the disk
this.reloadConfiguredProject(project, reason);
// If this is solution, reload the project till the reloaded project contains the script info directly
if (!project.containsScriptInfo(info) && project.isSolution()) {
// If this project does not contain this file directly, reload the project till the reloaded project contains the script info directly
if (!projectContainsInfoDirectly(project, info)) {
const referencedProject = forEachResolvedProjectReferenceProject(
project,
child => {
Expand Down Expand Up @@ -2936,14 +2934,18 @@ namespace ts.server {
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location: " + location.fileName : ""}`);
updateProjectIfDirty(configuredProject);

if (configuredProject.isSolution()) {
const projectContainsOriginalInfo = (project: ConfiguredProject) => {
const info = this.getScriptInfo(fileName);
return info && projectContainsInfoDirectly(project, info);
};

if (configuredProject.isSolution() || !projectContainsOriginalInfo(configuredProject)) {
// Find the project that is referenced from this solution that contains the script info directly
configuredProject = forEachResolvedProjectReferenceProject(
configuredProject,
child => {
updateProjectIfDirty(child);
const info = this.getScriptInfo(fileName);
return info && projectContainsInfoDirectly(child, info) ? child : undefined;
return projectContainsOriginalInfo(child) ? child : undefined;
},
configuredProject.getCompilerOptions().disableReferencedProjectLoad ? ProjectReferenceProjectLoadKind.Find : ProjectReferenceProjectLoadKind.FindCreateLoad,
`Creating project referenced in solution ${configuredProject.projectName} to find possible configured project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location: " + location.fileName : ""}`
Expand Down Expand Up @@ -3026,7 +3028,7 @@ namespace ts.server {

// If this configured project doesnt contain script info but
// it is solution with project references, try those project references
if (project.isSolution()) {
if (!projectContainsInfoDirectly(project, info)) {
forEachResolvedProjectReferenceProject(
project,
child => {
Expand Down Expand Up @@ -3151,10 +3153,10 @@ namespace ts.server {
if (forEachPotentialProjectReference(
project,
potentialRefPath => forProjects!.has(potentialRefPath)
) || (project.isSolution() && forEachResolvedProjectReference(
) || forEachResolvedProjectReference(
project,
(_ref, resolvedPath) => forProjects!.has(resolvedPath)
))) {
)) {
// Load children
this.ensureProjectChildren(project, seenProjects);
}
Expand Down
12 changes: 4 additions & 8 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2225,9 +2225,8 @@ namespace ts.server {
}

/* @internal */
/** Find the configured project from the project references in this solution which contains the info directly */
getDefaultChildProjectFromSolution(info: ScriptInfo) {
Debug.assert(this.isSolution());
/** Find the configured project from the project references in project which contains the info directly */
getDefaultChildProjectFromProjectWithReferences(info: ScriptInfo) {
return forEachResolvedProjectReferenceProject(
this,
child => projectContainsInfoDirectly(child, info) ?
Expand Down Expand Up @@ -2257,22 +2256,19 @@ namespace ts.server {
return !!configFileExistenceInfo.openFilesImpactedByConfigFile.size;
}

const isSolution = this.isSolution();

// If there is no pending update for this project,
// We know exact set of open files that get impacted by this configured project as the files in the project
// The project is referenced only if open files impacted by this project are present in this project
return forEachEntry(
configFileExistenceInfo.openFilesImpactedByConfigFile,
(_value, infoPath) => {
const info = this.projectService.getScriptInfoForPath(infoPath)!;
return isSolution ?
return this.containsScriptInfo(info) ||
!!forEachResolvedProjectReferenceProject(
this,
child => child.containsScriptInfo(info),
ProjectReferenceProjectLoadKind.Find
) :
this.containsScriptInfo(info);
);
}
) || false;
}
Expand Down
Loading