Rename Watch.synchronizeProgram to getProgram and return the updated program as part of this api

This commit is contained in:
Sheetal Nandi
2017-12-04 14:40:30 -08:00
parent 3dda2179e8
commit 61fc9b94de
2 changed files with 11 additions and 9 deletions

View File

@@ -212,8 +212,8 @@ namespace ts {
}
export interface Watch {
/** Synchronize the program with the changes */
synchronizeProgram(): void;
/** Synchronize with host and get updated program */
getProgram(): Program;
/** Gets the existing program without synchronizing with changes on host */
/*@internal*/
getExistingProgram(): Program;
@@ -360,10 +360,10 @@ namespace ts {
watchConfigFileWildCardDirectories();
return configFileName ?
{ getExistingProgram: () => program, synchronizeProgram } :
{ getExistingProgram: () => program, synchronizeProgram, updateRootFileNames };
{ getExistingProgram: () => program, getProgram: synchronizeProgram } :
{ getExistingProgram: () => program, getProgram: synchronizeProgram, updateRootFileNames };
function synchronizeProgram() {
function synchronizeProgram(): Program {
writeLog(`Synchronizing program`);
if (hasChangedCompilerOptions) {
@@ -375,7 +375,7 @@ namespace ts {
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution();
if (isProgramUptoDate(program, rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames)) {
return;
return program;
}
beforeProgramCreate(compilerOptions);
@@ -411,6 +411,7 @@ namespace ts {
afterProgramCreate(directoryStructureHost, program);
reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
return program;
}
function updateRootFileNames(files: string[]) {
@@ -569,7 +570,8 @@ namespace ts {
case ConfigFileProgramReloadLevel.Full:
return reloadConfigFile();
default:
return synchronizeProgram();
synchronizeProgram();
return;
}
}

View File

@@ -3850,8 +3850,8 @@ declare namespace ts {
onConfigFileDiagnostic(diagnostic: Diagnostic): void;
}
interface Watch {
/** Synchronize the program with the changes */
synchronizeProgram(): void;
/** Synchronize with host and get updated program */
getProgram(): Program;
}
/**
* Creates the watch what generates program using the config file