move saveTo to ScriptInfo
This commit is contained in:
parent
ac9717dc3d
commit
aea1534704
|
@ -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 {
|
reloadScript(filename: NormalizedPath): boolean {
|
||||||
const script = this.projectService.getScriptInfoForNormalizedPath(filename);
|
const script = this.projectService.getScriptInfoForNormalizedPath(filename);
|
||||||
if (script) {
|
if (script) {
|
||||||
|
|
|
@ -110,6 +110,11 @@ namespace ts.server {
|
||||||
this.markContainingProjectsAsDirty();
|
this.markContainingProjectsAsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveTo(fileName: string) {
|
||||||
|
const snap = this.snap();
|
||||||
|
this.host.writeFile(fileName, snap.getText(0, snap.getLength()));
|
||||||
|
}
|
||||||
|
|
||||||
reloadFromFile() {
|
reloadFromFile() {
|
||||||
this.svc.reloadFromFile(this.fileName);
|
this.svc.reloadFromFile(this.fileName);
|
||||||
this.markContainingProjectsAsDirty();
|
this.markContainingProjectsAsDirty();
|
||||||
|
|
|
@ -1015,12 +1015,9 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveToTmp(fileName: string, tempFileName: string) {
|
private saveToTmp(fileName: string, tempFileName: string) {
|
||||||
const file = toNormalizedPath(fileName);
|
const scriptInfo = this.projectService.getScriptInfo(fileName);
|
||||||
const tmpfile = toNormalizedPath(tempFileName);
|
if (scriptInfo) {
|
||||||
|
scriptInfo.saveTo(tempFileName);
|
||||||
const project = this.projectService.getDefaultProjectForFile(file);
|
|
||||||
if (project) {
|
|
||||||
project.saveTo(file, tmpfile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue