More second command to Ctx
This commit is contained in:
parent
e53ccb6e99
commit
29e86c0c72
@ -1,8 +1,8 @@
|
||||
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);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { Ctx, Cmd } from '../ctx'
|
||||
|
||||
import { analyzerStatus } from './analyzer_status';
|
||||
import * as applySourceChange from './apply_source_change';
|
||||
import * as expandMacro from './expand_macro';
|
||||
@ -9,6 +11,10 @@ import * as parentModule from './parent_module';
|
||||
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,
|
||||
@ -20,4 +26,5 @@ export {
|
||||
syntaxTree,
|
||||
onEnter,
|
||||
inlayHints,
|
||||
collectGarbage
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ export class Ctx {
|
||||
|
||||
registerCommand(
|
||||
name: string,
|
||||
factory: (ctx: Ctx) => () => Promise<vscode.TextEditor>,
|
||||
factory: (ctx: Ctx) => Cmd,
|
||||
) {
|
||||
const fullName = `rust-analyzer.${name}`
|
||||
const cmd = factory(this);
|
||||
@ -28,3 +28,5 @@ export class Ctx {
|
||||
this.extCtx.subscriptions.push(d)
|
||||
}
|
||||
}
|
||||
|
||||
export type Cmd = (...args: any[]) => any;
|
||||
|
@ -15,11 +15,8 @@ let ctx!: Ctx;
|
||||
|
||||
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);
|
||||
@ -58,9 +55,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
|
||||
// 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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user