Mark machine applicable fixes as preferred

This allows us to run the auto fix command from vscode to automatically
fix all diagnostics in the file.

They are also distinguished in the UI.
This commit is contained in:
Jeremy Kolb 2020-07-11 19:12:42 -04:00
parent 9210fcc076
commit d7cd88b1a2
9 changed files with 20 additions and 0 deletions

View file

@ -118,6 +118,7 @@ fn map_rust_child_diagnostic(
changes: Some(edit_map), changes: Some(edit_map),
document_changes: None, document_changes: None,
}), }),
is_preferred: Some(true),
}) })
} }
} }

View file

@ -775,6 +775,7 @@ fn handle_fixes(
group: None, group: None,
kind: Some(CodeActionKind::QUICKFIX), kind: Some(CodeActionKind::QUICKFIX),
edit: Some(edit), edit: Some(edit),
is_preferred: Some(false),
}; };
res.push(action); res.push(action);
} }

View file

@ -243,6 +243,7 @@ impl Request for CodeActionRequest {
} }
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeAction { pub struct CodeAction {
pub title: String, pub title: String,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -256,6 +257,8 @@ pub struct CodeAction {
// pub command: Option<lsp_types::Command>, // pub command: Option<lsp_types::Command>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub edit: Option<SnippetWorkspaceEdit>, pub edit: Option<SnippetWorkspaceEdit>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_preferred: Option<bool>,
} }
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]

View file

@ -652,6 +652,7 @@ pub(crate) fn unresolved_code_action(
group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0),
kind: Some(code_action_kind(assist.id.1)), kind: Some(code_action_kind(assist.id.1)),
edit: None, edit: None,
is_preferred: None,
}; };
Ok(res) Ok(res)
} }

View file

@ -65,6 +65,9 @@
document_changes: None, document_changes: None,
}, },
), ),
is_preferred: Some(
true,
),
}, },
], ],
}, },

View file

@ -65,6 +65,9 @@
document_changes: None, document_changes: None,
}, },
), ),
is_preferred: Some(
true,
),
}, },
], ],
}, },

View file

@ -65,6 +65,9 @@
document_changes: None, document_changes: None,
}, },
), ),
is_preferred: Some(
true,
),
}, },
], ],
}, },

View file

@ -93,6 +93,9 @@
document_changes: None, document_changes: None,
}, },
), ),
is_preferred: Some(
true,
),
}, },
], ],
}, },

View file

@ -284,6 +284,7 @@ fn main() {}
} }
] ]
}, },
"isPreferred": false,
"kind": "quickfix", "kind": "quickfix",
"title": "Create module" "title": "Create module"
}]), }]),
@ -355,6 +356,7 @@ fn main() {{}}
} }
] ]
}, },
"isPreferred": false,
"kind": "quickfix", "kind": "quickfix",
"title": "Create module" "title": "Create module"
}]), }]),