10726: minor: Add some completion profile spans r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-11-08 18:42:10 +00:00 committed by GitHub
commit 3c786bd7fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 6 deletions

View File

@ -6,6 +6,7 @@
use crate::{patterns::ImmediateLocation, CompletionContext, Completions}; use crate::{patterns::ImmediateLocation, CompletionContext, Completions};
pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) {
let _p = profile::span("complete_unqualified_path");
if ctx.is_path_disallowed() || !ctx.is_trivial_path() || ctx.has_impl_or_trait_prev_sibling() { if ctx.is_path_disallowed() || !ctx.is_trivial_path() || ctx.has_impl_or_trait_prev_sibling() {
return; return;
} }

View File

@ -353,6 +353,7 @@ pub(super) fn new(
position: FilePosition, position: FilePosition,
config: &'a CompletionConfig, config: &'a CompletionConfig,
) -> Option<CompletionContext<'a>> { ) -> Option<CompletionContext<'a>> {
let _p = profile::span("CompletionContext::new");
let sema = Semantics::new(db); let sema = Semantics::new(db);
let original_file = sema.parse(position.file_id); let original_file = sema.parse(position.file_id);

View File

@ -16,7 +16,7 @@
helpers::{item_name, SnippetCap}, helpers::{item_name, SnippetCap},
RootDatabase, SymbolKind, RootDatabase, SymbolKind,
}; };
use syntax::{SyntaxKind, TextRange}; use syntax::{SmolStr, SyntaxKind, TextRange};
use crate::{ use crate::{
context::{PathCompletionContext, PathKind}, context::{PathCompletionContext, PathKind},
@ -243,7 +243,7 @@ fn render_resolution_(
if has_non_default_type_params { if has_non_default_type_params {
cov_mark::hit!(inserts_angle_brackets_for_generics); cov_mark::hit!(inserts_angle_brackets_for_generics);
item.lookup_by(local_name.clone()) item.lookup_by(local_name.clone())
.label(format!("{}<…>", local_name)) .label(SmolStr::from_iter([&local_name, "<…>"]))
.insert_snippet(cap, format!("{}<$0>", local_name)); .insert_snippet(cap, format!("{}<$0>", local_name));
} }
} }

View File

@ -7,6 +7,7 @@
use crate::{item::CompletionItem, render::RenderContext}; use crate::{item::CompletionItem, render::RenderContext};
pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> { pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
let _p = profile::span("render_const");
ConstRender::new(ctx, const_)?.render() ConstRender::new(ctx, const_)?.render()
} }

View File

@ -40,7 +40,7 @@ fn new(ctx: RenderContext<'a>, name: hir::Name, macro_: hir::MacroDef) -> MacroR
MacroRender { ctx, name, macro_, docs, bra, ket } 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() { let source_range = if self.ctx.completion.is_immediately_after_macro_bang() {
cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token); cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
self.ctx.completion.token.parent().map(|it| it.text_range()) self.ctx.completion.token.parent().map(|it| it.text_range())
@ -48,9 +48,7 @@ fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
Some(self.ctx.source_range()) Some(self.ctx.source_range())
}?; }?;
let mut item = CompletionItem::new(SymbolKind::Macro, source_range, self.label()); let mut item = CompletionItem::new(SymbolKind::Macro, source_range, self.label());
item.set_documentation(self.docs.clone()) item.set_deprecated(self.ctx.is_deprecated(self.macro_)).set_detail(self.detail());
.set_deprecated(self.ctx.is_deprecated(self.macro_))
.set_detail(self.detail());
if let Some(import_to_add) = import_to_add { if let Some(import_to_add) = import_to_add {
item.add_import(import_to_add); item.add_import(import_to_add);
@ -76,6 +74,7 @@ fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
} }
}; };
item.set_documentation(self.docs);
Some(item.build()) Some(item.build())
} }

View File

@ -13,6 +13,7 @@ pub(crate) fn render_type_alias(
ctx: RenderContext<'_>, ctx: RenderContext<'_>,
type_alias: hir::TypeAlias, type_alias: hir::TypeAlias,
) -> Option<CompletionItem> { ) -> Option<CompletionItem> {
let _p = profile::span("render_type_alias");
TypeAliasRender::new(ctx, type_alias)?.render(false) TypeAliasRender::new(ctx, type_alias)?.render(false)
} }
@ -20,6 +21,7 @@ pub(crate) fn render_type_alias_with_eq(
ctx: RenderContext<'_>, ctx: RenderContext<'_>,
type_alias: hir::TypeAlias, type_alias: hir::TypeAlias,
) -> Option<CompletionItem> { ) -> Option<CompletionItem> {
let _p = profile::span("render_type_alias_with_eq");
TypeAliasRender::new(ctx, type_alias)?.render(true) TypeAliasRender::new(ctx, type_alias)?.render(true)
} }