aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/src/commands/analyzer_status.ts4
-rw-r--r--editors/code/src/commands/index.ts7
-rw-r--r--editors/code/src/ctx.ts4
-rw-r--r--editors/code/src/main.ts10
4 files changed, 14 insertions, 11 deletions
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts
index 6e92c50ef..c9d32fe07 100644
--- a/editors/code/src/commands/analyzer_status.ts
+++ b/editors/code/src/commands/analyzer_status.ts
@@ -1,8 +1,8 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import { Ctx } from '../ctx'; 2import { Ctx, Cmd } from '../ctx';
3// Shows status of rust-analyzer (for debugging) 3// Shows status of rust-analyzer (for debugging)
4 4
5export function analyzerStatus(ctx: Ctx) { 5export function analyzerStatus(ctx: Ctx): Cmd {
6 let poller: NodeJS.Timer | null = null; 6 let poller: NodeJS.Timer | null = null;
7 const tdcp = new TextDocumentContentProvider(ctx); 7 const tdcp = new TextDocumentContentProvider(ctx);
8 8
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index ec1995396..ed56f5a4e 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -1,3 +1,5 @@
1import { Ctx, Cmd } from '../ctx'
2
1import { analyzerStatus } from './analyzer_status'; 3import { analyzerStatus } from './analyzer_status';
2import * as applySourceChange from './apply_source_change'; 4import * as applySourceChange from './apply_source_change';
3import * as expandMacro from './expand_macro'; 5import * as expandMacro from './expand_macro';
@@ -9,6 +11,10 @@ import * as parentModule from './parent_module';
9import * as runnables from './runnables'; 11import * as runnables from './runnables';
10import * as syntaxTree from './syntaxTree'; 12import * as syntaxTree from './syntaxTree';
11 13
14function collectGarbage(ctx: Ctx): Cmd {
15 return async () => { ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null) }
16}
17
12export { 18export {
13 analyzerStatus, 19 analyzerStatus,
14 applySourceChange, 20 applySourceChange,
@@ -20,4 +26,5 @@ export {
20 syntaxTree, 26 syntaxTree,
21 onEnter, 27 onEnter,
22 inlayHints, 28 inlayHints,
29 collectGarbage
23}; 30};
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 8581667b4..9dd2b7d4f 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -16,7 +16,7 @@ export class Ctx {
16 16
17 registerCommand( 17 registerCommand(
18 name: string, 18 name: string,
19 factory: (ctx: Ctx) => () => Promise<vscode.TextEditor>, 19 factory: (ctx: Ctx) => Cmd,
20 ) { 20 ) {
21 const fullName = `rust-analyzer.${name}` 21 const fullName = `rust-analyzer.${name}`
22 const cmd = factory(this); 22 const cmd = factory(this);
@@ -28,3 +28,5 @@ export class Ctx {
28 this.extCtx.subscriptions.push(d) 28 this.extCtx.subscriptions.push(d)
29 } 29 }
30} 30}
31
32export type Cmd = (...args: any[]) => any;
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 048b9bbd4..9500219ca 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -15,11 +15,8 @@ let ctx!: Ctx;
15 15
16export async function activate(context: vscode.ExtensionContext) { 16export async function activate(context: vscode.ExtensionContext) {
17 ctx = new Ctx(context); 17 ctx = new Ctx(context);
18 ctx.registerCommand( 18 ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
19 'analyzerStatus', 19 ctx.registerCommand('collectGarbage', commands.collectGarbage);
20 commands.analyzerStatus
21 );
22
23 20
24 function disposeOnDeactivation(disposable: vscode.Disposable) { 21 function disposeOnDeactivation(disposable: vscode.Disposable) {
25 context.subscriptions.push(disposable); 22 context.subscriptions.push(disposable);
@@ -58,9 +55,6 @@ export async function activate(context: vscode.ExtensionContext) {
58 } 55 }
59 56
60 // Commands are requests from vscode to the language server 57 // Commands are requests from vscode to the language server
61 registerCommand('rust-analyzer.collectGarbage', () =>
62 Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null),
63 );
64 registerCommand( 58 registerCommand(
65 'rust-analyzer.matchingBrace', 59 'rust-analyzer.matchingBrace',
66 commands.matchingBrace.handle, 60 commands.matchingBrace.handle,