mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
internal: Expose snippet capability to diagnostic quickfixes
This commit is contained in:
parent
a8ad08b9b2
commit
4e6d908382
5 changed files with 13 additions and 6 deletions
|
@ -86,7 +86,7 @@ use ide_db::{
|
|||
label::Label,
|
||||
source_change::SourceChange,
|
||||
syntax_helpers::node_ext::parse_tt_as_comma_sep_paths,
|
||||
FxHashMap, FxHashSet, RootDatabase,
|
||||
FxHashMap, FxHashSet, RootDatabase, SnippetCap,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use stdx::never;
|
||||
|
@ -229,6 +229,7 @@ pub struct DiagnosticsConfig {
|
|||
pub expr_fill_default: ExprFillDefaultMode,
|
||||
pub style_lints: bool,
|
||||
// FIXME: We may want to include a whole `AssistConfig` here
|
||||
pub snippet_cap: Option<SnippetCap>,
|
||||
pub insert_use: InsertUseConfig,
|
||||
pub prefer_no_std: bool,
|
||||
pub prefer_prelude: bool,
|
||||
|
@ -248,6 +249,7 @@ impl DiagnosticsConfig {
|
|||
disabled: Default::default(),
|
||||
expr_fill_default: Default::default(),
|
||||
style_lints: true,
|
||||
snippet_cap: SnippetCap::new(true),
|
||||
insert_use: InsertUseConfig {
|
||||
granularity: ImportGranularity::Preserve,
|
||||
enforce_granularity: false,
|
||||
|
|
|
@ -223,7 +223,7 @@ fn code_action_capabilities(client_caps: &ClientCapabilities) -> CodeActionProvi
|
|||
|
||||
fn more_trigger_character(config: &Config) -> Vec<String> {
|
||||
let mut res = vec![".".to_owned(), ">".to_owned(), "{".to_owned(), "(".to_owned()];
|
||||
if config.snippet_cap() {
|
||||
if config.snippet_cap().is_some() {
|
||||
res.push("<".to_owned());
|
||||
}
|
||||
res
|
||||
|
|
|
@ -25,7 +25,7 @@ use ide_db::{
|
|||
salsa::{self, debug::DebugQueryTable, ParallelDatabase},
|
||||
SourceDatabase, SourceDatabaseExt,
|
||||
},
|
||||
LineIndexDatabase,
|
||||
LineIndexDatabase, SnippetCap,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
|
||||
|
@ -982,6 +982,7 @@ impl flags::AnalysisStats {
|
|||
disable_experimental: false,
|
||||
disabled: Default::default(),
|
||||
expr_fill_default: Default::default(),
|
||||
snippet_cap: SnippetCap::new(true),
|
||||
insert_use: ide_db::imports::insert_use::InsertUseConfig {
|
||||
granularity: ide_db::imports::insert_use::ImportGranularity::Crate,
|
||||
enforce_granularity: true,
|
||||
|
|
|
@ -1261,7 +1261,7 @@ impl Config {
|
|||
impl Config {
|
||||
pub fn assist(&self, source_root: Option<SourceRootId>) -> AssistConfig {
|
||||
AssistConfig {
|
||||
snippet_cap: SnippetCap::new(self.experimental("snippetTextEdit")),
|
||||
snippet_cap: self.snippet_cap(),
|
||||
allowed: None,
|
||||
insert_use: self.insert_use_config(source_root),
|
||||
prefer_no_std: self.imports_preferNoStd(source_root).to_owned(),
|
||||
|
@ -1321,6 +1321,7 @@ impl Config {
|
|||
ExprFillDefaultDef::Todo => ExprFillDefaultMode::Todo,
|
||||
ExprFillDefaultDef::Default => ExprFillDefaultMode::Default,
|
||||
},
|
||||
snippet_cap: self.snippet_cap(),
|
||||
insert_use: self.insert_use_config(source_root),
|
||||
prefer_no_std: self.imports_preferNoStd(source_root).to_owned(),
|
||||
prefer_prelude: self.imports_preferPrelude(source_root).to_owned(),
|
||||
|
@ -2007,8 +2008,10 @@ impl Config {
|
|||
*self.references_excludeTests()
|
||||
}
|
||||
|
||||
pub fn snippet_cap(&self) -> bool {
|
||||
self.experimental("snippetTextEdit")
|
||||
pub fn snippet_cap(&self) -> Option<SnippetCap> {
|
||||
// FIXME: Also detect the proposed lsp version at caps.workspace.workspaceEdit.snippetEditSupport
|
||||
// once lsp-types has it.
|
||||
SnippetCap::new(self.experimental("snippetTextEdit"))
|
||||
}
|
||||
|
||||
pub fn call_info(&self) -> CallInfoConfig {
|
||||
|
|
|
@ -289,6 +289,7 @@ fn integrated_diagnostics_benchmark() {
|
|||
disabled: Default::default(),
|
||||
expr_fill_default: Default::default(),
|
||||
style_lints: false,
|
||||
snippet_cap: SnippetCap::new(true),
|
||||
insert_use: InsertUseConfig {
|
||||
granularity: ImportGranularity::Crate,
|
||||
enforce_granularity: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue