Visual studio code VsCode扩展名:重命名符号
为什么要从扩展触发重命名变量Visual studio code VsCode扩展名:重命名符号,visual-studio-code,Visual Studio Code,为什么要从扩展触发重命名变量 我在文件中找到了如何重命名某个单词的方法,但引用变量与以前保持一致。尝试使用vscode.executeDocumentRenameProvider命令: import*作为“vscode”中的vscode vscode.commands.executeCommand('vscode.executeDocumentRenameProvider', vscode.window.activeTextEditor.document.uri, 新vscode.位置(targ
我在文件中找到了如何重命名某个单词的方法,但引用变量与以前保持一致。尝试使用
vscode.executeDocumentRenameProvider
命令:
import*作为“vscode”中的vscode
vscode.commands.executeCommand('vscode.executeDocumentRenameProvider',
vscode.window.activeTextEditor.document.uri,
新vscode.位置(targetLine,targetCharacter),
'newSymbolName')。然后(编辑=>{
如果(!编辑){
返回false;
}
返回vscode.workspace.applyEdit(编辑);
})
这将利用为目标文件注册的
重命名Provider
。如果不存在此类RenameProvider
,则需要实现一个尝试使用vscode.executedDocumentRenameProvider
命令:
import*作为“vscode”中的vscode
vscode.commands.executeCommand('vscode.executeDocumentRenameProvider',
vscode.window.activeTextEditor.document.uri,
新vscode.位置(targetLine,targetCharacter),
'newSymbolName')。然后(编辑=>{
如果(!编辑){
返回false;
}
返回vscode.workspace.applyEdit(编辑);
})
这将利用为目标文件注册的
重命名Provider
。如果不存在此类重命名Provider
,则需要实现一个我在返回vscode.workspace.applyEdit(编辑)时出错代码>用于编辑:类型为“{}”的参数不能分配给类型为“WorkspaceEdit”的参数。类型“{}”中缺少属性“size”。如果使用TypeScript,则需要使用executeCommand(…)
return vscode.workspace.applyEdit(编辑)指定返回类型代码>用于编辑:类型为“{}”的参数不能分配给类型为“WorkspaceEdit”的参数。类型“{}”中缺少属性“size”。如果使用TypeScript,则需要使用executeCommand(…)