when language service is disabled - build program using only open files (#12809)

This commit is contained in:
Vladimir Matveev
2016-12-13 13:21:32 -08:00
committed by GitHub
parent c71e6cc9ef
commit e68161adfa
6 changed files with 132 additions and 108 deletions

View File

@@ -75,17 +75,32 @@ namespace ts.server {
getFilesAffectedBy(scriptInfo: ScriptInfo): string[];
onProjectUpdateGraph(): void;
emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean;
clear(): void;
}
abstract class AbstractBuilder<T extends BuilderFileInfo> implements Builder {
private fileInfos = createFileMap<T>();
/**
* stores set of files from the project.
* NOTE: this field is created on demand and should not be accessed directly.
* Use 'getFileInfos' instead.
*/
private fileInfos_doNotAccessDirectly: FileMap<T>;
constructor(public readonly project: Project, private ctor: { new (scriptInfo: ScriptInfo, project: Project): T }) {
}
private getFileInfos() {
return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = createFileMap<T>());
}
public clear() {
// drop the existing list - it will be re-created as necessary
this.fileInfos_doNotAccessDirectly = undefined;
}
protected getFileInfo(path: Path): T {
return this.fileInfos.get(path);
return this.getFileInfos().get(path);
}
protected getOrCreateFileInfo(path: Path): T {
@@ -99,19 +114,19 @@ namespace ts.server {
}
protected getFileInfoPaths(): Path[] {
return this.fileInfos.getKeys();
return this.getFileInfos().getKeys();
}
protected setFileInfo(path: Path, info: T) {
this.fileInfos.set(path, info);
this.getFileInfos().set(path, info);
}
protected removeFileInfo(path: Path) {
this.fileInfos.remove(path);
this.getFileInfos().remove(path);
}
protected forEachFileInfo(action: (fileInfo: T) => any) {
this.fileInfos.forEachValue((_path, value) => action(value));
this.getFileInfos().forEachValue((_path, value) => action(value));
}
abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[];
@@ -231,6 +246,11 @@ namespace ts.server {
private projectVersionForDependencyGraph: string;
public clear() {
this.projectVersionForDependencyGraph = undefined;
super.clear();
}
private getReferencedFileInfos(fileInfo: ModuleBuilderFileInfo): ModuleBuilderFileInfo[] {
if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) {
return [];