本文整理汇总了TypeScript中vscode-languageserver.TextEdit类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextEdit类的具体用法?TypeScript TextEdit怎么用?TypeScript TextEdit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextEdit类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createTextEdit
const edits: TextEdit[] = nodes.reduce<TextEdit[]>((acc, curr) => {
const edit = createTextEdit(curr, newName);
if (edit) {
acc.push(edit);
}
return acc;
}, []);
示例2:
return Object.keys(response.statements!).map((k: any) => {
const eqClass = response.statements![k];
const title = eqClass.title;
const item = CompletionItem.create(`[${title}]`);
item.textEdit = TextEdit.replace(range, `[${title}]`);
item.kind = CompletionItemKind.Variable;
item.detail = IEquivalenceClass.getCanonicalMemberText(eqClass);
return item;
});
示例3: editsToWorkspaceEdit
editsToWorkspaceEdit(edits: Iterable<Edit>): WorkspaceEdit {
const edit: WorkspaceEdit = {changes: {}};
const changes = edit.changes!;
for (const polymerEdit of edits) {
for (const replacement of polymerEdit) {
const uri = replacement.range.file;
if (!changes[uri]) {
changes[uri] = [];
}
changes[uri]!.push(TextEdit.replace(
this.convertPRangeToL(replacement.range),
replacement.replacementText));
}
}
return edit;
}
示例4: switch
const createTextEdit = (node: IAstNode, newName: string): TextEdit | null => {
if (isTokenNode(node) && node.tokenType) {
switch (node.tokenType.tokenName) {
case "ArgumentReference":
return TextEdit.replace(createRange(node), `<${newName}>`);
case "ArgumentDefinition":
return TextEdit.replace(createRange(node), `<${newName}>:`);
case "ArgumentMention":
return TextEdit.replace(createRange(node), `@<${newName}>`);
case "StatementReference":
return TextEdit.replace(createRange(node), `[${newName}]`);
case "StatementDefinition":
return TextEdit.replace(createRange(node), `[${newName}]:`);
case "StatementMention":
return TextEdit.replace(createRange(node), `@[${newName}]`);
case "Tag":
return TextEdit.replace(createRange(node), `#(${newName})`); // we use the bracketed tag syntax, so we don't have to check the format of newName
}
}
return null;
};
示例5: addEdit
function addEdit(text: string, startOffset: number, endOffset: number) {
if (documentText.substring(startOffset, endOffset) !== text) {
let replaceRange = Range.create(document.positionAt(startOffset), document.positionAt(endOffset));
editOperations.push(TextEdit.replace(replaceRange, text));
}
}
示例6: replaceText
function replaceText(range: LangServer.Range, text?: string) {
return LangServer.TextEdit.replace(range, text || '');
}