mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add doc(alias)-based method completion
This commit is contained in:
parent
d4b668a3bb
commit
2a182f3f1f
@ -295,9 +295,12 @@ impl Completions {
|
||||
Visible::Editable => true,
|
||||
Visible::No => return,
|
||||
};
|
||||
let doc_aliases = ctx.doc_aliases(&func);
|
||||
self.add(
|
||||
render_fn(
|
||||
RenderContext::new(ctx).private_editable(is_private_editable),
|
||||
RenderContext::new(ctx)
|
||||
.private_editable(is_private_editable)
|
||||
.doc_aliases(doc_aliases),
|
||||
path_ctx,
|
||||
local_name,
|
||||
func,
|
||||
@ -322,9 +325,12 @@ impl Completions {
|
||||
Visible::Editable => true,
|
||||
Visible::No => return,
|
||||
};
|
||||
let doc_aliases = ctx.doc_aliases(&func);
|
||||
self.add(
|
||||
render_method(
|
||||
RenderContext::new(ctx).private_editable(is_private_editable),
|
||||
RenderContext::new(ctx)
|
||||
.private_editable(is_private_editable)
|
||||
.doc_aliases(doc_aliases),
|
||||
dot_access,
|
||||
receiver,
|
||||
local_name,
|
||||
@ -349,10 +355,12 @@ impl Completions {
|
||||
Visible::Editable => true,
|
||||
Visible::No => return,
|
||||
};
|
||||
let doc_aliases = ctx.doc_aliases(&func);
|
||||
self.add(
|
||||
render_method(
|
||||
RenderContext::new(ctx)
|
||||
.private_editable(is_private_editable)
|
||||
.doc_aliases(doc_aliases)
|
||||
.import_to_add(Some(import)),
|
||||
dot_access,
|
||||
None,
|
||||
|
@ -1106,6 +1106,62 @@ fn here_we_go() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_struct_fn_name_via_doc_alias_in_fn_body() {
|
||||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
#[doc(alias = "qux")]
|
||||
fn bar() -> u8 { 1 }
|
||||
}
|
||||
|
||||
fn here_we_go() {
|
||||
Foo::q$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn bar() (alias qux) fn() -> u8
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_method_name_via_doc_alias_in_fn_body() {
|
||||
check(
|
||||
r#"
|
||||
struct Foo {
|
||||
bar: u8
|
||||
}
|
||||
impl Foo {
|
||||
#[doc(alias = "qux")]
|
||||
fn baz(&self) -> u8 {
|
||||
self.bar
|
||||
}
|
||||
}
|
||||
|
||||
fn here_we_go() {
|
||||
let foo = Foo { field: 42 };
|
||||
foo.q$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd bar u8
|
||||
me baz() (alias qux) fn(&self) -> u8
|
||||
sn box Box::new(expr)
|
||||
sn call function(expr)
|
||||
sn dbg dbg!(expr)
|
||||
sn dbgr dbg!(&expr)
|
||||
sn let let
|
||||
sn letm let mut
|
||||
sn match match expr {}
|
||||
sn ref &expr
|
||||
sn refm &mut expr
|
||||
sn unsafe unsafe {}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_fn_name_via_doc_alias_in_fn_body() {
|
||||
check(
|
||||
|
Loading…
Reference in New Issue
Block a user