mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Remove redundant code
This commit is contained in:
parent
50e06ee95a
commit
68a747efe0
8 changed files with 79 additions and 102 deletions
|
@ -15,12 +15,12 @@ pub struct CompletionConfig {
|
|||
pub add_call_argument_snippets: bool,
|
||||
pub snippet_cap: Option<SnippetCap>,
|
||||
pub merge: Option<MergeBehaviour>,
|
||||
/// A set of capabilities, enabled on the cliend and supported on the server.
|
||||
pub resolve_capabilities: FxHashSet<CompletionResolveCapability>,
|
||||
/// A set of capabilities, enabled on the client and supported on the server.
|
||||
pub active_resolve_capabilities: FxHashSet<CompletionResolveCapability>,
|
||||
}
|
||||
|
||||
/// A resolve capability, supported on a server.
|
||||
/// If the client registers any of those in its completion resolve capabilities,
|
||||
/// A resolve capability, supported on the server.
|
||||
/// If the client registers any completion resolve capabilities,
|
||||
/// the server is able to render completion items' corresponding fields later,
|
||||
/// not during an initial completion item request.
|
||||
/// See https://github.com/rust-analyzer/rust-analyzer/issues/6366 for more details.
|
||||
|
@ -37,8 +37,11 @@ impl CompletionConfig {
|
|||
}
|
||||
|
||||
/// Whether the completions' additional edits are calculated later, during a resolve request or not.
|
||||
pub fn should_resolve_additional_edits_immediately(&self) -> bool {
|
||||
!self.resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits)
|
||||
/// See `CompletionResolveCapability` for the details.
|
||||
pub fn resolve_edits_immediately(&self) -> bool {
|
||||
!self
|
||||
.active_resolve_capabilities
|
||||
.contains(&CompletionResolveCapability::AdditionalTextEdits)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,7 @@ impl Default for CompletionConfig {
|
|||
add_call_argument_snippets: true,
|
||||
snippet_cap: Some(SnippetCap { _private: () }),
|
||||
merge: Some(MergeBehaviour::Full),
|
||||
resolve_capabilities: FxHashSet::default(),
|
||||
active_resolve_capabilities: FxHashSet::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,10 +194,7 @@ impl<'a> Render<'a> {
|
|||
local_name,
|
||||
)
|
||||
.kind(CompletionItemKind::UnresolvedReference)
|
||||
.add_import(
|
||||
import_to_add,
|
||||
self.ctx.completion.config.should_resolve_additional_edits_immediately(),
|
||||
)
|
||||
.add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately())
|
||||
.build();
|
||||
return Some(item);
|
||||
}
|
||||
|
@ -252,10 +249,7 @@ impl<'a> Render<'a> {
|
|||
|
||||
let item = item
|
||||
.kind(kind)
|
||||
.add_import(
|
||||
import_to_add,
|
||||
self.ctx.completion.config.should_resolve_additional_edits_immediately(),
|
||||
)
|
||||
.add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately())
|
||||
.set_documentation(docs)
|
||||
.set_ref_match(ref_match)
|
||||
.build();
|
||||
|
|
|
@ -71,10 +71,7 @@ impl<'a> EnumVariantRender<'a> {
|
|||
.kind(CompletionItemKind::EnumVariant)
|
||||
.set_documentation(self.variant.docs(self.ctx.db()))
|
||||
.set_deprecated(self.ctx.is_deprecated(self.variant))
|
||||
.add_import(
|
||||
import_to_add,
|
||||
self.ctx.completion.config.should_resolve_additional_edits_immediately(),
|
||||
)
|
||||
.add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately())
|
||||
.detail(self.detail());
|
||||
|
||||
if self.variant_kind == StructKind::Tuple {
|
||||
|
|
|
@ -47,10 +47,7 @@ impl<'a> FunctionRender<'a> {
|
|||
.set_deprecated(self.ctx.is_deprecated(self.func))
|
||||
.detail(self.detail())
|
||||
.add_call_parens(self.ctx.completion, self.name, params)
|
||||
.add_import(
|
||||
import_to_add,
|
||||
self.ctx.completion.config.should_resolve_additional_edits_immediately(),
|
||||
)
|
||||
.add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately())
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
|
@ -50,10 +50,7 @@ impl<'a> MacroRender<'a> {
|
|||
.kind(CompletionItemKind::Macro)
|
||||
.set_documentation(self.docs.clone())
|
||||
.set_deprecated(self.ctx.is_deprecated(self.macro_))
|
||||
.add_import(
|
||||
import_to_add,
|
||||
self.ctx.completion.config.should_resolve_additional_edits_immediately(),
|
||||
)
|
||||
.add_import(import_to_add, self.ctx.completion.config.resolve_edits_immediately())
|
||||
.detail(self.detail());
|
||||
|
||||
let needs_bang = self.needs_bang();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue