diff options
author | Lukas Wirth <[email protected]> | 2021-06-16 17:50:18 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-16 20:51:21 +0100 |
commit | 11115ebad8d0cb367478a4f154abe08c0c25aa95 (patch) | |
tree | d4260c26782bc61c904c0d78707ea74830bbbfbe /crates/ide_completion/src/tests | |
parent | 9ea6ee6b2785da02ff1963fbbc2eea340450905c (diff) |
Don't complete paths after attributes
Diffstat (limited to 'crates/ide_completion/src/tests')
-rw-r--r-- | crates/ide_completion/src/tests/item_list.rs | 141 |
1 files changed, 100 insertions, 41 deletions
diff --git a/crates/ide_completion/src/tests/item_list.rs b/crates/ide_completion/src/tests/item_list.rs index c8aa44d88..33b23b8b4 100644 --- a/crates/ide_completion/src/tests/item_list.rs +++ b/crates/ide_completion/src/tests/item_list.rs | |||
@@ -9,7 +9,7 @@ fn in_mod_item_list() { | |||
9 | $0 | 9 | $0 |
10 | } | 10 | } |
11 | "#, | 11 | "#, |
12 | expect![[r#" | 12 | expect![[r##" |
13 | kw pub(crate) | 13 | kw pub(crate) |
14 | kw pub | 14 | kw pub |
15 | kw unsafe | 15 | kw unsafe |
@@ -28,22 +28,15 @@ fn in_mod_item_list() { | |||
28 | sn tmod (Test module) | 28 | sn tmod (Test module) |
29 | sn tfn (Test function) | 29 | sn tfn (Test function) |
30 | sn macro_rules | 30 | sn macro_rules |
31 | "#]], | 31 | ma foo!(…) #[macro_export] macro_rules! foo |
32 | "##]], | ||
32 | ) | 33 | ) |
33 | } | 34 | } |
34 | 35 | ||
35 | #[test] | 36 | #[test] |
36 | fn in_source_file_item_list() { | 37 | fn in_source_file_item_list() { |
37 | check( | 38 | check( |
38 | r#" | 39 | r#"$0"#, |
39 | enum Enum { Variant } | ||
40 | struct MyStruct {} | ||
41 | #[macro_export] | ||
42 | macro_rules! foo {} | ||
43 | mod bar {} | ||
44 | const CONST: () = (); | ||
45 | |||
46 | $0"#, | ||
47 | expect![[r##" | 40 | expect![[r##" |
48 | kw pub(crate) | 41 | kw pub(crate) |
49 | kw pub | 42 | kw pub |
@@ -71,18 +64,10 @@ $0"#, | |||
71 | } | 64 | } |
72 | 65 | ||
73 | #[test] | 66 | #[test] |
74 | fn in_qualified_path() { | 67 | fn in_item_list_after_attr() { |
75 | check( | 68 | check( |
76 | r#" | 69 | r#"#[attr] $0"#, |
77 | enum Enum { Variant } | 70 | expect![[r#" |
78 | struct MyStruct {} | ||
79 | #[macro_export] | ||
80 | macro_rules! foo {} | ||
81 | mod bar {} | ||
82 | const CONST: () = (); | ||
83 | |||
84 | crate::$0"#, | ||
85 | expect![[r##" | ||
86 | kw pub(crate) | 71 | kw pub(crate) |
87 | kw pub | 72 | kw pub |
88 | kw unsafe | 73 | kw unsafe |
@@ -101,8 +86,32 @@ crate::$0"#, | |||
101 | sn tmod (Test module) | 86 | sn tmod (Test module) |
102 | sn tfn (Test function) | 87 | sn tfn (Test function) |
103 | sn macro_rules | 88 | sn macro_rules |
89 | "#]], | ||
90 | ) | ||
91 | } | ||
92 | |||
93 | #[test] | ||
94 | fn in_qualified_path() { | ||
95 | check( | ||
96 | r#"crate::$0"#, | ||
97 | expect![[r##" | ||
98 | kw pub(crate) | ||
99 | kw pub | ||
100 | kw unsafe | ||
101 | kw fn | ||
102 | kw const | ||
103 | kw type | ||
104 | kw impl | ||
105 | kw extern | ||
106 | kw use | ||
107 | kw trait | ||
108 | kw static | ||
109 | kw mod | ||
110 | kw enum | ||
111 | kw struct | ||
112 | kw union | ||
104 | md bar | 113 | md bar |
105 | ma foo!(…) #[macro_export] macro_rules! foo | 114 | ma foo!(…) #[macro_export] macro_rules! foo |
106 | "##]], | 115 | "##]], |
107 | ) | 116 | ) |
108 | } | 117 | } |
@@ -110,15 +119,7 @@ crate::$0"#, | |||
110 | #[test] | 119 | #[test] |
111 | fn after_unsafe_token() { | 120 | fn after_unsafe_token() { |
112 | check( | 121 | check( |
113 | r#" | 122 | r#"unsafe $0"#, |
114 | enum Enum { Variant } | ||
115 | struct MyStruct {} | ||
116 | #[macro_export] | ||
117 | macro_rules! foo {} | ||
118 | mod bar {} | ||
119 | const CONST: () = (); | ||
120 | |||
121 | unsafe $0"#, | ||
122 | expect![[r#" | 123 | expect![[r#" |
123 | kw fn | 124 | kw fn |
124 | kw trait | 125 | kw trait |
@@ -130,15 +131,7 @@ unsafe $0"#, | |||
130 | #[test] | 131 | #[test] |
131 | fn after_visibility() { | 132 | fn after_visibility() { |
132 | check( | 133 | check( |
133 | r#" | 134 | r#"pub $0"#, |
134 | enum Enum { Variant } | ||
135 | struct MyStruct {} | ||
136 | #[macro_export] | ||
137 | macro_rules! foo {} | ||
138 | mod bar {} | ||
139 | const CONST: () = (); | ||
140 | |||
141 | pub $0"#, | ||
142 | expect![[r#" | 135 | expect![[r#" |
143 | kw unsafe | 136 | kw unsafe |
144 | kw fn | 137 | kw fn |
@@ -154,3 +147,69 @@ pub $0"#, | |||
154 | "#]], | 147 | "#]], |
155 | ); | 148 | ); |
156 | } | 149 | } |
150 | |||
151 | #[test] | ||
152 | fn after_visibility_unsafe() { | ||
153 | // FIXME this shouldn't show `impl` | ||
154 | check( | ||
155 | r#"pub unsafe $0"#, | ||
156 | expect![[r#" | ||
157 | kw fn | ||
158 | kw trait | ||
159 | kw impl | ||
160 | "#]], | ||
161 | ); | ||
162 | } | ||
163 | |||
164 | #[test] | ||
165 | fn in_impl_assoc_item_list() { | ||
166 | check( | ||
167 | r#"impl Struct { | ||
168 | $0 | ||
169 | }"#, | ||
170 | expect![[r##" | ||
171 | kw pub(crate) | ||
172 | kw pub | ||
173 | kw unsafe | ||
174 | kw fn | ||
175 | kw const | ||
176 | kw type | ||
177 | md bar | ||
178 | ma foo!(…) #[macro_export] macro_rules! foo | ||
179 | ma foo!(…) #[macro_export] macro_rules! foo | ||
180 | "##]], | ||
181 | ) | ||
182 | } | ||
183 | |||
184 | #[test] | ||
185 | fn in_impl_assoc_item_list_after_attr() { | ||
186 | check( | ||
187 | r#"impl Struct { | ||
188 | #[attr] $0 | ||
189 | }"#, | ||
190 | expect![[r#" | ||
191 | kw pub(crate) | ||
192 | kw pub | ||
193 | kw unsafe | ||
194 | kw fn | ||
195 | kw const | ||
196 | kw type | ||
197 | "#]], | ||
198 | ) | ||
199 | } | ||
200 | |||
201 | #[test] | ||
202 | fn in_trait_assoc_item_list() { | ||
203 | check( | ||
204 | r"trait Foo { $0 }", | ||
205 | expect![[r##" | ||
206 | kw unsafe | ||
207 | kw fn | ||
208 | kw const | ||
209 | kw type | ||
210 | md bar | ||
211 | ma foo!(…) #[macro_export] macro_rules! foo | ||
212 | ma foo!(…) #[macro_export] macro_rules! foo | ||
213 | "##]], | ||
214 | ); | ||
215 | } | ||