File tree Expand file tree Collapse file tree 1 file changed +78
-0
lines changed
crates/ra_ide/src/completion Expand file tree Collapse file tree 1 file changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -283,4 +283,82 @@ mod tests {
283283 ]
284284 "### ) ;
285285 }
286+
287+ #[ test]
288+ fn associated_type ( ) {
289+ let completions = complete (
290+ r"
291+ trait Test {
292+ type SomeType;
293+ }
294+
295+ impl Test for () {
296+ <|>
297+ }
298+ " ,
299+ ) ;
300+ assert_debug_snapshot ! ( completions, @r###"
301+ [
302+ CompletionItem {
303+ label: "type SomeType = ",
304+ source_range: [119; 119),
305+ delete: [119; 119),
306+ insert: "type SomeType = ",
307+ kind: TypeAlias,
308+ },
309+ ]
310+ "### ) ;
311+ }
312+
313+ #[ test]
314+ fn associated_const ( ) {
315+ let completions = complete (
316+ r"
317+ trait Test {
318+ const SOME_CONST: u16;
319+ }
320+
321+ impl Test for () {
322+ <|>
323+ }
324+ " ,
325+ ) ;
326+ assert_debug_snapshot ! ( completions, @r###"
327+ [
328+ CompletionItem {
329+ label: "const SOME_CONST: u16 = ",
330+ source_range: [127; 127),
331+ delete: [127; 127),
332+ insert: "const SOME_CONST: u16 = ",
333+ kind: Const,
334+ },
335+ ]
336+ "### ) ;
337+ }
338+
339+ #[ test]
340+ fn associated_const_with_default ( ) {
341+ let completions = complete (
342+ r"
343+ trait Test {
344+ const SOME_CONST: u16 = 42;
345+ }
346+
347+ impl Test for () {
348+ <|>
349+ }
350+ " ,
351+ ) ;
352+ assert_debug_snapshot ! ( completions, @r###"
353+ [
354+ CompletionItem {
355+ label: "const SOME_CONST: u16 = ",
356+ source_range: [132; 132),
357+ delete: [132; 132),
358+ insert: "const SOME_CONST: u16 = ",
359+ kind: Const,
360+ },
361+ ]
362+ "### ) ;
363+ }
286364}
You can’t perform that action at this time.
0 commit comments