Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as LServer from "vscode-languageserver-types";
import {IEdit, ITextEdit} from "../edit_helper";
export class LSPEdit {
public static mapEdits(edits: IEdit[]): LServer.WorkspaceEdit {
const workspace: LServer.WorkspaceEdit = {changes: {}};
for (const edit of edits) {
for (const filename in edit) {
if (workspace.changes![filename] === undefined) {
workspace.changes![filename] = [];
}
workspace.changes![filename] = workspace.changes![filename].concat(this.mapText(edit[filename]));
}
}
return workspace;
}
public static mapEdit(edit: IEdit): LServer.WorkspaceEdit {
const workspace: LServer.WorkspaceEdit = {changes: {}};
for (const filename in edit) {
workspace.changes![filename] = this.mapText(edit[filename]);
}
return workspace;
}
private static mapText(edit: ITextEdit[]): LServer.TextEdit[] {
const result: LServer.TextEdit[] = [];
for (const e of edit) {
const range = LServer.Range.create(
e.range.start.getRow() - 1,
e.range.start.getCol() - 1,
e.range.end.getRow() - 1,
e.range.end.getCol() - 1);
result.push({range, newText: e.newText});
}
return result;
}
} |