mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-18 03:43:28 -06:00
switch to use explicit list of open files
This commit is contained in:
parent
e817faabfe
commit
b9729a79fc
@ -1484,18 +1484,18 @@ namespace ts.server {
|
||||
return files;
|
||||
}
|
||||
|
||||
applyChangesInOpenFiles(openFiles: protocol.OpenFile[], closedFiles: string[]): void {
|
||||
applyChangesInOpenFiles(openFiles: protocol.NewOpenFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void {
|
||||
for (const file of openFiles) {
|
||||
const scriptInfo = this.getScriptInfo(file.fileName);
|
||||
if (!scriptInfo || !scriptInfo.isOpen) {
|
||||
Debug.assert(!!file.content);
|
||||
this.openClientFile(file.fileName, file.content);
|
||||
}
|
||||
else {
|
||||
Debug.assert(!!file.textChanges);
|
||||
for (const change of file.textChanges) {
|
||||
scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText);
|
||||
}
|
||||
Debug.assert(!scriptInfo || !scriptInfo.isOpen);
|
||||
this.openClientFile(file.fileName, file.content);
|
||||
}
|
||||
|
||||
for (const file of changedFiles) {
|
||||
const scriptInfo = this.getScriptInfo(file.fileName);
|
||||
Debug.assert(!!scriptInfo);
|
||||
for (const change of file.changes) {
|
||||
scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
src/server/protocol.d.ts
vendored
13
src/server/protocol.d.ts
vendored
@ -451,10 +451,14 @@ declare namespace ts.server.protocol {
|
||||
* Represents a set of changes for open document with a given file name.
|
||||
* Either content of textChanges should be present.
|
||||
*/
|
||||
export interface OpenFile {
|
||||
export interface NewOpenFile {
|
||||
fileName: string;
|
||||
content?: string;
|
||||
textChanges?: ts.TextChange[];
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface ChangedOpenFile {
|
||||
fileName: string;
|
||||
changes: ts.TextChange[];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -611,7 +615,8 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
export interface ApplyChangedToOpenFilesRequestArgs {
|
||||
openFiles: OpenFile[];
|
||||
openFiles: NewOpenFile[];
|
||||
changedFiles: ChangedOpenFile[];
|
||||
closedFiles: string[];
|
||||
}
|
||||
|
||||
|
||||
@ -1063,7 +1063,7 @@ namespace ts.server {
|
||||
return this.requiredResponse(result);
|
||||
},
|
||||
[CommandNames.ApplyChangedToOpenFiles]: (request: protocol.ApplyChangedToOpenFilesRequest) => {
|
||||
this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.closedFiles);
|
||||
this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles);
|
||||
// TODO: report errors
|
||||
return this.requiredResponse(true);
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user