Add command for manually running flychecks
This commit is contained in:
@@ -788,8 +788,17 @@ export function openDocs(ctx: CtxInit): Cmd {
|
||||
|
||||
export function cancelFlycheck(ctx: CtxInit): Cmd {
|
||||
return async () => {
|
||||
await ctx.client.sendRequest(ra.cancelFlycheck);
|
||||
};
|
||||
}
|
||||
|
||||
export function runFlycheck(ctx: CtxInit): Cmd {
|
||||
return async () => {
|
||||
const editor = ctx.activeRustEditor;
|
||||
const client = ctx.client;
|
||||
await client.sendRequest(ra.cancelFlycheck);
|
||||
const params = editor ? { uri: editor.document.uri.toString() } : null;
|
||||
|
||||
await client.sendNotification(ra.runFlycheck, { textDocument: params });
|
||||
};
|
||||
}
|
||||
|
||||
@@ -797,12 +806,12 @@ export function resolveCodeAction(ctx: CtxInit): Cmd {
|
||||
return async (params: lc.CodeAction) => {
|
||||
const client = ctx.client;
|
||||
params.command = undefined;
|
||||
const item = await client?.sendRequest(lc.CodeActionResolveRequest.type, params);
|
||||
const item = await client.sendRequest(lc.CodeActionResolveRequest.type, params);
|
||||
if (!item?.edit) {
|
||||
return;
|
||||
}
|
||||
const itemEdit = item.edit;
|
||||
const edit = await client?.protocol2CodeConverter.asWorkspaceEdit(itemEdit);
|
||||
const edit = await client.protocol2CodeConverter.asWorkspaceEdit(itemEdit);
|
||||
// filter out all text edits and recreate the WorkspaceEdit without them so we can apply
|
||||
// snippet edits on our own
|
||||
const lcFileSystemEdit = {
|
||||
|
||||
@@ -81,6 +81,10 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
|
||||
|
||||
export const cancelFlycheck = new lc.RequestType0<void, void>("rust-analyzer/cancelFlycheck");
|
||||
|
||||
export const runFlycheck = new lc.NotificationType<{
|
||||
textDocument: lc.TextDocumentIdentifier | null;
|
||||
}>("rust-analyzer/runFlycheck");
|
||||
|
||||
// Experimental extensions
|
||||
|
||||
export interface SsrParams {
|
||||
|
||||
@@ -150,6 +150,7 @@ function createCommands(): Record<string, CommandFactory> {
|
||||
moveItemUp: { enabled: commands.moveItemUp },
|
||||
moveItemDown: { enabled: commands.moveItemDown },
|
||||
cancelFlycheck: { enabled: commands.cancelFlycheck },
|
||||
runFlycheck: { enabled: commands.runFlycheck },
|
||||
ssr: { enabled: commands.ssr },
|
||||
serverVersion: { enabled: commands.serverVersion },
|
||||
// Internal commands which are invoked by the server.
|
||||
|
||||
Reference in New Issue
Block a user