From 9909875bfe89d2b901c35c0667bed018338b44e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 22 Aug 2018 10:18:58 +0300 Subject: parent module request --- code/src/extension.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'code/src/extension.ts') diff --git a/code/src/extension.ts b/code/src/extension.ts index 084a9d769..fb6841fa0 100644 --- a/code/src/extension.ts +++ b/code/src/extension.ts @@ -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("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', -- cgit v1.2.3