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/package.json | 5 +++++ code/src/extension.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'code') diff --git a/code/package.json b/code/package.json index fd3b8e423..042821b1c 100644 --- a/code/package.json +++ b/code/package.json @@ -41,6 +41,11 @@ "command": "libsyntax-rust.matchingBrace", "key": "ctrl+shift+m", "title": "Rust Matching Brace" + }, + { + "command": "libsyntax-rust.parentModule", + "key": "ctrl+u", + "title": "Rust Parent Module" } ], "keybindings": [ 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