Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/ide-completion/src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ impl Completions {
}
}

pub(crate) fn add_type_keywords(&mut self, ctx: &CompletionContext<'_>) {
self.add_keyword_snippet(ctx, "fn", "fn($1)");
self.add_keyword_snippet(ctx, "dyn", "dyn $0");
self.add_keyword_snippet(ctx, "impl", "impl $0");
self.add_keyword_snippet(ctx, "for", "for<$1>");
}

pub(crate) fn add_super_keyword(
&mut self,
ctx: &CompletionContext<'_>,
Expand Down
1 change: 1 addition & 0 deletions crates/ide-completion/src/completions/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ pub(crate) fn complete_type_path(
};

acc.add_nameref_keywords_with_colon(ctx);
acc.add_type_keywords(ctx);
ctx.process_all_names(&mut |name, def, doc_aliases| {
if scope_def_applicable(def) {
acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases);
Expand Down
8 changes: 8 additions & 0 deletions crates/ide-completion/src/tests/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ impl Tra$0
un Union Union
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
)
Expand All @@ -45,6 +49,10 @@ impl Trait for Str$0
un Union Union
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
)
Expand Down
12 changes: 12 additions & 0 deletions crates/ide-completion/src/tests/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ struct Foo<'lt, T, const C: usize> where $0 {}
un Union Union
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
);
Expand Down Expand Up @@ -95,6 +99,10 @@ struct Foo<'lt, T, const C: usize> where for<'a> $0 {}
un Union Union
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
);
Expand All @@ -120,6 +128,10 @@ impl Record {
un Union Union
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
);
Expand Down
8 changes: 8 additions & 0 deletions crates/ide-completion/src/tests/special.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,10 @@ fn foo(_: a_$0) { }
expect![[r#"
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
);
Expand All @@ -1506,6 +1510,10 @@ fn foo<T>() {
tp T
bt u32 u32
kw crate::
kw dyn
kw fn
kw for
kw impl
kw self::
"#]],
);
Expand Down
Loading
Loading