mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 05:13:35 +00:00
Merge pull request #18927 from ChayimFriedman2/skip-iter-await
feat: Add smart completions that skip `await` or `iter()` and `into_iter()`
This commit is contained in:
commit
c7f187430f
7 changed files with 230 additions and 72 deletions
|
|
@ -23,7 +23,7 @@ use crate::{
|
|||
#[derive(Debug)]
|
||||
enum FuncKind<'ctx> {
|
||||
Function(&'ctx PathCompletionCtx),
|
||||
Method(&'ctx DotAccess, Option<hir::Name>),
|
||||
Method(&'ctx DotAccess, Option<SmolStr>),
|
||||
}
|
||||
|
||||
pub(crate) fn render_fn(
|
||||
|
|
@ -39,7 +39,7 @@ pub(crate) fn render_fn(
|
|||
pub(crate) fn render_method(
|
||||
ctx: RenderContext<'_>,
|
||||
dot_access: &DotAccess,
|
||||
receiver: Option<hir::Name>,
|
||||
receiver: Option<SmolStr>,
|
||||
local_name: Option<hir::Name>,
|
||||
func: hir::Function,
|
||||
) -> Builder {
|
||||
|
|
@ -59,16 +59,8 @@ fn render(
|
|||
|
||||
let (call, escaped_call) = match &func_kind {
|
||||
FuncKind::Method(_, Some(receiver)) => (
|
||||
format_smolstr!(
|
||||
"{}.{}",
|
||||
receiver.unescaped().display(ctx.db()),
|
||||
name.unescaped().display(ctx.db())
|
||||
),
|
||||
format_smolstr!(
|
||||
"{}.{}",
|
||||
receiver.display(ctx.db(), completion.edition),
|
||||
name.display(ctx.db(), completion.edition)
|
||||
),
|
||||
format_smolstr!("{}.{}", receiver, name.unescaped().display(ctx.db())),
|
||||
format_smolstr!("{}.{}", receiver, name.display(ctx.db(), completion.edition)),
|
||||
),
|
||||
_ => (
|
||||
name.unescaped().display(db).to_smolstr(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue