mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #4899
4899: don't complete top level attrs inside nested attrs and add better labels r=matklad a=bnjjj close #4890 Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
commit
d8842e89e9
1 changed files with 207 additions and 73 deletions
|
@ -20,6 +20,7 @@ pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
|
||||||
{
|
{
|
||||||
complete_derive(acc, ctx, token_tree)
|
complete_derive(acc, ctx, token_tree)
|
||||||
}
|
}
|
||||||
|
(_, Some(ast::AttrInput::TokenTree(_token_tree))) => {}
|
||||||
_ => complete_attribute_start(acc, ctx, attribute),
|
_ => complete_attribute_start(acc, ctx, attribute),
|
||||||
}
|
}
|
||||||
Some(())
|
Some(())
|
||||||
|
@ -34,6 +35,10 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr
|
||||||
)
|
)
|
||||||
.kind(CompletionItemKind::Attribute);
|
.kind(CompletionItemKind::Attribute);
|
||||||
|
|
||||||
|
if let Some(lookup) = attr_completion.lookup {
|
||||||
|
item = item.lookup_by(lookup);
|
||||||
|
}
|
||||||
|
|
||||||
match (attr_completion.snippet, ctx.config.snippet_cap) {
|
match (attr_completion.snippet, ctx.config.snippet_cap) {
|
||||||
(Some(snippet), Some(cap)) => {
|
(Some(snippet), Some(cap)) => {
|
||||||
item = item.insert_snippet(cap, snippet);
|
item = item.insert_snippet(cap, snippet);
|
||||||
|
@ -49,84 +54,160 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr
|
||||||
|
|
||||||
struct AttrCompletion {
|
struct AttrCompletion {
|
||||||
label: &'static str,
|
label: &'static str,
|
||||||
|
lookup: Option<&'static str>,
|
||||||
snippet: Option<&'static str>,
|
snippet: Option<&'static str>,
|
||||||
should_be_inner: bool,
|
should_be_inner: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ATTRIBUTES: &[AttrCompletion] = &[
|
const ATTRIBUTES: &[AttrCompletion] = &[
|
||||||
AttrCompletion { label: "allow", snippet: Some("allow(${0:lint})"), should_be_inner: false },
|
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "cfg_attr",
|
label: "allow(…)",
|
||||||
|
snippet: Some("allow(${0:lint})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("allow"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "cfg_attr(…)",
|
||||||
snippet: Some("cfg_attr(${1:predicate}, ${0:attr})"),
|
snippet: Some("cfg_attr(${1:predicate}, ${0:attr})"),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("cfg_attr"),
|
||||||
},
|
},
|
||||||
AttrCompletion { label: "cfg", snippet: Some("cfg(${0:predicate})"), should_be_inner: false },
|
|
||||||
AttrCompletion { label: "deny", snippet: Some("deny(${0:lint})"), should_be_inner: false },
|
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "deprecated",
|
label: "cfg(…)",
|
||||||
|
snippet: Some("cfg(${0:predicate})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("cfg"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "deny(…)",
|
||||||
|
snippet: Some("deny(${0:lint})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("deny"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: r#"deprecated = "…""#,
|
||||||
snippet: Some(r#"deprecated = "${0:reason}""#),
|
snippet: Some(r#"deprecated = "${0:reason}""#),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("deprecated"),
|
||||||
},
|
},
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "derive",
|
label: "derive(…)",
|
||||||
snippet: Some(r#"derive(${0:Debug})"#),
|
snippet: Some(r#"derive(${0:Debug})"#),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("derive"),
|
||||||
},
|
},
|
||||||
AttrCompletion { label: "doc", snippet: Some(r#"doc = "${0:docs}""#), should_be_inner: false },
|
|
||||||
AttrCompletion { label: "feature", snippet: Some("feature(${0:flag})"), should_be_inner: true },
|
|
||||||
AttrCompletion { label: "forbid", snippet: Some("forbid(${0:lint})"), should_be_inner: false },
|
|
||||||
// FIXME: resolve through macro resolution?
|
|
||||||
AttrCompletion { label: "global_allocator", snippet: None, should_be_inner: true },
|
|
||||||
AttrCompletion { label: "ignore", snippet: Some("ignore(${0:lint})"), should_be_inner: false },
|
|
||||||
AttrCompletion { label: "inline", snippet: Some("inline(${0:lint})"), should_be_inner: false },
|
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "link_name",
|
label: r#"doc = "…""#,
|
||||||
|
snippet: Some(r#"doc = "${0:docs}""#),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("doc"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "feature(…)",
|
||||||
|
snippet: Some("feature(${0:flag})"),
|
||||||
|
should_be_inner: true,
|
||||||
|
lookup: Some("feature"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "forbid(…)",
|
||||||
|
snippet: Some("forbid(${0:lint})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("forbid"),
|
||||||
|
},
|
||||||
|
// FIXME: resolve through macro resolution?
|
||||||
|
AttrCompletion {
|
||||||
|
label: "global_allocator",
|
||||||
|
snippet: None,
|
||||||
|
should_be_inner: true,
|
||||||
|
lookup: None,
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "ignore(…)",
|
||||||
|
snippet: Some("ignore(${0:lint})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("ignore"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "inline(…)",
|
||||||
|
snippet: Some("inline(${0:lint})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("inline"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: r#"link_name = "…""#,
|
||||||
snippet: Some(r#"link_name = "${0:symbol_name}""#),
|
snippet: Some(r#"link_name = "${0:symbol_name}""#),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("link_name"),
|
||||||
},
|
},
|
||||||
AttrCompletion { label: "link", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "link", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion { label: "macro_export", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "macro_export", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion { label: "macro_use", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "macro_use", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "must_use",
|
label: r#"must_use = "…""#,
|
||||||
snippet: Some(r#"must_use = "${0:reason}""#),
|
snippet: Some(r#"must_use = "${0:reason}""#),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("must_use"),
|
||||||
},
|
},
|
||||||
AttrCompletion { label: "no_mangle", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "no_mangle", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion { label: "no_std", snippet: None, should_be_inner: true },
|
AttrCompletion { label: "no_std", snippet: None, should_be_inner: true, lookup: None },
|
||||||
AttrCompletion { label: "non_exhaustive", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "non_exhaustive", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion { label: "panic_handler", snippet: None, should_be_inner: true },
|
AttrCompletion { label: "panic_handler", snippet: None, should_be_inner: true, lookup: None },
|
||||||
AttrCompletion { label: "path", snippet: Some("path =\"${0:path}\""), should_be_inner: false },
|
|
||||||
AttrCompletion { label: "proc_macro", snippet: None, should_be_inner: false },
|
|
||||||
AttrCompletion { label: "proc_macro_attribute", snippet: None, should_be_inner: false },
|
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "proc_macro_derive",
|
label: "path = \"…\"",
|
||||||
|
snippet: Some("path =\"${0:path}\""),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("path"),
|
||||||
|
},
|
||||||
|
AttrCompletion { label: "proc_macro", snippet: None, should_be_inner: false, lookup: None },
|
||||||
|
AttrCompletion {
|
||||||
|
label: "proc_macro_attribute",
|
||||||
|
snippet: None,
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: None,
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "proc_macro_derive(…)",
|
||||||
snippet: Some("proc_macro_derive(${0:Trait})"),
|
snippet: Some("proc_macro_derive(${0:Trait})"),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("proc_macro_derive"),
|
||||||
},
|
},
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "recursion_limit",
|
label: "recursion_limit = …",
|
||||||
snippet: Some("recursion_limit = ${0:128}"),
|
snippet: Some("recursion_limit = ${0:128}"),
|
||||||
should_be_inner: true,
|
should_be_inner: true,
|
||||||
|
lookup: Some("recursion_limit"),
|
||||||
},
|
},
|
||||||
AttrCompletion { label: "repr", snippet: Some("repr(${0:C})"), should_be_inner: false },
|
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "should_panic",
|
label: "repr(…)",
|
||||||
|
snippet: Some("repr(${0:C})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("repr"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: "should_panic(…)",
|
||||||
snippet: Some(r#"should_panic(expected = "${0:reason}")"#),
|
snippet: Some(r#"should_panic(expected = "${0:reason}")"#),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("should_panic"),
|
||||||
},
|
},
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "target_feature",
|
label: r#"target_feature = "…""#,
|
||||||
snippet: Some("target_feature = \"${0:feature}\""),
|
snippet: Some("target_feature = \"${0:feature}\""),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
|
lookup: Some("target_feature"),
|
||||||
},
|
},
|
||||||
AttrCompletion { label: "test", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "test", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion { label: "used", snippet: None, should_be_inner: false },
|
AttrCompletion { label: "used", snippet: None, should_be_inner: false, lookup: None },
|
||||||
AttrCompletion { label: "warn", snippet: Some("warn(${0:lint})"), should_be_inner: false },
|
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "windows_subsystem",
|
label: "warn(…)",
|
||||||
|
snippet: Some("warn(${0:lint})"),
|
||||||
|
should_be_inner: false,
|
||||||
|
lookup: Some("warn"),
|
||||||
|
},
|
||||||
|
AttrCompletion {
|
||||||
|
label: r#"windows_subsystem = "…""#,
|
||||||
snippet: Some(r#"windows_subsystem = "${0:subsystem}""#),
|
snippet: Some(r#"windows_subsystem = "${0:subsystem}""#),
|
||||||
should_be_inner: true,
|
should_be_inner: true,
|
||||||
|
lookup: Some("windows_subsystem"),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -414,74 +495,84 @@ mod tests {
|
||||||
@r###"
|
@r###"
|
||||||
[
|
[
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "allow",
|
label: "allow(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "allow(${0:lint})",
|
insert: "allow(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "allow",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "cfg",
|
label: "cfg(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "cfg(${0:predicate})",
|
insert: "cfg(${0:predicate})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "cfg",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "cfg_attr",
|
label: "cfg_attr(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "cfg_attr(${1:predicate}, ${0:attr})",
|
insert: "cfg_attr(${1:predicate}, ${0:attr})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "cfg_attr",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "deny",
|
label: "deny(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "deny(${0:lint})",
|
insert: "deny(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "deny",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "deprecated",
|
label: "deprecated = \"…\"",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "deprecated = \"${0:reason}\"",
|
insert: "deprecated = \"${0:reason}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "deprecated",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "derive",
|
label: "derive(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "derive(${0:Debug})",
|
insert: "derive(${0:Debug})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "derive",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "doc",
|
label: "doc = \"…\"",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "doc = \"${0:docs}\"",
|
insert: "doc = \"${0:docs}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "doc",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "forbid",
|
label: "forbid(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "forbid(${0:lint})",
|
insert: "forbid(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "forbid",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "ignore",
|
label: "ignore(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "ignore(${0:lint})",
|
insert: "ignore(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "ignore",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "inline",
|
label: "inline(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "inline(${0:lint})",
|
insert: "inline(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "inline",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "link",
|
label: "link",
|
||||||
|
@ -491,11 +582,12 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "link_name",
|
label: "link_name = \"…\"",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "link_name = \"${0:symbol_name}\"",
|
insert: "link_name = \"${0:symbol_name}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "link_name",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "macro_export",
|
label: "macro_export",
|
||||||
|
@ -512,11 +604,12 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "must_use",
|
label: "must_use = \"…\"",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "must_use = \"${0:reason}\"",
|
insert: "must_use = \"${0:reason}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "must_use",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "no_mangle",
|
label: "no_mangle",
|
||||||
|
@ -533,11 +626,12 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "path",
|
label: "path = \"…\"",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "path =\"${0:path}\"",
|
insert: "path =\"${0:path}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "path",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "proc_macro",
|
label: "proc_macro",
|
||||||
|
@ -554,32 +648,36 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "proc_macro_derive",
|
label: "proc_macro_derive(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "proc_macro_derive(${0:Trait})",
|
insert: "proc_macro_derive(${0:Trait})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "proc_macro_derive",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "repr",
|
label: "repr(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "repr(${0:C})",
|
insert: "repr(${0:C})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "repr",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "should_panic",
|
label: "should_panic(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "should_panic(expected = \"${0:reason}\")",
|
insert: "should_panic(expected = \"${0:reason}\")",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "should_panic",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "target_feature",
|
label: "target_feature = \"…\"",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "target_feature = \"${0:feature}\"",
|
insert: "target_feature = \"${0:feature}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "target_feature",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "test",
|
label: "test",
|
||||||
|
@ -596,17 +694,32 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "warn",
|
label: "warn(…)",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "warn(${0:lint})",
|
insert: "warn(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "warn",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_attribute_completion_inside_nested_attr() {
|
||||||
|
assert_debug_snapshot!(
|
||||||
|
do_attr_completion(
|
||||||
|
r"
|
||||||
|
#[allow(<|>)]
|
||||||
|
",
|
||||||
|
),
|
||||||
|
@r###"
|
||||||
|
[]
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_inner_attribute_completion() {
|
fn test_inner_attribute_completion() {
|
||||||
assert_debug_snapshot!(
|
assert_debug_snapshot!(
|
||||||
|
@ -618,67 +731,76 @@ mod tests {
|
||||||
@r###"
|
@r###"
|
||||||
[
|
[
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "allow",
|
label: "allow(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "allow(${0:lint})",
|
insert: "allow(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "allow",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "cfg",
|
label: "cfg(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "cfg(${0:predicate})",
|
insert: "cfg(${0:predicate})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "cfg",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "cfg_attr",
|
label: "cfg_attr(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "cfg_attr(${1:predicate}, ${0:attr})",
|
insert: "cfg_attr(${1:predicate}, ${0:attr})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "cfg_attr",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "deny",
|
label: "deny(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "deny(${0:lint})",
|
insert: "deny(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "deny",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "deprecated",
|
label: "deprecated = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "deprecated = \"${0:reason}\"",
|
insert: "deprecated = \"${0:reason}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "deprecated",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "derive",
|
label: "derive(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "derive(${0:Debug})",
|
insert: "derive(${0:Debug})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "derive",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "doc",
|
label: "doc = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "doc = \"${0:docs}\"",
|
insert: "doc = \"${0:docs}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "doc",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "feature",
|
label: "feature(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "feature(${0:flag})",
|
insert: "feature(${0:flag})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "feature",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "forbid",
|
label: "forbid(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "forbid(${0:lint})",
|
insert: "forbid(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "forbid",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "global_allocator",
|
label: "global_allocator",
|
||||||
|
@ -688,18 +810,20 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "ignore",
|
label: "ignore(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "ignore(${0:lint})",
|
insert: "ignore(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "ignore",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "inline",
|
label: "inline(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "inline(${0:lint})",
|
insert: "inline(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "inline",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "link",
|
label: "link",
|
||||||
|
@ -709,11 +833,12 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "link_name",
|
label: "link_name = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "link_name = \"${0:symbol_name}\"",
|
insert: "link_name = \"${0:symbol_name}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "link_name",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "macro_export",
|
label: "macro_export",
|
||||||
|
@ -730,11 +855,12 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "must_use",
|
label: "must_use = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "must_use = \"${0:reason}\"",
|
insert: "must_use = \"${0:reason}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "must_use",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "no_mangle",
|
label: "no_mangle",
|
||||||
|
@ -765,11 +891,12 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "path",
|
label: "path = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "path =\"${0:path}\"",
|
insert: "path =\"${0:path}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "path",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "proc_macro",
|
label: "proc_macro",
|
||||||
|
@ -786,39 +913,44 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "proc_macro_derive",
|
label: "proc_macro_derive(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "proc_macro_derive(${0:Trait})",
|
insert: "proc_macro_derive(${0:Trait})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "proc_macro_derive",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "recursion_limit",
|
label: "recursion_limit = …",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "recursion_limit = ${0:128}",
|
insert: "recursion_limit = ${0:128}",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "recursion_limit",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "repr",
|
label: "repr(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "repr(${0:C})",
|
insert: "repr(${0:C})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "repr",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "should_panic",
|
label: "should_panic(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "should_panic(expected = \"${0:reason}\")",
|
insert: "should_panic(expected = \"${0:reason}\")",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "should_panic",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "target_feature",
|
label: "target_feature = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "target_feature = \"${0:feature}\"",
|
insert: "target_feature = \"${0:feature}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "target_feature",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "test",
|
label: "test",
|
||||||
|
@ -835,18 +967,20 @@ mod tests {
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "warn",
|
label: "warn(…)",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "warn(${0:lint})",
|
insert: "warn(${0:lint})",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "warn",
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
label: "windows_subsystem",
|
label: "windows_subsystem = \"…\"",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "windows_subsystem = \"${0:subsystem}\"",
|
insert: "windows_subsystem = \"${0:subsystem}\"",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
|
lookup: "windows_subsystem",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
"###
|
"###
|
||||||
|
|
Loading…
Reference in a new issue