- params.into_iter().for_each(|(label, lookup)| {
- let mut item = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label);
- item.kind(CompletionItemKind::Binding).lookup_by(lookup);
- item.add_to(acc)
- });
+ let self_completion_items = ["self", "&self", "mut self", "&mut self"];
+ if ctx.impl_def.is_some() && me?.param_list()?.params().next().is_none() {
+ self_completion_items.iter().for_each(|self_item| {
+ add_new_item_to_acc(ctx, acc, self_item.to_string(), self_item.to_string())
+ });
+ }
+
+ params.into_iter().for_each(|(label, lookup)| add_new_item_to_acc(ctx, acc, label, lookup));
+
+ Some(())
+}
+
+fn add_new_item_to_acc(
+ ctx: &CompletionContext,
+ acc: &mut Completions,
+ label: String,
+ lookup: String,
+) {
+ let mut item = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label);
+ item.kind(CompletionItemKind::Binding).lookup_by(lookup);
+ item.add_to(acc)