mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Partially unify SymbolKind and CompletionItemKind
This commit is contained in:
parent
563a175fdb
commit
f2cb7dbcb7
13 changed files with 128 additions and 110 deletions
|
@ -1,13 +1,14 @@
|
|||
//! Renderer for `const` fields.
|
||||
|
||||
use hir::HasSource;
|
||||
use ide_db::SymbolKind;
|
||||
use syntax::{
|
||||
ast::{Const, NameOwner},
|
||||
display::const_label,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
item::{CompletionItem, CompletionItemKind, CompletionKind},
|
||||
item::{CompletionItem, CompletionKind},
|
||||
render::RenderContext,
|
||||
};
|
||||
|
||||
|
@ -36,7 +37,7 @@ impl<'a> ConstRender<'a> {
|
|||
let detail = self.detail();
|
||||
|
||||
let item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), name)
|
||||
.kind(CompletionItemKind::Const)
|
||||
.kind(SymbolKind::Const)
|
||||
.set_documentation(self.ctx.docs(self.const_))
|
||||
.set_deprecated(
|
||||
self.ctx.is_deprecated(self.const_)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
//! Renderer for `enum` variants.
|
||||
|
||||
use hir::{HasAttrs, HirDisplay, ModPath, StructKind};
|
||||
use ide_db::SymbolKind;
|
||||
use itertools::Itertools;
|
||||
use test_utils::mark;
|
||||
|
||||
use crate::{
|
||||
item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit},
|
||||
item::{CompletionItem, CompletionKind, ImportEdit},
|
||||
render::{builder_ext::Params, RenderContext},
|
||||
};
|
||||
|
||||
|
@ -60,7 +61,7 @@ impl<'a> EnumRender<'a> {
|
|||
self.ctx.source_range(),
|
||||
self.qualified_name.clone(),
|
||||
)
|
||||
.kind(CompletionItemKind::EnumVariant)
|
||||
.kind(SymbolKind::Variant)
|
||||
.set_documentation(self.variant.docs(self.ctx.db()))
|
||||
.set_deprecated(self.ctx.is_deprecated(self.variant))
|
||||
.add_import(import_to_add)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! Renderer for function calls.
|
||||
|
||||
use hir::{HasSource, Type};
|
||||
use ide_db::SymbolKind;
|
||||
use syntax::{ast::Fn, display::function_declaration};
|
||||
use test_utils::mark;
|
||||
|
||||
|
@ -105,7 +106,7 @@ impl<'a> FunctionRender<'a> {
|
|||
if self.func.self_param(self.ctx.db()).is_some() {
|
||||
CompletionItemKind::Method
|
||||
} else {
|
||||
CompletionItemKind::Function
|
||||
SymbolKind::Function.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
//! Renderer for macro invocations.
|
||||
|
||||
use hir::{Documentation, HasSource};
|
||||
use ide_db::SymbolKind;
|
||||
use syntax::display::macro_label;
|
||||
use test_utils::mark;
|
||||
|
||||
use crate::{
|
||||
item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit},
|
||||
item::{CompletionItem, CompletionKind, ImportEdit},
|
||||
render::RenderContext,
|
||||
};
|
||||
|
||||
|
@ -41,7 +42,7 @@ impl<'a> MacroRender<'a> {
|
|||
fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
|
||||
let mut builder =
|
||||
CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label())
|
||||
.kind(CompletionItemKind::Macro)
|
||||
.kind(SymbolKind::Macro)
|
||||
.set_documentation(self.docs.clone())
|
||||
.set_deprecated(self.ctx.is_deprecated(self.macro_))
|
||||
.add_import(import_to_add)
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
//! Renderer for type aliases.
|
||||
|
||||
use hir::HasSource;
|
||||
use ide_db::SymbolKind;
|
||||
use syntax::{
|
||||
ast::{NameOwner, TypeAlias},
|
||||
display::type_label,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
item::{CompletionItem, CompletionItemKind, CompletionKind},
|
||||
item::{CompletionItem, CompletionKind},
|
||||
render::RenderContext,
|
||||
};
|
||||
|
||||
|
@ -36,7 +37,7 @@ impl<'a> TypeAliasRender<'a> {
|
|||
let detail = self.detail();
|
||||
|
||||
let item = CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), name)
|
||||
.kind(CompletionItemKind::TypeAlias)
|
||||
.kind(SymbolKind::TypeAlias)
|
||||
.set_documentation(self.ctx.docs(self.type_alias))
|
||||
.set_deprecated(
|
||||
self.ctx.is_deprecated(self.type_alias)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue