mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Support loading of child project if found project is not pure solution has some of its own files and project references (#39613)
* Use disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions Fixes #39144 * Handle indirect references * Support loading of child project if found project is not pure solution has some of its own files and project references Fixes #38605 * Fix grammar
This commit is contained in:
1 parent
e92afacc44
commit
34adaaf6aa
3 files changed
+239
-26
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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 => {
|
||||
@@ -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 : ""}`
|
||||
@@ -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 => {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) ?
|
||||
@@ -2257,8 +2256,6 @@ 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
|
||||
@@ -2266,13 +2263,12 @@ namespace ts.server {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user