mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Use updateGraphIfDirty to do quick check if project update is needed
With this updateGraph is used only in locations we are certain project is dirty
This commit is contained in:
@@ -337,7 +337,8 @@ namespace ts.server {
|
||||
return `Project: ${project ? project.getProjectName() : ""} WatchType: ${watchType}`;
|
||||
}
|
||||
|
||||
function updateProjectIfDirty(project: Project) {
|
||||
/*@internal*/
|
||||
export function updateProjectIfDirty(project: Project) {
|
||||
return project.dirty && project.updateGraph();
|
||||
}
|
||||
|
||||
@@ -617,7 +618,7 @@ namespace ts.server {
|
||||
this.pendingProjectUpdates.set(projectName, project);
|
||||
this.throttledOperations.schedule(projectName, /*delay*/ 250, () => {
|
||||
if (this.pendingProjectUpdates.delete(projectName)) {
|
||||
project.updateGraph();
|
||||
updateProjectIfDirty(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2148,7 +2149,7 @@ namespace ts.server {
|
||||
private findExternalProjectContainingOpenScriptInfo(info: ScriptInfo): ExternalProject | undefined {
|
||||
return find(this.externalProjects, proj => {
|
||||
// Ensure project structure is up-to-date to check if info is present in external project
|
||||
proj.updateGraph();
|
||||
updateProjectIfDirty(proj);
|
||||
return proj.containsScriptInfo(info);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ namespace ts.server {
|
||||
private readonly cancellationToken: ThrottledCancellationToken;
|
||||
|
||||
public isNonTsProject() {
|
||||
this.updateGraph();
|
||||
updateProjectIfDirty(this);
|
||||
return allFilesAreJsOrDts(this);
|
||||
}
|
||||
|
||||
public isJsOnlyProject() {
|
||||
this.updateGraph();
|
||||
updateProjectIfDirty(this);
|
||||
return hasOneOrMoreJsAndNoTsFiles(this);
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ namespace ts.server {
|
||||
|
||||
getLanguageService(ensureSynchronized = true): LanguageService {
|
||||
if (ensureSynchronized) {
|
||||
this.updateGraph();
|
||||
updateProjectIfDirty(this);
|
||||
}
|
||||
return this.languageService;
|
||||
}
|
||||
@@ -477,7 +477,7 @@ namespace ts.server {
|
||||
if (!this.languageServiceEnabled) {
|
||||
return [];
|
||||
}
|
||||
this.updateGraph();
|
||||
updateProjectIfDirty(this);
|
||||
this.builderState = BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState);
|
||||
return mapDefined(BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, data => this.projectService.host.createHash!(data)), // TODO: GH#18217
|
||||
sourceFile => this.shouldEmitFile(this.projectService.getScriptInfoForPath(sourceFile.path)!) ? sourceFile.fileName : undefined);
|
||||
@@ -1025,7 +1025,7 @@ namespace ts.server {
|
||||
|
||||
/* @internal */
|
||||
getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics {
|
||||
this.updateGraph();
|
||||
updateProjectIfDirty(this);
|
||||
|
||||
const info: protocol.ProjectVersionInfo = {
|
||||
projectName: this.getProjectName(),
|
||||
|
||||
@@ -695,7 +695,7 @@ namespace ts.server {
|
||||
const { fileName, project } = checkList[index];
|
||||
index++;
|
||||
// Ensure the project is upto date before checking if this file is present in the project
|
||||
project.updateGraph();
|
||||
updateProjectIfDirty(project);
|
||||
if (!project.containsFile(fileName, requireOpen)) {
|
||||
return;
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ namespace ts.server {
|
||||
|
||||
private getProjectInfoWorker(uncheckedFileName: string, projectFileName: string | undefined, needFileNameList: boolean, excludeConfigFiles: boolean) {
|
||||
const { project } = this.getFileAndProjectWorker(uncheckedFileName, projectFileName);
|
||||
project.updateGraph();
|
||||
updateProjectIfDirty(project);
|
||||
const projectInfo = {
|
||||
configFileName: project.getProjectName(),
|
||||
languageServiceDisabled: !project.languageServiceEnabled,
|
||||
|
||||
Reference in New Issue
Block a user