mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Add some completion profile spans
This commit is contained in:
parent
c5c11b87cc
commit
ab657af5b7
6 changed files with 10 additions and 6 deletions
|
@ -7,6 +7,7 @@ use syntax::{ast::Const, display::const_label};
|
|||
use crate::{item::CompletionItem, render::RenderContext};
|
||||
|
||||
pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
|
||||
let _p = profile::span("render_const");
|
||||
ConstRender::new(ctx, const_)?.render()
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ impl<'a> MacroRender<'a> {
|
|||
MacroRender { ctx, name, macro_, docs, bra, ket }
|
||||
}
|
||||
|
||||
fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
|
||||
fn render(self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
|
||||
let source_range = if self.ctx.completion.is_immediately_after_macro_bang() {
|
||||
cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
|
||||
self.ctx.completion.token.parent().map(|it| it.text_range())
|
||||
|
@ -48,9 +48,7 @@ impl<'a> MacroRender<'a> {
|
|||
Some(self.ctx.source_range())
|
||||
}?;
|
||||
let mut item = CompletionItem::new(SymbolKind::Macro, source_range, self.label());
|
||||
item.set_documentation(self.docs.clone())
|
||||
.set_deprecated(self.ctx.is_deprecated(self.macro_))
|
||||
.set_detail(self.detail());
|
||||
item.set_deprecated(self.ctx.is_deprecated(self.macro_)).set_detail(self.detail());
|
||||
|
||||
if let Some(import_to_add) = import_to_add {
|
||||
item.add_import(import_to_add);
|
||||
|
@ -76,6 +74,7 @@ impl<'a> MacroRender<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
item.set_documentation(self.docs);
|
||||
Some(item.build())
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ pub(crate) fn render_type_alias(
|
|||
ctx: RenderContext<'_>,
|
||||
type_alias: hir::TypeAlias,
|
||||
) -> Option<CompletionItem> {
|
||||
let _p = profile::span("render_type_alias");
|
||||
TypeAliasRender::new(ctx, type_alias)?.render(false)
|
||||
}
|
||||
|
||||
|
@ -20,6 +21,7 @@ pub(crate) fn render_type_alias_with_eq(
|
|||
ctx: RenderContext<'_>,
|
||||
type_alias: hir::TypeAlias,
|
||||
) -> Option<CompletionItem> {
|
||||
let _p = profile::span("render_type_alias_with_eq");
|
||||
TypeAliasRender::new(ctx, type_alias)?.render(true)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue