aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/index.ts17
-rw-r--r--editors/code/src/commands/runnables.ts8
2 files changed, 20 insertions, 5 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index 9f4636e52..4a2e8e4db 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -1,3 +1,6 @@
1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient';
3
1import { Ctx, Cmd } from '../ctx'; 4import { Ctx, Cmd } from '../ctx';
2 5
3import { analyzerStatus } from './analyzer_status'; 6import { analyzerStatus } from './analyzer_status';
@@ -16,6 +19,17 @@ function collectGarbage(ctx: Ctx): Cmd {
16 }; 19 };
17} 20}
18 21
22function showReferences(ctx: Ctx): Cmd {
23 return (uri: string, position: lc.Position, locations: lc.Location[]) => {
24 vscode.commands.executeCommand(
25 'editor.action.showReferences',
26 vscode.Uri.parse(uri),
27 ctx.client.protocol2CodeConverter.asPosition(position),
28 locations.map(ctx.client.protocol2CodeConverter.asLocation),
29 );
30 };
31}
32
19export { 33export {
20 analyzerStatus, 34 analyzerStatus,
21 expandMacro, 35 expandMacro,
@@ -27,5 +41,6 @@ export {
27 inlayHints, 41 inlayHints,
28 collectGarbage, 42 collectGarbage,
29 run, 43 run,
30 runSingle 44 runSingle,
45 showReferences,
31}; 46};
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index c4be21a0c..8cd86c21e 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -8,7 +8,7 @@ export function run(ctx: Ctx): Cmd {
8 8
9 return async () => { 9 return async () => {
10 const editor = ctx.activeRustEditor; 10 const editor = ctx.activeRustEditor;
11 if (!editor) return 11 if (!editor) return;
12 12
13 const textDocument: lc.TextDocumentIdentifier = { 13 const textDocument: lc.TextDocumentIdentifier = {
14 uri: editor.document.uri.toString(), 14 uri: editor.document.uri.toString(),
@@ -43,13 +43,13 @@ export function run(ctx: Ctx): Cmd {
43 prevRunnable = item; 43 prevRunnable = item;
44 const task = createTask(item.runnable); 44 const task = createTask(item.runnable);
45 return await vscode.tasks.executeTask(task); 45 return await vscode.tasks.executeTask(task);
46 } 46 };
47} 47}
48 48
49export function runSingle(ctx: Ctx): Cmd { 49export function runSingle(ctx: Ctx): Cmd {
50 return async (runnable: Runnable) => { 50 return async (runnable: Runnable) => {
51 const editor = ctx.activeRustEditor; 51 const editor = ctx.activeRustEditor;
52 if (!editor) return 52 if (!editor) return;
53 53
54 const task = createTask(runnable); 54 const task = createTask(runnable);
55 task.group = vscode.TaskGroup.Build; 55 task.group = vscode.TaskGroup.Build;
@@ -60,7 +60,7 @@ export function runSingle(ctx: Ctx): Cmd {
60 }; 60 };
61 61
62 return vscode.tasks.executeTask(task); 62 return vscode.tasks.executeTask(task);
63 } 63 };
64} 64}
65 65
66interface RunnablesParams { 66interface RunnablesParams {