import * as vscode from 'vscode';
-import { Ctx } from '../ctx';
+import { Ctx, Cmd } from '../ctx';
// Shows status of rust-analyzer (for debugging)
-export function analyzerStatus(ctx: Ctx) {
+export function analyzerStatus(ctx: Ctx): Cmd {
let poller: NodeJS.Timer | null = null;
const tdcp = new TextDocumentContentProvider(ctx);
+import { Ctx, Cmd } from '../ctx'
+
import { analyzerStatus } from './analyzer_status';
import * as applySourceChange from './apply_source_change';
import * as expandMacro from './expand_macro';
import * as runnables from './runnables';
import * as syntaxTree from './syntaxTree';
+function collectGarbage(ctx: Ctx): Cmd {
+ return async () => { ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null) }
+}
+
export {
analyzerStatus,
applySourceChange,
syntaxTree,
onEnter,
inlayHints,
+ collectGarbage
};
registerCommand(
name: string,
- factory: (ctx: Ctx) => () => Promise<vscode.TextEditor>,
+ factory: (ctx: Ctx) => Cmd,
) {
const fullName = `rust-analyzer.${name}`
const cmd = factory(this);
this.extCtx.subscriptions.push(d)
}
}
+
+export type Cmd = (...args: any[]) => any;
export async function activate(context: vscode.ExtensionContext) {
ctx = new Ctx(context);
- ctx.registerCommand(
- 'analyzerStatus',
- commands.analyzerStatus
- );
-
+ ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
+ ctx.registerCommand('collectGarbage', commands.collectGarbage);
function disposeOnDeactivation(disposable: vscode.Disposable) {
context.subscriptions.push(disposable);
}
// Commands are requests from vscode to the language server
- registerCommand('rust-analyzer.collectGarbage', () =>
- Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null),
- );
registerCommand(
'rust-analyzer.matchingBrace',
commands.matchingBrace.handle,