File tree 3 files changed +49
-0
lines changed
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ pub fn function_label(node: &ast::FnDef) -> Option<String> {
71
71
. children ( )
72
72
. filter ( |child| !child. range ( ) . is_subrange ( & body_range) ) // Filter out body
73
73
. filter ( |child| ast:: Comment :: cast ( child) . is_none ( ) ) // Filter out comments
74
+ . filter ( |child| ast:: Attr :: cast ( child) . is_none ( ) ) // Filter out attributes
74
75
. map ( |node| node. text ( ) . to_string ( ) )
75
76
. collect ( ) ;
76
77
label
@@ -86,6 +87,7 @@ pub fn const_label(node: &ast::ConstDef) -> String {
86
87
. syntax ( )
87
88
. children ( )
88
89
. filter ( |child| ast:: Comment :: cast ( child) . is_none ( ) )
90
+ . filter ( |child| ast:: Attr :: cast ( child) . is_none ( ) )
89
91
. map ( |node| node. text ( ) . to_string ( ) )
90
92
. collect ( ) ;
91
93
@@ -97,6 +99,7 @@ pub fn type_label(node: &ast::TypeDef) -> String {
97
99
. syntax ( )
98
100
. children ( )
99
101
. filter ( |child| ast:: Comment :: cast ( child) . is_none ( ) )
102
+ . filter ( |child| ast:: Attr :: cast ( child) . is_none ( ) )
100
103
. map ( |node| node. text ( ) . to_string ( ) )
101
104
. collect ( ) ;
102
105
Original file line number Diff line number Diff line change @@ -179,6 +179,26 @@ mod tests {
179
179
) ;
180
180
}
181
181
182
+ #[ test]
183
+ fn test_method_attr_filtering ( ) {
184
+ check_ref_completion (
185
+ "method_attr_filtering" ,
186
+ r"
187
+ struct A {}
188
+ impl A {
189
+ #[inline]
190
+ fn the_method(&self) {
191
+ let x = 1;
192
+ let y = 2;
193
+ }
194
+ }
195
+ fn foo(a: A) {
196
+ a.<|>
197
+ }
198
+ " ,
199
+ ) ;
200
+ }
201
+
182
202
#[ test]
183
203
fn test_tuple_field_completion ( ) {
184
204
check_ref_completion (
Original file line number Diff line number Diff line change
1
+ -- -
2
+ created : " 2019-02-12T18:32:09.428929418Z"
3
+ creator : insta @0.6 .2
4
+ source : crates / ra_ide_api / src / completion / completion_item .rs
5
+ expression : kind_completions
6
+ -- -
7
+ [
8
+ CompletionItem {
9
+ completion_kind: Reference ,
10
+ label: " the_method" ,
11
+ kind: Some (
12
+ Method
13
+ ),
14
+ detail: Some (
15
+ " fn the_method(&self)"
16
+ ),
17
+ documentation: None ,
18
+ lookup: None ,
19
+ insert_text: Some (
20
+ " the_method()$0"
21
+ ),
22
+ insert_text_format: Snippet ,
23
+ source_range: [249 ; 249 ),
24
+ text_edit : None
25
+ }
26
+ ]
You can’t perform that action at this time.
0 commit comments