Remove source_old from adding const and function impls
@@ -156,8 +156,8 @@ fn add_function_impl(
};
let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end());
- #[allow(deprecated)]
- let function_decl = function_declaration(&func.source_old(ctx.db).value);
+ if let Some(src) = func.source(ctx.db) {
+ let function_decl = function_declaration(&src.value);
match ctx.config.snippet_cap {
Some(cap) => {
let snippet = format!("{} {{\n $0\n}}", function_decl);
@@ -171,6 +171,7 @@ fn add_function_impl(
.kind(completion_kind)
.add_to(acc);
}
+}
fn add_type_alias_impl(
type_def_node: &SyntaxNode,
@@ -201,10 +202,11 @@ fn add_const_impl(
let const_name = const_.name(ctx.db).map(|n| n.to_string());
if let Some(const_name) = const_name {
- #[allow(deprecated)]
- let snippet = make_const_compl_syntax(&const_.source_old(ctx.db).value);
+ if let Some(source) = const_.source(ctx.db) {
+ let snippet = make_const_compl_syntax(&source.value);
- let range = TextRange::new(const_def_node.text_range().start(), ctx.source_range().end());
+ let range =
+ TextRange::new(const_def_node.text_range().start(), ctx.source_range().end());
CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone())
.text_edit(TextEdit::replace(range, snippet))
@@ -214,6 +216,7 @@ fn add_const_impl(
.add_to(acc);
}
}
+}
fn make_const_compl_syntax(const_: &ast::Const) -> String {
let const_ = edit::remove_attrs_and_docs(const_);
