mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 20:35:09 +00:00
Add a command to clear flycheck diagnostics
This commit is contained in:
parent
d8ddde27f9
commit
cf8d89e46b
7 changed files with 64 additions and 2 deletions
|
@ -144,6 +144,13 @@ impl Notification for RunFlycheck {
|
||||||
const METHOD: &'static str = "rust-analyzer/runFlycheck";
|
const METHOD: &'static str = "rust-analyzer/runFlycheck";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum ClearFlycheck {}
|
||||||
|
|
||||||
|
impl Notification for ClearFlycheck {
|
||||||
|
type Params = ();
|
||||||
|
const METHOD: &'static str = "rust-analyzer/clearFlycheck";
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RunFlycheckParams {
|
pub struct RunFlycheckParams {
|
||||||
|
|
|
@ -861,6 +861,10 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})?
|
})?
|
||||||
|
.on::<lsp_ext::ClearFlycheck>(|this, ()| {
|
||||||
|
this.diagnostics.clear_check_all();
|
||||||
|
Ok(())
|
||||||
|
})?
|
||||||
.on::<lsp_ext::RunFlycheck>(|this, params| {
|
.on::<lsp_ext::RunFlycheck>(|this, params| {
|
||||||
if let Some(text_document) = params.text_document {
|
if let Some(text_document) = params.text_document {
|
||||||
if let Ok(vfs_path) = from_proto::vfs_path(&text_document.uri) {
|
if let Ok(vfs_path) = from_proto::vfs_path(&text_document.uri) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!---
|
<!---
|
||||||
lsp_ext.rs hash: 1cb29d3afa36e743
|
lsp_ext.rs hash: 45bd7985265725c5
|
||||||
|
|
||||||
If you need to change the above hash to make the test pass, please check if you
|
If you need to change the above hash to make the test pass, please check if you
|
||||||
need to adjust this doc as well and ping this issue:
|
need to adjust this doc as well and ping this issue:
|
||||||
|
@ -459,6 +459,45 @@ Note that this functionality is intended primarily to inform the end user about
|
||||||
In particular, it's valid for the client to completely ignore this extension.
|
In particular, it's valid for the client to completely ignore this extension.
|
||||||
Clients are discouraged from but are allowed to use the `health` status to decide if it's worth sending a request to the server.
|
Clients are discouraged from but are allowed to use the `health` status to decide if it's worth sending a request to the server.
|
||||||
|
|
||||||
|
### Controlling Flycheck
|
||||||
|
|
||||||
|
The flycheck/checkOnSave feature can be controlled via notifications sent by the client to the server.
|
||||||
|
|
||||||
|
**Method:** `rust-analyzer/runFlycheck`
|
||||||
|
|
||||||
|
**Notification:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface RunFlycheckParams {
|
||||||
|
/// The text document whose cargo workspace flycheck process should be started.
|
||||||
|
/// If the document is null or does not belong to a cargo workspace all flycheck processes will be started.
|
||||||
|
textDocument: lc.TextDocumentIdentifier | null;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Triggers the flycheck processes.
|
||||||
|
|
||||||
|
|
||||||
|
**Method:** `rust-analyzer/clearFlycheck`
|
||||||
|
|
||||||
|
**Notification:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface ClearFlycheckParams {}
|
||||||
|
```
|
||||||
|
|
||||||
|
Clears the flycheck diagnostics.
|
||||||
|
|
||||||
|
**Method:** `rust-analyzer/cancelFlycheck`
|
||||||
|
|
||||||
|
**Notification:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface CancelFlycheckParams {}
|
||||||
|
```
|
||||||
|
|
||||||
|
Cancels all running flycheck processes.
|
||||||
|
|
||||||
## Syntax Tree
|
## Syntax Tree
|
||||||
|
|
||||||
**Method:** `rust-analyzer/syntaxTree`
|
**Method:** `rust-analyzer/syntaxTree`
|
||||||
|
|
|
@ -251,6 +251,11 @@
|
||||||
"command": "rust-analyzer.runFlycheck",
|
"command": "rust-analyzer.runFlycheck",
|
||||||
"title": "Run flycheck",
|
"title": "Run flycheck",
|
||||||
"category": "rust-analyzer"
|
"category": "rust-analyzer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "rust-analyzer.clearFlycheck",
|
||||||
|
"title": "Clear flycheck diagnostics",
|
||||||
|
"category": "rust-analyzer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
|
|
|
@ -792,6 +792,12 @@ export function cancelFlycheck(ctx: CtxInit): Cmd {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearFlycheck(ctx: CtxInit): Cmd {
|
||||||
|
return async () => {
|
||||||
|
await ctx.client.sendNotification(ra.clearFlycheck);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function runFlycheck(ctx: CtxInit): Cmd {
|
export function runFlycheck(ctx: CtxInit): Cmd {
|
||||||
return async () => {
|
return async () => {
|
||||||
const editor = ctx.activeRustEditor;
|
const editor = ctx.activeRustEditor;
|
||||||
|
|
|
@ -80,7 +80,7 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
|
||||||
);
|
);
|
||||||
|
|
||||||
export const cancelFlycheck = new lc.NotificationType0("rust-analyzer/cancelFlycheck");
|
export const cancelFlycheck = new lc.NotificationType0("rust-analyzer/cancelFlycheck");
|
||||||
|
export const clearFlycheck = new lc.NotificationType0("rust-analyzer/clearFlycheck");
|
||||||
export const runFlycheck = new lc.NotificationType<{
|
export const runFlycheck = new lc.NotificationType<{
|
||||||
textDocument: lc.TextDocumentIdentifier | null;
|
textDocument: lc.TextDocumentIdentifier | null;
|
||||||
}>("rust-analyzer/runFlycheck");
|
}>("rust-analyzer/runFlycheck");
|
||||||
|
|
|
@ -150,6 +150,7 @@ function createCommands(): Record<string, CommandFactory> {
|
||||||
moveItemUp: { enabled: commands.moveItemUp },
|
moveItemUp: { enabled: commands.moveItemUp },
|
||||||
moveItemDown: { enabled: commands.moveItemDown },
|
moveItemDown: { enabled: commands.moveItemDown },
|
||||||
cancelFlycheck: { enabled: commands.cancelFlycheck },
|
cancelFlycheck: { enabled: commands.cancelFlycheck },
|
||||||
|
clearFlycheck: { enabled: commands.clearFlycheck },
|
||||||
runFlycheck: { enabled: commands.runFlycheck },
|
runFlycheck: { enabled: commands.runFlycheck },
|
||||||
ssr: { enabled: commands.ssr },
|
ssr: { enabled: commands.ssr },
|
||||||
serverVersion: { enabled: commands.serverVersion },
|
serverVersion: { enabled: commands.serverVersion },
|
||||||
|
|
Loading…
Reference in a new issue