added cleanup message

This commit is contained in:
Vladimir Matveev
2016-06-17 16:22:03 -07:00
parent 6ebc8abea2
commit f34ba2df0b
4 changed files with 35 additions and 1 deletions

View File

@@ -142,6 +142,7 @@ namespace ts.server {
export const SynchronizeProjectList = "synchronizeProjectList";
export const ApplyChangedToOpenFiles = "applyChangedToOpenFiles";
export const EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
export const Cleanup = "cleanup";
}
namespace Errors {
@@ -331,6 +332,28 @@ namespace ts.server {
}
}
private cleanProjects(caption: string, projects: Project[]) {
if (!projects) {
return;
}
this.projectService.log(`cleaning ${caption}`);
for (const p of projects) {
p.languageService.cleanupSemanticCache();
}
}
private cleanup() {
this.cleanProjects("inferred projects", this.projectService.inferredProjects);
this.cleanProjects("configured projects", this.projectService.configuredProjects);
this.cleanProjects("external projects", this.projectService.externalProjects);
if (typeof global !== "undefined" && global.gc) {
this.projectService.log(`global.gc()`);
global.gc();
global.gc();
global.gc();
}
}
private getEncodedSemanticClassifications(args: protocol.FileSpanRequestArgs) {
const file = normalizePath(args.file);
const project = this.projectService.getProjectForFile(file);
@@ -1248,6 +1271,10 @@ namespace ts.server {
[CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.FileSpanRequest) => {
return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments));
},
[CommandNames.Cleanup]: (request: protocol.Request) => {
this.cleanup();
return this.requiredResponse(true);
},
[CommandNames.Geterr]: (request: protocol.Request) => {
const geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
return { response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false };