mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Refactor vscode extension
This commit is contained in:
parent
e4fdfd1501
commit
69de7e2fd7
14 changed files with 518 additions and 415 deletions
22
editors/code/src/commands/parent_module.ts
Normal file
22
editors/code/src/commands/parent_module.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { TextDocumentIdentifier, Location } from "vscode-languageclient";
|
||||
import { Server } from '../server';
|
||||
|
||||
export async function handle() {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
let request: TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString()
|
||||
}
|
||||
let response = await Server.client.sendRequest<Location[]>("m/parentModule", request)
|
||||
let loc = response[0]
|
||||
if (loc == null) return
|
||||
let uri = Server.client.protocol2CodeConverter.asUri(loc.uri)
|
||||
let range = Server.client.protocol2CodeConverter.asRange(loc.range)
|
||||
|
||||
let doc = await vscode.workspace.openTextDocument(uri)
|
||||
let e = await vscode.window.showTextDocument(doc)
|
||||
e.selection = new vscode.Selection(range.start, range.start)
|
||||
e.revealRange(range, vscode.TextEditorRevealType.InCenter)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue