minor: Make use of some new SmolStr improvements

This commit is contained in:
Lukas Wirth 2024-01-17 13:43:18 +01:00
parent 0bdbf497b6
commit 83591268ab
18 changed files with 80 additions and 61 deletions

View file

@ -4,7 +4,7 @@ use hir::{db::HirDatabase, AsAssocItem, HirDisplay};
use ide_db::{SnippetCap, SymbolKind};
use itertools::Itertools;
use stdx::{format_to, to_lower_snake_case};
use syntax::{AstNode, SmolStr};
use syntax::{format_smolstr, AstNode, SmolStr};
use crate::{
context::{CompletionContext, DotAccess, DotAccessKind, PathCompletionCtx, PathKind},
@ -52,13 +52,12 @@ fn render(
let (call, escaped_call) = match &func_kind {
FuncKind::Method(_, Some(receiver)) => (
format!(
format_smolstr!(
"{}.{}",
receiver.unescaped().display(ctx.db()),
name.unescaped().display(ctx.db())
)
.into(),
format!("{}.{}", receiver.display(ctx.db()), name.display(ctx.db())).into(),
),
format_smolstr!("{}.{}", receiver.display(ctx.db()), name.display(ctx.db())),
),
_ => (name.unescaped().to_smol_str(), name.to_smol_str()),
};

View file

@ -2,7 +2,7 @@
use hir::HirDisplay;
use ide_db::{documentation::Documentation, SymbolKind};
use syntax::SmolStr;
use syntax::{format_smolstr, SmolStr};
use crate::{
context::{PathCompletionCtx, PathKind, PatternContext},
@ -94,7 +94,7 @@ fn label(
) -> SmolStr {
if needs_bang {
if ctx.snippet_cap().is_some() {
SmolStr::from_iter([&*name, "!", bra, "", ket])
format_smolstr!("{name}!{bra}…{ket}",)
} else {
banged_name(name)
}