Skip to content

Commit

Permalink
feat(commands): add rust-analyzer.cancelFlycheck
Browse files Browse the repository at this point in the history
  • Loading branch information
fannheyward committed Aug 22, 2022
1 parent 47e279d commit 73248ba
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ You can use these commands by `:CocCommand XYZ`.
| rust-analyzer.viewCrateGraph | View Crate Graph |
| rust-analyzer.viewFullCrateGraph | View Crate Graph (Full) |
| rust-analyzer.shuffleCrateGraph | Shuffle Crate Graph |
| rust-analyzer.cancelFlycheck | Cancel running flychecks |

## Highlight Group

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,11 @@
"title": "Move item down",
"category": "Rust Analyzer"
},
{
"command": "rust-analyzer.cancelFlycheck",
"title": "Cancel running flychecks",
"category": "rust-analyzer"
},
{
"command": "rust-analyzer.explainError",
"title": "Explain the currently hovered diagnostic",
Expand Down
8 changes: 7 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export function testCurrent(ctx: Ctx): Cmd {
return;
}

const testRunnable = runnables.find(run => run.label.startsWith('cargo test'));
const testRunnable = runnables.find((run) => run.label.startsWith('cargo test'));
if (!testRunnable) return;

await runSingle(ctx)(testRunnable);
Expand Down Expand Up @@ -537,6 +537,12 @@ export function applySnippetWorkspaceEditCommand(): Cmd {
};
}

export function cancelFlycheck(ctx: Ctx): Cmd {
return async () => {
await ctx.client.sendRequest(ra.cancelFlycheck);
};
}

export function resolveCodeAction(ctx: Ctx): Cmd {
return async (params: CodeAction) => {
params.command = undefined;
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
ctx.registerCommand('matchingBrace', cmds.matchingBrace);
ctx.registerCommand('openCargoToml', cmds.openCargoToml);
ctx.registerCommand('serverVersion', cmds.serverVersion);
ctx.registerCommand('cancelFlycheck', cmds.cancelFlycheck);
ctx.registerCommand('analyzerStatus', cmds.analyzerStatus);
ctx.registerCommand('viewCrateGraph', cmds.viewCrateGraph);
ctx.registerCommand('shuffleCrateGraph', cmds.shuffleCrateGraph);
Expand Down
26 changes: 15 additions & 11 deletions src/lsp_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ export interface ExpandedMacro {
}
export const expandMacro = new lc.RequestType<ExpandMacroParams, ExpandedMacro | null, void>('rust-analyzer/expandMacro');

export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>('rust-analyzer/relatedTests');

export const cancelFlycheck = new lc.RequestType0<void, void>('rust-analyzer/cancelFlycheck');

// Experimental extensions

export interface SsrParams {
query: string;
parseOnly: boolean;
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;
selections: readonly lc.Range[];
}
export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');

export interface MatchingBraceParams {
textDocument: lc.TextDocumentIdentifier;
positions: lc.Position[];
Expand Down Expand Up @@ -100,17 +115,6 @@ export interface TestInfo {
runnable: Runnable;
}

export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>('rust-analyzer/relatedTests');

export interface SsrParams {
query: string;
parseOnly: boolean;
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;
selections: readonly lc.Range[];
}
export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');

export interface CommandLink extends lc.Command {
/**
* A tooltip for the command, when represented in the UI.
Expand Down

0 comments on commit 73248ba

Please sign in to comment.