move saveTo to ScriptInfo

This commit is contained in:
Vladimir Matveev 2016-07-11 19:51:14 -07:00
parent ac9717dc3d
commit aea1534704
3 changed files with 8 additions and 15 deletions

View file

@ -267,15 +267,6 @@ namespace ts.server {
}
}
saveTo(filename: NormalizedPath, tmpfilename: NormalizedPath) {
const script = this.projectService.getScriptInfoForNormalizedPath(filename);
if (script) {
Debug.assert(script.isAttached(this));
const snap = script.snap();
this.projectService.host.writeFile(tmpfilename, snap.getText(0, snap.getLength()));
}
}
reloadScript(filename: NormalizedPath): boolean {
const script = this.projectService.getScriptInfoForNormalizedPath(filename);
if (script) {

View file

@ -110,6 +110,11 @@ namespace ts.server {
this.markContainingProjectsAsDirty();
}
saveTo(fileName: string) {
const snap = this.snap();
this.host.writeFile(fileName, snap.getText(0, snap.getLength()));
}
reloadFromFile() {
this.svc.reloadFromFile(this.fileName);
this.markContainingProjectsAsDirty();

View file

@ -1015,12 +1015,9 @@ namespace ts.server {
}
private saveToTmp(fileName: string, tempFileName: string) {
const file = toNormalizedPath(fileName);
const tmpfile = toNormalizedPath(tempFileName);
const project = this.projectService.getDefaultProjectForFile(file);
if (project) {
project.saveTo(file, tmpfile);
const scriptInfo = this.projectService.getScriptInfo(fileName);
if (scriptInfo) {
scriptInfo.saveTo(tempFileName);
}
}