本文整理匯總了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 || '');
}