Remove the unused text buffer from ScriptInfo
This commit is contained in:
parent
4768286f72
commit
28938fbc30
2 changed files with 11 additions and 6 deletions
|
@ -38,7 +38,7 @@ namespace ts.server {
|
|||
path: Path;
|
||||
scriptKind: ScriptKind;
|
||||
|
||||
constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) {
|
||||
constructor(private host: ServerHost, public fileName: string, content: string, public isOpen = false) {
|
||||
this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames));
|
||||
this.svc = ScriptVersionCache.fromString(host, content);
|
||||
}
|
||||
|
|
|
@ -108,6 +108,8 @@ namespace ts {
|
|||
let diags = project.compilerService.languageService.getSemanticDiagnostics(imported.name);
|
||||
assert.equal(diags.length, 1);
|
||||
|
||||
let content = rootScriptInfo.getText();
|
||||
|
||||
const originalFileExists = serverHost.fileExists;
|
||||
{
|
||||
// patch fileExists to make sure that disk is not touched
|
||||
|
@ -118,7 +120,8 @@ namespace ts {
|
|||
|
||||
const newContent = `import {x} from "f1"
|
||||
var x: string = 1;`;
|
||||
rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent);
|
||||
rootScriptInfo.editContent(0, content.length, newContent);
|
||||
content = newContent;
|
||||
// trigger synchronization to make sure that import will be fetched from the cache
|
||||
diags = project.compilerService.languageService.getSemanticDiagnostics(imported.name);
|
||||
// ensure file has correct number of errors after edit
|
||||
|
@ -135,7 +138,8 @@ namespace ts {
|
|||
return originalFileExists.call(serverHost, fileName);
|
||||
};
|
||||
const newContent = `import {x} from "f2"`;
|
||||
rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent);
|
||||
rootScriptInfo.editContent(0, content.length, newContent);
|
||||
content = newContent;
|
||||
|
||||
try {
|
||||
// trigger synchronization to make sure that LSHost will try to find 'f2' module on disk
|
||||
|
@ -160,7 +164,8 @@ namespace ts {
|
|||
};
|
||||
|
||||
const newContent = `import {x} from "f1"`;
|
||||
rootScriptInfo.editContent(0, rootScriptInfo.content.length, newContent);
|
||||
rootScriptInfo.editContent(0, content.length, newContent);
|
||||
content = newContent;
|
||||
project.compilerService.languageService.getSemanticDiagnostics(imported.name);
|
||||
assert.isTrue(fileExistsCalled);
|
||||
|
||||
|
@ -205,7 +210,7 @@ namespace ts {
|
|||
};
|
||||
|
||||
const { project, rootScriptInfo } = createProject(root.name, serverHost);
|
||||
|
||||
const content = rootScriptInfo.getText();
|
||||
let diags = project.compilerService.languageService.getSemanticDiagnostics(root.name);
|
||||
assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called");
|
||||
assert.isTrue(diags.length === 1, "one diagnostic expected");
|
||||
|
@ -214,7 +219,7 @@ namespace ts {
|
|||
// assert that import will success once file appear on disk
|
||||
fileMap[imported.name] = imported;
|
||||
fileExistsCalledForBar = false;
|
||||
rootScriptInfo.editContent(0, rootScriptInfo.content.length, `import {y} from "bar"`);
|
||||
rootScriptInfo.editContent(0, content.length, `import {y} from "bar"`);
|
||||
|
||||
diags = project.compilerService.languageService.getSemanticDiagnostics(root.name);
|
||||
assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called");
|
||||
|
|
Loading…
Reference in a new issue