mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-28 06:14:22 +00:00
More second command to Ctx
This commit is contained in:
parent
e53ccb6e99
commit
29e86c0c72
4 changed files with 14 additions and 11 deletions
|
@ -1,8 +1,8 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { Ctx } from '../ctx';
|
import { Ctx, Cmd } from '../ctx';
|
||||||
// Shows status of rust-analyzer (for debugging)
|
// Shows status of rust-analyzer (for debugging)
|
||||||
|
|
||||||
export function analyzerStatus(ctx: Ctx) {
|
export function analyzerStatus(ctx: Ctx): Cmd {
|
||||||
let poller: NodeJS.Timer | null = null;
|
let poller: NodeJS.Timer | null = null;
|
||||||
const tdcp = new TextDocumentContentProvider(ctx);
|
const tdcp = new TextDocumentContentProvider(ctx);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Ctx, Cmd } from '../ctx'
|
||||||
|
|
||||||
import { analyzerStatus } from './analyzer_status';
|
import { analyzerStatus } from './analyzer_status';
|
||||||
import * as applySourceChange from './apply_source_change';
|
import * as applySourceChange from './apply_source_change';
|
||||||
import * as expandMacro from './expand_macro';
|
import * as expandMacro from './expand_macro';
|
||||||
|
@ -9,6 +11,10 @@ import * as parentModule from './parent_module';
|
||||||
import * as runnables from './runnables';
|
import * as runnables from './runnables';
|
||||||
import * as syntaxTree from './syntaxTree';
|
import * as syntaxTree from './syntaxTree';
|
||||||
|
|
||||||
|
function collectGarbage(ctx: Ctx): Cmd {
|
||||||
|
return async () => { ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null) }
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
analyzerStatus,
|
analyzerStatus,
|
||||||
applySourceChange,
|
applySourceChange,
|
||||||
|
@ -20,4 +26,5 @@ export {
|
||||||
syntaxTree,
|
syntaxTree,
|
||||||
onEnter,
|
onEnter,
|
||||||
inlayHints,
|
inlayHints,
|
||||||
|
collectGarbage
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@ export class Ctx {
|
||||||
|
|
||||||
registerCommand(
|
registerCommand(
|
||||||
name: string,
|
name: string,
|
||||||
factory: (ctx: Ctx) => () => Promise<vscode.TextEditor>,
|
factory: (ctx: Ctx) => Cmd,
|
||||||
) {
|
) {
|
||||||
const fullName = `rust-analyzer.${name}`
|
const fullName = `rust-analyzer.${name}`
|
||||||
const cmd = factory(this);
|
const cmd = factory(this);
|
||||||
|
@ -28,3 +28,5 @@ export class Ctx {
|
||||||
this.extCtx.subscriptions.push(d)
|
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) {
|
export async function activate(context: vscode.ExtensionContext) {
|
||||||
ctx = new Ctx(context);
|
ctx = new Ctx(context);
|
||||||
ctx.registerCommand(
|
ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
|
||||||
'analyzerStatus',
|
ctx.registerCommand('collectGarbage', commands.collectGarbage);
|
||||||
commands.analyzerStatus
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
function disposeOnDeactivation(disposable: vscode.Disposable) {
|
function disposeOnDeactivation(disposable: vscode.Disposable) {
|
||||||
context.subscriptions.push(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
|
// Commands are requests from vscode to the language server
|
||||||
registerCommand('rust-analyzer.collectGarbage', () =>
|
|
||||||
Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null),
|
|
||||||
);
|
|
||||||
registerCommand(
|
registerCommand(
|
||||||
'rust-analyzer.matchingBrace',
|
'rust-analyzer.matchingBrace',
|
||||||
commands.matchingBrace.handle,
|
commands.matchingBrace.handle,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue