Set deprecated field on CompletionItems

This commit is contained in:
Martin Asquino 2019-11-01 23:52:59 -03:00
parent eb8f76a86f
commit dc3848a6a3
9 changed files with 186 additions and 1 deletions

View file

@ -96,6 +96,7 @@ mod tests {
insert: "the_field", insert: "the_field",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"### "###
@ -128,6 +129,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "foo", lookup: "foo",
detail: "fn foo(self)", detail: "fn foo(self)",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "the_field", label: "the_field",
@ -139,6 +141,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"This is the_field", "This is the_field",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -168,6 +171,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "foo", lookup: "foo",
detail: "fn foo(&self)", detail: "fn foo(&self)",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "the_field", label: "the_field",
@ -176,6 +180,7 @@ mod tests {
insert: "the_field", insert: "the_field",
kind: Field, kind: Field,
detail: "(u32, i32)", detail: "(u32, i32)",
deprecated: false,
}, },
] ]
"### "###
@ -221,6 +226,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "the_method", lookup: "the_method",
detail: "fn the_method(&self)", detail: "fn the_method(&self)",
deprecated: false,
}, },
] ]
"### "###
@ -250,6 +256,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "the_method", lookup: "the_method",
detail: "fn the_method(&self)", detail: "fn the_method(&self)",
deprecated: false,
}, },
] ]
"### "###
@ -279,6 +286,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "the_method", lookup: "the_method",
detail: "fn the_method(&self)", detail: "fn the_method(&self)",
deprecated: false,
}, },
] ]
"### "###
@ -331,6 +339,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "the_method", lookup: "the_method",
detail: "fn the_method(&self)", detail: "fn the_method(&self)",
deprecated: false,
}, },
] ]
"### "###
@ -401,6 +410,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "blah", lookup: "blah",
detail: "pub fn blah(&self)", detail: "pub fn blah(&self)",
deprecated: false,
}, },
] ]
"### "###
@ -427,6 +437,7 @@ mod tests {
insert: "the_field", insert: "the_field",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"### "###

View file

@ -45,6 +45,7 @@ mod tests {
insert: "foo!($0)", insert: "foo!($0)",
kind: Macro, kind: Macro,
detail: "macro_rules! foo", detail: "macro_rules! foo",
deprecated: false,
}, },
]"## ]"##
); );
@ -86,6 +87,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"Creates a [`Vec`] containing the arguments.\n\n- Create a [`Vec`] containing a given list of elements:\n\n```\nlet v = vec![1, 2, 3];\nassert_eq!(v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```", "Creates a [`Vec`] containing the arguments.\n\n- Create a [`Vec`] containing a given list of elements:\n\n```\nlet v = vec![1, 2, 3];\nassert_eq!(v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```",
), ),
deprecated: false,
}, },
]"## ]"##
); );
@ -121,6 +123,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"Foo\n\nNot call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`.\nCall as `let _=foo! { hello world };`", "Foo\n\nNot call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`.\nCall as `let _=foo! { hello world };`",
), ),
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "main()", label: "main()",
@ -130,6 +133,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
] ]
"### "###

View file

@ -308,6 +308,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"Bar Variant with i32", "Bar Variant with i32",
), ),
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "Foo", label: "Foo",
@ -319,6 +320,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"Foo Variant", "Foo Variant",
), ),
deprecated: false,
}, },
]"### ]"###
); );
@ -354,6 +356,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"Bar Variant with i32 and u32", "Bar Variant with i32 and u32",
), ),
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "Foo", label: "Foo",
@ -365,6 +368,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"Foo Variant (empty)", "Foo Variant (empty)",
), ),
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "S", label: "S",
@ -376,6 +380,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"", "",
), ),
deprecated: false,
}, },
]"### ]"###
); );
@ -411,6 +416,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"An associated method", "An associated method",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -445,6 +451,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"An associated const", "An associated const",
), ),
deprecated: false,
}, },
]"### ]"###
); );
@ -478,6 +485,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"An associated type", "An associated type",
), ),
deprecated: false,
}, },
]"### ]"###
); );
@ -513,6 +521,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"An associated method", "An associated method",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -549,6 +558,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"An associated method", "An associated method",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -608,6 +618,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"A trait method", "A trait method",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -644,6 +655,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"A trait method", "A trait method",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -680,6 +692,7 @@ mod tests {
documentation: Documentation( documentation: Documentation(
"A trait method", "A trait method",
), ),
deprecated: false,
}, },
] ]
"### "###
@ -711,6 +724,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "bar", lookup: "bar",
detail: "fn bar()", detail: "fn bar()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "foo()", label: "foo()",
@ -720,6 +734,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo()", detail: "fn foo()",
deprecated: false,
}, },
] ]
"### "###
@ -750,6 +765,7 @@ mod tests {
insert: "foo!($0)", insert: "foo!($0)",
kind: Macro, kind: Macro,
detail: "#[macro_export]\nmacro_rules! foo", detail: "#[macro_export]\nmacro_rules! foo",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "main()", label: "main()",
@ -759,6 +775,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
] ]
"### "###

View file

@ -31,6 +31,34 @@ mod tests {
do_completion(code, CompletionKind::Reference) do_completion(code, CompletionKind::Reference)
} }
#[test]
fn test_record_literal_deprecated_field() {
let completions = complete(
r"
struct A {
#[deprecated]
the_field: u32,
}
fn foo() {
A { the<|> }
}
",
);
assert_debug_snapshot!(completions, @r###"
[
CompletionItem {
label: "the_field",
source_range: [142; 145),
delete: [142; 145),
insert: "the_field",
kind: Field,
detail: "u32",
deprecated: true,
},
]
"###);
}
#[test] #[test]
fn test_record_literal_field() { fn test_record_literal_field() {
let completions = complete( let completions = complete(
@ -50,6 +78,7 @@ mod tests {
insert: "the_field", insert: "the_field",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"###); "###);
@ -76,6 +105,7 @@ mod tests {
insert: "a", insert: "a",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"###); "###);
@ -102,6 +132,7 @@ mod tests {
insert: "b", insert: "b",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"###); "###);
@ -127,6 +158,7 @@ mod tests {
insert: "a", insert: "a",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"###); "###);

View file

@ -52,6 +52,7 @@ mod tests {
insert: "foo", insert: "foo",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"###); "###);
@ -81,6 +82,7 @@ mod tests {
insert: "bar", insert: "bar",
kind: Field, kind: Field,
detail: "()", detail: "()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "foo", label: "foo",
@ -89,6 +91,7 @@ mod tests {
insert: "foo", insert: "foo",
kind: Field, kind: Field,
detail: "u32", detail: "u32",
deprecated: false,
}, },
] ]
"###); "###);

View file

@ -155,6 +155,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "quux", lookup: "quux",
detail: "fn quux(x: i32)", detail: "fn quux(x: i32)",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "x", label: "x",
@ -218,6 +219,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "quux", lookup: "quux",
detail: "fn quux()", detail: "fn quux()",
deprecated: false,
}, },
] ]
"### "###
@ -246,6 +248,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "quux", lookup: "quux",
detail: "fn quux()", detail: "fn quux()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "x", label: "x",
@ -286,6 +289,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "quux", lookup: "quux",
detail: "fn quux<T>()", detail: "fn quux<T>()",
deprecated: false,
}, },
] ]
"### "###
@ -391,6 +395,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "quux", lookup: "quux",
detail: "fn quux()", detail: "fn quux()",
deprecated: false,
}, },
] ]
"### "###
@ -450,6 +455,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "quux", lookup: "quux",
detail: "fn quux()", detail: "fn quux()",
deprecated: false,
}, },
] ]
"### "###
@ -482,6 +488,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "x", lookup: "x",
detail: "fn x()", detail: "fn x()",
deprecated: false,
}, },
] ]
"### "###
@ -520,6 +527,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo()", detail: "fn foo()",
deprecated: false,
}, },
] ]
"### "###
@ -584,6 +592,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo()", detail: "fn foo()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "std", label: "std",
@ -639,6 +648,7 @@ mod tests {
insert: "bar!($0)", insert: "bar!($0)",
kind: Macro, kind: Macro,
detail: "macro_rules! bar", detail: "macro_rules! bar",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "baz!", label: "baz!",
@ -647,6 +657,7 @@ mod tests {
insert: "baz!($0)", insert: "baz!($0)",
kind: Macro, kind: Macro,
detail: "#[macro_export]\nmacro_rules! baz", detail: "#[macro_export]\nmacro_rules! baz",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "foo!", label: "foo!",
@ -655,6 +666,7 @@ mod tests {
insert: "foo!($0)", insert: "foo!($0)",
kind: Macro, kind: Macro,
detail: "macro_rules! foo", detail: "macro_rules! foo",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "m1", label: "m1",
@ -678,6 +690,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
] ]
"### "###
@ -708,6 +721,7 @@ mod tests {
insert: "foo!($0)", insert: "foo!($0)",
kind: Macro, kind: Macro,
detail: "macro_rules! foo", detail: "macro_rules! foo",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "foo()", label: "foo()",
@ -717,6 +731,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo()", detail: "fn foo()",
deprecated: false,
}, },
] ]
"### "###
@ -747,6 +762,7 @@ mod tests {
insert: "foo!($0)", insert: "foo!($0)",
kind: Macro, kind: Macro,
detail: "macro_rules! foo", detail: "macro_rules! foo",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "main()", label: "main()",
@ -756,6 +772,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
] ]
"### "###
@ -786,6 +803,7 @@ mod tests {
insert: "foo!($0)", insert: "foo!($0)",
kind: Macro, kind: Macro,
detail: "macro_rules! foo", detail: "macro_rules! foo",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "main()", label: "main()",
@ -795,6 +813,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
] ]
"### "###

View file

@ -44,6 +44,9 @@ pub struct CompletionItem {
/// Additional info to show in the UI pop up. /// Additional info to show in the UI pop up.
detail: Option<String>, detail: Option<String>,
documentation: Option<Documentation>, documentation: Option<Documentation>,
/// Whether this item is marked as deprecated
deprecated: Option<bool>,
} }
// We use custom debug for CompletionItem to make `insta`'s diffs more readable. // We use custom debug for CompletionItem to make `insta`'s diffs more readable.
@ -70,6 +73,9 @@ impl fmt::Debug for CompletionItem {
if let Some(documentation) = self.documentation() { if let Some(documentation) = self.documentation() {
s.field("documentation", &documentation); s.field("documentation", &documentation);
} }
if let Some(deprecated) = self.deprecated {
s.field("deprecated", &deprecated);
}
s.finish() s.finish()
} }
} }
@ -132,6 +138,7 @@ impl CompletionItem {
lookup: None, lookup: None,
kind: None, kind: None,
text_edit: None, text_edit: None,
deprecated: None,
} }
} }
/// What user sees in pop-up in the UI. /// What user sees in pop-up in the UI.
@ -166,6 +173,10 @@ impl CompletionItem {
pub fn kind(&self) -> Option<CompletionItemKind> { pub fn kind(&self) -> Option<CompletionItemKind> {
self.kind self.kind
} }
pub fn deprecated(&self) -> Option<bool> {
self.deprecated
}
} }
/// A helper to make `CompletionItem`s. /// A helper to make `CompletionItem`s.
@ -181,6 +192,7 @@ pub(crate) struct Builder {
lookup: Option<String>, lookup: Option<String>,
kind: Option<CompletionItemKind>, kind: Option<CompletionItemKind>,
text_edit: Option<TextEdit>, text_edit: Option<TextEdit>,
deprecated: Option<bool>,
} }
impl Builder { impl Builder {
@ -208,6 +220,7 @@ impl Builder {
lookup: self.lookup, lookup: self.lookup,
kind: self.kind, kind: self.kind,
completion_kind: self.completion_kind, completion_kind: self.completion_kind,
deprecated: self.deprecated,
} }
} }
pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder { pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder {
@ -254,6 +267,10 @@ impl Builder {
self.documentation = docs.map(Into::into); self.documentation = docs.map(Into::into);
self self
} }
pub(crate) fn set_deprecated(mut self, deprecated: bool) -> Builder {
self.deprecated = Some(deprecated);
self
}
} }
impl<'a> Into<CompletionItem> for Builder { impl<'a> Into<CompletionItem> for Builder {

View file

@ -2,7 +2,7 @@
use hir::{db::HirDatabase, Docs, HasSource, HirDisplay, ScopeDef, Ty, TypeWalk}; use hir::{db::HirDatabase, Docs, HasSource, HirDisplay, ScopeDef, Ty, TypeWalk};
use join_to_string::join; use join_to_string::join;
use ra_syntax::ast::NameOwner; use ra_syntax::ast::{AttrsOwner, NameOwner};
use test_utils::tested_by; use test_utils::tested_by;
use crate::completion::{ use crate::completion::{
@ -18,6 +18,11 @@ impl Completions {
field: hir::StructField, field: hir::StructField,
substs: &hir::Substs, substs: &hir::Substs,
) { ) {
let ast_node = field.source(ctx.db).ast;
let is_deprecated = match ast_node {
hir::FieldSource::Named(m) => is_deprecated(m),
hir::FieldSource::Pos(m) => is_deprecated(m),
};
CompletionItem::new( CompletionItem::new(
CompletionKind::Reference, CompletionKind::Reference,
ctx.source_range(), ctx.source_range(),
@ -26,6 +31,7 @@ impl Completions {
.kind(CompletionItemKind::Field) .kind(CompletionItemKind::Field)
.detail(field.ty(ctx.db).subst(substs).display(ctx.db).to_string()) .detail(field.ty(ctx.db).subst(substs).display(ctx.db).to_string())
.set_documentation(field.docs(ctx.db)) .set_documentation(field.docs(ctx.db))
.set_deprecated(is_deprecated)
.add_to(self); .add_to(self);
} }
@ -179,6 +185,7 @@ impl Completions {
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), &macro_declaration) CompletionItem::new(CompletionKind::Reference, ctx.source_range(), &macro_declaration)
.kind(CompletionItemKind::Macro) .kind(CompletionItemKind::Macro)
.set_documentation(docs.clone()) .set_documentation(docs.clone())
.set_deprecated(is_deprecated(ast_node))
.detail(detail); .detail(detail);
builder = if ctx.use_item_syntax.is_some() { builder = if ctx.use_item_syntax.is_some() {
@ -211,6 +218,7 @@ impl Completions {
CompletionItemKind::Function CompletionItemKind::Function
}) })
.set_documentation(func.docs(ctx.db)) .set_documentation(func.docs(ctx.db))
.set_deprecated(is_deprecated(ast_node))
.detail(detail); .detail(detail);
// Add `<>` for generic types // Add `<>` for generic types
@ -242,6 +250,7 @@ impl Completions {
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string())
.kind(CompletionItemKind::Const) .kind(CompletionItemKind::Const)
.set_documentation(constant.docs(ctx.db)) .set_documentation(constant.docs(ctx.db))
.set_deprecated(is_deprecated(ast_node))
.detail(detail) .detail(detail)
.add_to(self); .add_to(self);
} }
@ -257,11 +266,13 @@ impl Completions {
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string())
.kind(CompletionItemKind::TypeAlias) .kind(CompletionItemKind::TypeAlias)
.set_documentation(type_alias.docs(ctx.db)) .set_documentation(type_alias.docs(ctx.db))
.set_deprecated(is_deprecated(type_def))
.detail(detail) .detail(detail)
.add_to(self); .add_to(self);
} }
pub(crate) fn add_enum_variant(&mut self, ctx: &CompletionContext, variant: hir::EnumVariant) { pub(crate) fn add_enum_variant(&mut self, ctx: &CompletionContext, variant: hir::EnumVariant) {
let is_deprecated = is_deprecated(variant.source(ctx.db).ast);
let name = match variant.name(ctx.db) { let name = match variant.name(ctx.db) {
Some(it) => it, Some(it) => it,
None => return, None => return,
@ -274,11 +285,16 @@ impl Completions {
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.to_string()) CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.to_string())
.kind(CompletionItemKind::EnumVariant) .kind(CompletionItemKind::EnumVariant)
.set_documentation(variant.docs(ctx.db)) .set_documentation(variant.docs(ctx.db))
.set_deprecated(is_deprecated)
.detail(detail) .detail(detail)
.add_to(self); .add_to(self);
} }
} }
fn is_deprecated(node: impl AttrsOwner) -> bool {
node.attrs().filter_map(|x| x.simple_name()).any(|x| x == "deprecated")
}
fn has_non_default_type_params(def: hir::GenericDef, db: &db::RootDatabase) -> bool { fn has_non_default_type_params(def: hir::GenericDef, db: &db::RootDatabase) -> bool {
let subst = db.generic_defaults(def); let subst = db.generic_defaults(def);
subst.iter().any(|ty| ty == &Ty::Unknown) subst.iter().any(|ty| ty == &Ty::Unknown)
@ -295,6 +311,57 @@ mod tests {
do_completion(code, CompletionKind::Reference) do_completion(code, CompletionKind::Reference)
} }
#[test]
fn sets_deprecated_flag_in_completion_items() {
assert_debug_snapshot!(
do_reference_completion(
r#"
#[deprecated]
fn something_deprecated() {}
#[deprecated(since = "1.0.0")]
fn something_else_deprecated() {}
fn main() { som<|> }
"#,
),
@r###"
[
CompletionItem {
label: "main()",
source_range: [203; 206),
delete: [203; 206),
insert: "main()$0",
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
CompletionItem {
label: "something_deprecated()",
source_range: [203; 206),
delete: [203; 206),
insert: "something_deprecated()$0",
kind: Function,
lookup: "something_deprecated",
detail: "fn something_deprecated()",
deprecated: true,
},
CompletionItem {
label: "something_else_deprecated()",
source_range: [203; 206),
delete: [203; 206),
insert: "something_else_deprecated()$0",
kind: Function,
lookup: "something_else_deprecated",
detail: "fn something_else_deprecated()",
deprecated: true,
},
]
"###
);
}
#[test] #[test]
fn inserts_parens_for_function_calls() { fn inserts_parens_for_function_calls() {
covers!(inserts_parens_for_function_calls); covers!(inserts_parens_for_function_calls);
@ -315,6 +382,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "no_args()", label: "no_args()",
@ -324,6 +392,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "no_args", lookup: "no_args",
detail: "fn no_args()", detail: "fn no_args()",
deprecated: false,
}, },
] ]
"### "###
@ -345,6 +414,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "main", lookup: "main",
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "with_args(…)", label: "with_args(…)",
@ -354,6 +424,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "with_args", lookup: "with_args",
detail: "fn with_args(x: i32, y: String)", detail: "fn with_args(x: i32, y: String)",
deprecated: false,
}, },
] ]
"### "###
@ -380,6 +451,7 @@ mod tests {
kind: Method, kind: Method,
lookup: "foo", lookup: "foo",
detail: "fn foo(&self)", detail: "fn foo(&self)",
deprecated: false,
}, },
] ]
"### "###
@ -404,6 +476,7 @@ mod tests {
insert: "foo", insert: "foo",
kind: Function, kind: Function,
detail: "pub fn foo()", detail: "pub fn foo()",
deprecated: false,
}, },
]"# ]"#
); );
@ -429,6 +502,7 @@ mod tests {
insert: "frobnicate", insert: "frobnicate",
kind: Function, kind: Function,
detail: "fn frobnicate()", detail: "fn frobnicate()",
deprecated: false,
}, },
CompletionItem { CompletionItem {
label: "main", label: "main",
@ -437,6 +511,7 @@ mod tests {
insert: "main", insert: "main",
kind: Function, kind: Function,
detail: "fn main()", detail: "fn main()",
deprecated: false,
}, },
]"# ]"#
); );
@ -459,6 +534,7 @@ mod tests {
insert: "new", insert: "new",
kind: Function, kind: Function,
detail: "fn new() -> Foo", detail: "fn new() -> Foo",
deprecated: false,
}, },
]"# ]"#
); );
@ -492,6 +568,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo(xs: Ve)", detail: "fn foo(xs: Ve)",
deprecated: false,
}, },
] ]
"### "###
@ -521,6 +598,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo(xs: Ve)", detail: "fn foo(xs: Ve)",
deprecated: false,
}, },
] ]
"### "###
@ -549,6 +627,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo(xs: Ve)", detail: "fn foo(xs: Ve)",
deprecated: false,
}, },
] ]
"### "###
@ -577,6 +656,7 @@ mod tests {
kind: Function, kind: Function,
lookup: "foo", lookup: "foo",
detail: "fn foo(xs: Ve<i128>)", detail: "fn foo(xs: Ve<i128>)",
deprecated: false,
}, },
] ]
"### "###
@ -607,6 +687,7 @@ mod tests {
insert: "frobnicate", insert: "frobnicate",
kind: Macro, kind: Macro,
detail: "#[macro_export]\nmacro_rules! frobnicate", detail: "#[macro_export]\nmacro_rules! frobnicate",
deprecated: false,
}, },
] ]
"### "###

View file

@ -127,6 +127,7 @@ impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem {
text_edit: Some(text_edit), text_edit: Some(text_edit),
additional_text_edits: Some(additional_text_edits), additional_text_edits: Some(additional_text_edits),
documentation: self.documentation().map(|it| it.conv()), documentation: self.documentation().map(|it| it.conv()),
deprecated: self.deprecated(),
..Default::default() ..Default::default()
}; };
res.insert_text_format = Some(match self.insert_text_format() { res.insert_text_format = Some(match self.insert_text_format() {