mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
Merge #811
811: Filter attributes from the completion details/label r=kjeremy a=lnicola Before: ![image](https://user-images.githubusercontent.com/308347/52657254-efba9a00-2f00-11e9-952f-901910cfc459.png) After: ![image](https://user-images.githubusercontent.com/308347/52657278-fb0dc580-2f00-11e9-9267-8aff44c93447.png) Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
61324a845b
@ -71,6 +71,7 @@ pub fn function_label(node: &ast::FnDef) -> Option<String> {
|
||||
.children()
|
||||
.filter(|child| !child.range().is_subrange(&body_range)) // Filter out body
|
||||
.filter(|child| ast::Comment::cast(child).is_none()) // Filter out comments
|
||||
.filter(|child| ast::Attr::cast(child).is_none()) // Filter out attributes
|
||||
.map(|node| node.text().to_string())
|
||||
.collect();
|
||||
label
|
||||
@ -86,6 +87,7 @@ pub fn const_label(node: &ast::ConstDef) -> String {
|
||||
.syntax()
|
||||
.children()
|
||||
.filter(|child| ast::Comment::cast(child).is_none())
|
||||
.filter(|child| ast::Attr::cast(child).is_none())
|
||||
.map(|node| node.text().to_string())
|
||||
.collect();
|
||||
|
||||
@ -97,6 +99,7 @@ pub fn type_label(node: &ast::TypeDef) -> String {
|
||||
.syntax()
|
||||
.children()
|
||||
.filter(|child| ast::Comment::cast(child).is_none())
|
||||
.filter(|child| ast::Attr::cast(child).is_none())
|
||||
.map(|node| node.text().to_string())
|
||||
.collect();
|
||||
|
||||
|
@ -179,6 +179,26 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_method_attr_filtering() {
|
||||
check_ref_completion(
|
||||
"method_attr_filtering",
|
||||
r"
|
||||
struct A {}
|
||||
impl A {
|
||||
#[inline]
|
||||
fn the_method(&self) {
|
||||
let x = 1;
|
||||
let y = 2;
|
||||
}
|
||||
}
|
||||
fn foo(a: A) {
|
||||
a.<|>
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tuple_field_completion() {
|
||||
check_ref_completion(
|
||||
|
@ -0,0 +1,26 @@
|
||||
---
|
||||
created: "2019-02-12T18:32:09.428929418Z"
|
||||
creator: insta@0.6.2
|
||||
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||
expression: kind_completions
|
||||
---
|
||||
[
|
||||
CompletionItem {
|
||||
completion_kind: Reference,
|
||||
label: "the_method",
|
||||
kind: Some(
|
||||
Method
|
||||
),
|
||||
detail: Some(
|
||||
"fn the_method(&self)"
|
||||
),
|
||||
documentation: None,
|
||||
lookup: None,
|
||||
insert_text: Some(
|
||||
"the_method()$0"
|
||||
),
|
||||
insert_text_format: Snippet,
|
||||
source_range: [249; 249),
|
||||
text_edit: None
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user