mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
parent module request
This commit is contained in:
parent
ecc9df5f00
commit
9909875bfe
5 changed files with 52 additions and 2 deletions
|
@ -51,6 +51,22 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
return new vscode.Selection(anchor, active)
|
||||
})
|
||||
})
|
||||
registerCommand('libsyntax-rust.parentModule', async () => {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
let request: lc.TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString()
|
||||
}
|
||||
let response = await client.sendRequest<lc.TextDocumentIdentifier>("m/parentModule", request)
|
||||
let loc: lc.Location = response[0]
|
||||
if (loc == null) return
|
||||
let uri = client.protocol2CodeConverter.asUri(loc.uri)
|
||||
let range = client.protocol2CodeConverter.asRange(loc.range)
|
||||
|
||||
let doc = await vscode.workspace.openTextDocument(uri)
|
||||
let e = await vscode.window.showTextDocument(doc)
|
||||
e.revealRange(range, vscode.TextEditorRevealType.InCenter)
|
||||
})
|
||||
|
||||
dispose(vscode.workspace.registerTextDocumentContentProvider(
|
||||
'libsyntax-rust',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue