- invalidate typings fix

- update gc timer
This commit is contained in:
Jason Ramsay 2016-08-30 15:51:43 -07:00
parent ba50c6eb25
commit d15381682b
4 changed files with 11 additions and 23 deletions

View file

@ -283,7 +283,7 @@ namespace ts.server {
return true;
}
let hasChanges = this.updateGraphWorker();
const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this);
const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges);
if (this.setTypings(cachedTypings)) {
hasChanges = this.updateGraphWorker() || hasChanges;
}
@ -312,7 +312,6 @@ namespace ts.server {
// - newProgram is different from the old program and structure of the old program was not reused.
if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) {
hasChanges = true;
//this.projectService.typingsCache.invalidateCachedTypingsForProject(this);
if (oldProgram) {
for (const f of oldProgram.getSourceFiles()) {
if (this.program.getSourceFileByPath(f.path)) {
@ -405,27 +404,16 @@ namespace ts.server {
const added: string[] = [];
const removed: string[] = [];
let invalidateTypings = false;
for (const id in currentFiles) {
if (hasProperty(currentFiles, id) && !hasProperty(lastReportedFileNames, id)) {
if (!hasProperty(lastReportedFileNames, id)) {
added.push(id);
if (this.typingFiles.indexOf(id) < 0) {
invalidateTypings = true;
break;
}
}
}
for (const id in lastReportedFileNames) {
if (hasProperty(lastReportedFileNames, id) && !hasProperty(currentFiles, id)) {
if (!hasProperty(currentFiles, id)) {
removed.push(id);
invalidateTypings = true;
}
}
if (invalidateTypings) {
this.projectService.typingsCache.invalidateCachedTypingsForProject(this);
}
this.lastReportedFileNames = currentFiles;
this.lastReportedFileNames = currentFiles;
this.lastReportedVersion = this.projectStructureVersion;
return { info, changes: { added, removed }, projectErrors: this.projectErrors };

View file

@ -168,7 +168,7 @@ namespace ts.server {
: undefined;
this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler);
this.gcTimer = new GcTimer(host, /*delay*/ 15000, logger);
this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger);
}
private handleEvent(event: ProjectServiceEvent) {

View file

@ -76,7 +76,7 @@ namespace ts.server {
constructor(private readonly installer: ITypingsInstaller) {
}
getTypingsForProject(project: Project): TypingsArray {
getTypingsForProject(project: Project, forceRefresh: boolean): TypingsArray {
const typingOptions = project.getTypingOptions();
if (!typingOptions || !typingOptions.enableAutoDiscovery) {
@ -84,8 +84,8 @@ namespace ts.server {
}
const entry = this.perProjectCache[project.getProjectName()];
const result: TypingsArray = entry && entry.typings.length > 0 ? entry.typings : toTypingsArray(typingOptions.include);
if (!entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) {
const result: TypingsArray = entry ? entry.typings : <any>emptyArray;
if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) {
// Note: entry is now poisoned since it does not really contain typings for a given combination of compiler options\typings options.
// instead it acts as a placeholder to prevent issuing multiple requests
this.perProjectCache[project.getProjectName()] = {

View file

@ -92,7 +92,7 @@ namespace ts.server.typingsInstaller {
protected runInstall(cachePath: string, typingsToInstall: string[], postInstallAction: (installedTypings: string[]) => void): void {
const id = this.installRunCount;
this.installRunCount++;
let installCount = 0;
let execInstallCmdCount = 0;
const installedTypings: string[] = [];
const expr = /^.*(@types\/\w+)\S*\s*$/gm;
let match: RegExpExecArray;
@ -102,7 +102,7 @@ namespace ts.server.typingsInstaller {
this.log.writeLine(`Running npm install @types ${id}, command '${command}'. cache path '${cachePath}'`);
}
this.exec(command, { cwd: cachePath }, (err, stdout, stderr) => {
installCount++;
execInstallCmdCount++;
if (this.log.isEnabled()) {
this.log.writeLine(`npm install @types ${id} stdout: ${stdout}`);
this.log.writeLine(`npm install @types ${id} stderr: ${stderr}`);
@ -110,7 +110,7 @@ namespace ts.server.typingsInstaller {
while (match = expr.exec(stdout)) {
installedTypings.push(`node_modules/${match[1]}`);
}
if (installCount >= typingsToInstall.length) {
if (execInstallCmdCount >= typingsToInstall.length) {
postInstallAction(installedTypings);
}
});
@ -121,7 +121,7 @@ namespace ts.server.typingsInstaller {
function findArgument(argumentName: string) {
const index = sys.args.indexOf(argumentName);
return index >= 0 && index < sys.args.length - 1
? sys.args[index]
? sys.args[index + 1]
: undefined;
}