Skip to content

Commit 3c786bd

Browse files
bors[bot]Veykril
andauthored
Merge #10726
10726: minor: Add some completion profile spans r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents 653b78e + ab657af commit 3c786bd

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

crates/ide_completion/src/completions/unqualified_path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use syntax::{ast, AstNode};
66
use crate::{patterns::ImmediateLocation, CompletionContext, Completions};
77

88
pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) {
9+
let _p = profile::span("complete_unqualified_path");
910
if ctx.is_path_disallowed() || !ctx.is_trivial_path() || ctx.has_impl_or_trait_prev_sibling() {
1011
return;
1112
}

crates/ide_completion/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ impl<'a> CompletionContext<'a> {
353353
position: FilePosition,
354354
config: &'a CompletionConfig,
355355
) -> Option<CompletionContext<'a>> {
356+
let _p = profile::span("CompletionContext::new");
356357
let sema = Semantics::new(db);
357358

358359
let original_file = sema.parse(position.file_id);

crates/ide_completion/src/render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ide_db::{
1616
helpers::{item_name, SnippetCap},
1717
RootDatabase, SymbolKind,
1818
};
19-
use syntax::{SyntaxKind, TextRange};
19+
use syntax::{SmolStr, SyntaxKind, TextRange};
2020

2121
use crate::{
2222
context::{PathCompletionContext, PathKind},
@@ -243,7 +243,7 @@ fn render_resolution_(
243243
if has_non_default_type_params {
244244
cov_mark::hit!(inserts_angle_brackets_for_generics);
245245
item.lookup_by(local_name.clone())
246-
.label(format!("{}<…>", local_name))
246+
.label(SmolStr::from_iter([&local_name, "<…>"]))
247247
.insert_snippet(cap, format!("{}<$0>", local_name));
248248
}
249249
}

crates/ide_completion/src/render/const_.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use syntax::{ast::Const, display::const_label};
77
use crate::{item::CompletionItem, render::RenderContext};
88

99
pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
10+
let _p = profile::span("render_const");
1011
ConstRender::new(ctx, const_)?.render()
1112
}
1213

crates/ide_completion/src/render/macro_.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ impl<'a> MacroRender<'a> {
4040
MacroRender { ctx, name, macro_, docs, bra, ket }
4141
}
4242

43-
fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
43+
fn render(self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
4444
let source_range = if self.ctx.completion.is_immediately_after_macro_bang() {
4545
cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
4646
self.ctx.completion.token.parent().map(|it| it.text_range())
4747
} else {
4848
Some(self.ctx.source_range())
4949
}?;
5050
let mut item = CompletionItem::new(SymbolKind::Macro, source_range, self.label());
51-
item.set_documentation(self.docs.clone())
52-
.set_deprecated(self.ctx.is_deprecated(self.macro_))
53-
.set_detail(self.detail());
51+
item.set_deprecated(self.ctx.is_deprecated(self.macro_)).set_detail(self.detail());
5452

5553
if let Some(import_to_add) = import_to_add {
5654
item.add_import(import_to_add);
@@ -76,6 +74,7 @@ impl<'a> MacroRender<'a> {
7674
}
7775
};
7876

77+
item.set_documentation(self.docs);
7978
Some(item.build())
8079
}
8180

crates/ide_completion/src/render/type_alias.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ pub(crate) fn render_type_alias(
1313
ctx: RenderContext<'_>,
1414
type_alias: hir::TypeAlias,
1515
) -> Option<CompletionItem> {
16+
let _p = profile::span("render_type_alias");
1617
TypeAliasRender::new(ctx, type_alias)?.render(false)
1718
}
1819

1920
pub(crate) fn render_type_alias_with_eq(
2021
ctx: RenderContext<'_>,
2122
type_alias: hir::TypeAlias,
2223
) -> Option<CompletionItem> {
24+
let _p = profile::span("render_type_alias_with_eq");
2325
TypeAliasRender::new(ctx, type_alias)?.render(true)
2426
}
2527

0 commit comments

Comments
 (0)