本文整理汇总了TypeScript中vscode-languageserver.TextEdit.replace方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextEdit.replace方法的具体用法?TypeScript TextEdit.replace怎么用?TypeScript TextEdit.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver.TextEdit
的用法示例。
在下文中一共展示了TextEdit.replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
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;
});
示例2: 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;
}
示例3: 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;
};
示例4: 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));
}
}
示例5: replaceText
function replaceText(range: LangServer.Range, text?: string) {
return LangServer.TextEdit.replace(range, text || '');
}