Remove source_old from adding const and function impls

This commit is contained in:
Nick Spain 2021-01-01 17:30:13 +11:00
parent 7bfec89cf9
commit 3a1f8e897b

View file

@ -156,8 +156,8 @@ fn add_function_impl(
}; };
let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end()); let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end());
#[allow(deprecated)] if let Some(src) = func.source(ctx.db) {
let function_decl = function_declaration(&func.source_old(ctx.db).value); let function_decl = function_declaration(&src.value);
match ctx.config.snippet_cap { match ctx.config.snippet_cap {
Some(cap) => { Some(cap) => {
let snippet = format!("{} {{\n $0\n}}", function_decl); let snippet = format!("{} {{\n $0\n}}", function_decl);
@ -170,6 +170,7 @@ fn add_function_impl(
} }
.kind(completion_kind) .kind(completion_kind)
.add_to(acc); .add_to(acc);
}
} }
fn add_type_alias_impl( fn add_type_alias_impl(
@ -201,10 +202,11 @@ fn add_const_impl(
let const_name = const_.name(ctx.db).map(|n| n.to_string()); let const_name = const_.name(ctx.db).map(|n| n.to_string());
if let Some(const_name) = const_name { if let Some(const_name) = const_name {
#[allow(deprecated)] if let Some(source) = const_.source(ctx.db) {
let snippet = make_const_compl_syntax(&const_.source_old(ctx.db).value); 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()) CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone())
.text_edit(TextEdit::replace(range, snippet)) .text_edit(TextEdit::replace(range, snippet))
@ -213,6 +215,7 @@ fn add_const_impl(
.set_documentation(const_.docs(ctx.db)) .set_documentation(const_.docs(ctx.db))
.add_to(acc); .add_to(acc);
} }
}
} }
fn make_const_compl_syntax(const_: &ast::Const) -> String { fn make_const_compl_syntax(const_: &ast::Const) -> String {