Skip to content

Commit

Permalink
Make initialLoadPending as property instead of method
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Sep 12, 2024
1 parent 0bc84cd commit 8ad73bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ function forEachAncestorProject<T>(
while (true) {
// Skip if project is not composite and we are only looking for solution
if (
!project.isInitialLoadPending() &&
!project.initialLoadPending &&
(
!project.getCompilerOptions().composite ||
project.getCompilerOptions().disableSolutionSearching
Expand Down Expand Up @@ -746,7 +746,7 @@ function forEachAncestorProject<T>(

// If this ancestor is new and was delay loaded, then set the project as potential project reference
if (
ancestor.project.isInitialLoadPending() &&
ancestor.project.initialLoadPending &&
project.getCompilerOptions().composite
) {
// Set a potential project reference
Expand Down Expand Up @@ -909,7 +909,7 @@ function forEachAnyProjectReferenceKind<T>(
): T | undefined {
return project.getCurrentProgram() ?
project.forEachResolvedProjectReference(cb) :
project.isInitialLoadPending() ?
project.initialLoadPending ?
forEachPotentialProjectReference(project, cbPotentialProjectRef) :
forEach(project.getProjectReferences(), cbProjectRef);
}
Expand Down Expand Up @@ -1978,7 +1978,7 @@ export class ProjectService {
scheduledAnyProjectUpdate = true;
if (projectCanonicalPath === canonicalConfigFilePath) {
// Skip refresh if project is not yet loaded
if (project.isInitialLoadPending()) return;
if (project.initialLoadPending) return;
project.pendingUpdateLevel = ProgramUpdateLevel.Full;
project.pendingUpdateReason = loadReason;
this.delayUpdateProjectGraph(project);
Expand Down Expand Up @@ -2056,7 +2056,7 @@ export class ProjectService {

// If this was not already updated, and its new project, schedule for update
// Existing projects dont need to update if they were not using the changed config in any way
if (tryAddToSet(updatedProjects, projectForInfo) && projectForInfo.isInitialLoadPending()) {
if (tryAddToSet(updatedProjects, projectForInfo) && projectForInfo.initialLoadPending) {
this.delayUpdateProjectGraph(projectForInfo);
}
});
Expand Down Expand Up @@ -3063,7 +3063,7 @@ export class ProjectService {
* @internal
*/
reloadConfiguredProject(project: ConfiguredProject, reason: string) {
project.isInitialLoadPending = returnFalse;
project.initialLoadPending = false;
project.pendingUpdateReason = undefined;
project.pendingUpdateLevel = ProgramUpdateLevel.Update;

Expand Down Expand Up @@ -3895,7 +3895,7 @@ export class ProjectService {
const reason = `Reloading configured project in external project: ${externalProjectName}`;
projects.forEach(project => {
if (this.getHostPreferences().lazyConfiguredProjectsFromExternalProject) {
if (!project.isInitialLoadPending()) {
if (!project.initialLoadPending) {
this.clearSemanticCache(project);
project.pendingUpdateLevel = ProgramUpdateLevel.Full;
project.pendingUpdateReason = reloadReason(reason);
Expand Down Expand Up @@ -4358,7 +4358,7 @@ export class ProjectService {
/** @internal */
loadAncestorProjectTree(forProjects?: ReadonlyCollection<string>) {
forProjects ??= new Set(
mapDefinedIterator(this.configuredProjects.entries(), ([key, project]) => !project.isInitialLoadPending() ? key : undefined),
mapDefinedIterator(this.configuredProjects.entries(), ([key, project]) => !project.initialLoadPending ? key : undefined),
);

const seenProjects = new Set<NormalizedPath>();
Expand Down
14 changes: 7 additions & 7 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ import {
ResolvedTypeReferenceDirectiveWithFailedLookupLocations,
resolvePackageNameToPackageJson,
returnFalse,
returnTrue,
ScriptKind,
some,
sortAndDeduplicate,
Expand Down Expand Up @@ -435,7 +434,8 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo

protected projectErrors: Diagnostic[] | undefined;

protected isInitialLoadPending: () => boolean = returnFalse;
/** @internal */
initialLoadPending = false;

/** @internal */
dirty = false;
Expand Down Expand Up @@ -1911,7 +1911,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
}

private filesToStringWorker(writeProjectFileNames: boolean, writeFileExplaination: boolean, writeFileVersionAndText: boolean) {
if (this.isInitialLoadPending()) return "\tFiles (0) InitialLoadPending\n";
if (this.initialLoadPending) return "\tFiles (0) InitialLoadPending\n";
if (!this.program) return "\tFiles (0) NoProgram\n";
const sourceFiles = this.program.getSourceFiles();
let strBuilder = `\tFiles (${sourceFiles.length})\n`;
Expand Down Expand Up @@ -1991,7 +1991,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
: (files: Map<string, boolean>) => arrayFrom(files.keys());

// Update the graph only if initial configured project load is not pending
if (!this.isInitialLoadPending()) {
if (!this.initialLoadPending) {
updateProjectIfDirty(this);
}

Expand Down Expand Up @@ -2882,7 +2882,7 @@ export class ConfiguredProject extends Project {
projectOptions?: ProjectOptions | true;

/** @internal */
override isInitialLoadPending: () => boolean = returnTrue;
override initialLoadPending = true;

/** @internal */
sendLoadingProjectFinish = false;
Expand Down Expand Up @@ -2972,7 +2972,7 @@ export class ConfiguredProject extends Project {
override updateGraph(): boolean {
if (this.deferredClose) return false;
const isDirty = this.dirty;
this.isInitialLoadPending = returnFalse;
this.initialLoadPending = false;
const updateLevel = this.pendingUpdateLevel;
this.pendingUpdateLevel = ProgramUpdateLevel.Update;
let result: boolean;
Expand Down Expand Up @@ -3032,7 +3032,7 @@ export class ConfiguredProject extends Project {

/** @internal */
setPotentialProjectReference(canonicalConfigPath: NormalizedPath) {
Debug.assert(this.isInitialLoadPending());
Debug.assert(this.initialLoadPending);
(this.potentialProjectReferences || (this.potentialProjectReferences = new Set())).add(canonicalConfigPath);
}

Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,6 @@ declare namespace ts {
private lastReportedFileNames;
private lastReportedVersion;
protected projectErrors: Diagnostic[] | undefined;
protected isInitialLoadPending: () => boolean;
private typingsCache;
private typingWatchers;
private readonly cancellationToken;
Expand Down

0 comments on commit 8ad73bd

Please sign in to comment.