add command for rebuild all project structure

This commit is contained in:
zhengbli 2015-08-20 14:34:46 -07:00
parent 762e0e8146
commit a4d496c4c6
2 changed files with 29 additions and 5 deletions

View file

@ -621,7 +621,10 @@ namespace ts.server {
let fileNames = project.getFileNames();
for (let fileName of fileNames) {
this.getScriptInfo(fileName).defaultProject = undefined;
let info = this.getScriptInfo(fileName);
if (info.defaultProject == project){
info.defaultProject = undefined;
}
}
}
@ -766,6 +769,19 @@ namespace ts.server {
return referencingProjects;
}
rebuildProjectStructure() {
// First check if there is new tsconfig file added for inferred project roots
for (let info of this.openFileRoots) {
this.openOrUpdateConfiguredProjectForFile(info.fileName);
}
this.updateProjectStructure();
}
/**
* This function is to update the project structure for every projects.
* It is called on the premise that all the configured projects are
* up to date.
*/
updateProjectStructure() {
this.log("updating project structure from ...", "Info");
this.printProjects();
@ -912,10 +928,6 @@ namespace ts.server {
let configFileName = this.findConfigFile(searchPath);
if (configFileName) {
this.log("Config file name: " + configFileName, "Info");
} else {
this.log("no config file");
}
if (configFileName) {
let project = this.findConfiguredProjectByConfigFile(configFileName);
if (!project) {
var configResult = this.openConfigFile(configFileName, fileName);
@ -931,6 +943,9 @@ namespace ts.server {
this.updateConfiguredProject(project);
}
}
else {
this.log("No config files found.");
}
}
/**

View file

@ -100,6 +100,7 @@ namespace ts.server {
export const SignatureHelp = "signatureHelp";
export const TypeDefinition = "typeDefinition";
export const ProjectInfo = "projectInfo";
export const RebuildProjects = "rebuildProjects";
export const Unknown = "unknown";
}
@ -226,6 +227,10 @@ namespace ts.server {
this.syntacticCheck(file, project);
this.semanticCheck(file, project);
}
private rebuildProjectStructure() {
this.projectService.rebuildProjectStructure();
}
private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) {
setTimeout(() => {
@ -1033,6 +1038,10 @@ namespace ts.server {
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true};
},
[CommandNames.RebuildProjects]: (request: protocol.Request) => {
this.rebuildProjectStructure();
return {responseRequired: false};
}
};
public addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) {
if (this.handlers[command]) {