Skip to content

Remove the unused text buffer(content) from ScriptInfo #9537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
15 changes: 10 additions & 5 deletions tests/cases/unittests/cachingInServerLSHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down