rust-analyzer/editors/code/src/commands/index.ts

53 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-12-30 19:07:04 +00:00
import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient';
2019-12-30 17:31:08 +00:00
import { Ctx, Cmd } from '../ctx';
import * as sourceChange from '../source_change';
2019-12-30 13:53:43 +00:00
2019-12-30 13:42:59 +00:00
import { analyzerStatus } from './analyzer_status';
2019-12-30 14:20:13 +00:00
import { matchingBrace } from './matching_brace';
2019-12-30 14:50:15 +00:00
import { joinLines } from './join_lines';
2019-12-30 15:43:34 +00:00
import { onEnter } from './on_enter';
2019-12-30 16:03:05 +00:00
import { parentModule } from './parent_module';
2019-12-30 18:05:41 +00:00
import { syntaxTree } from './syntax_tree';
2019-12-30 18:30:30 +00:00
import { expandMacro } from './expand_macro';
2019-12-30 18:58:44 +00:00
import { run, runSingle } from './runnables';
2018-10-08 18:18:55 +00:00
2019-12-30 13:53:43 +00:00
function collectGarbage(ctx: Ctx): Cmd {
2019-12-30 17:31:08 +00:00
return async () => {
ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null);
};
2019-12-30 13:53:43 +00:00
}
2019-12-30 19:07:04 +00:00
function showReferences(ctx: Ctx): Cmd {
return (uri: string, position: lc.Position, locations: lc.Location[]) => {
vscode.commands.executeCommand(
'editor.action.showReferences',
vscode.Uri.parse(uri),
ctx.client.protocol2CodeConverter.asPosition(position),
locations.map(ctx.client.protocol2CodeConverter.asLocation),
);
};
}
function applySourceChange(ctx: Ctx): Cmd {
return async (change: sourceChange.SourceChange) => {
sourceChange.applySourceChange(ctx, change);
}
}
2018-10-08 18:18:55 +00:00
export {
2019-01-22 21:15:03 +00:00
analyzerStatus,
2019-11-17 18:47:50 +00:00
expandMacro,
2018-10-08 18:18:55 +00:00
joinLines,
matchingBrace,
parentModule,
syntaxTree,
2019-07-23 13:38:21 +00:00
onEnter,
2019-12-30 17:31:08 +00:00
collectGarbage,
2019-12-30 18:58:44 +00:00
run,
2019-12-30 19:07:04 +00:00
runSingle,
showReferences,
applySourceChange,
2018-10-08 18:18:55 +00:00
};