diff options
Diffstat (limited to 'crates/ra_ide_api')
34 files changed, 568 insertions, 363 deletions
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index 79e473463..908899129 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml | |||
@@ -15,6 +15,9 @@ rustc-hash = "1.0" | |||
15 | parking_lot = "0.7.0" | 15 | parking_lot = "0.7.0" |
16 | unicase = "2.2.0" | 16 | unicase = "2.2.0" |
17 | 17 | ||
18 | jemallocator = { version = "0.1.9", optional = true } | ||
19 | jemalloc-ctl = { version = "0.2.0", optional = true } | ||
20 | |||
18 | ra_syntax = { path = "../ra_syntax" } | 21 | ra_syntax = { path = "../ra_syntax" } |
19 | ra_ide_api_light = { path = "../ra_ide_api_light" } | 22 | ra_ide_api_light = { path = "../ra_ide_api_light" } |
20 | ra_text_edit = { path = "../ra_text_edit" } | 23 | ra_text_edit = { path = "../ra_text_edit" } |
@@ -24,3 +27,6 @@ test_utils = { path = "../test_utils" } | |||
24 | 27 | ||
25 | [dev-dependencies] | 28 | [dev-dependencies] |
26 | insta = "0.5.1" | 29 | insta = "0.5.1" |
30 | |||
31 | [features] | ||
32 | jemalloc = [ "jemallocator", "jemalloc-ctl" ] | ||
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index ee1e13799..2eb388e0e 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -3,9 +3,10 @@ use ra_db::SourceDatabase; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | AstNode, SyntaxNode, TextUnit, TextRange, | 4 | AstNode, SyntaxNode, TextUnit, TextRange, |
5 | SyntaxKind::FN_DEF, | 5 | SyntaxKind::FN_DEF, |
6 | ast::{self, ArgListOwner, DocCommentsOwner}, | 6 | ast::{self, ArgListOwner}, |
7 | algo::find_node_at_offset, | 7 | algo::find_node_at_offset, |
8 | }; | 8 | }; |
9 | use hir::Docs; | ||
9 | 10 | ||
10 | use crate::{FilePosition, CallInfo, db::RootDatabase}; | 11 | use crate::{FilePosition, CallInfo, db::RootDatabase}; |
11 | 12 | ||
@@ -26,7 +27,9 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
26 | let fn_file = db.parse(symbol.file_id); | 27 | let fn_file = db.parse(symbol.file_id); |
27 | let fn_def = symbol.ptr.to_node(&fn_file); | 28 | let fn_def = symbol.ptr.to_node(&fn_file); |
28 | let fn_def = ast::FnDef::cast(fn_def).unwrap(); | 29 | let fn_def = ast::FnDef::cast(fn_def).unwrap(); |
29 | let mut call_info = CallInfo::new(fn_def)?; | 30 | let function = hir::source_binder::function_from_source(db, symbol.file_id, fn_def)?; |
31 | |||
32 | let mut call_info = CallInfo::new(db, function, fn_def)?; | ||
30 | // If we have a calling expression let's find which argument we are on | 33 | // If we have a calling expression let's find which argument we are on |
31 | let num_params = call_info.parameters.len(); | 34 | let num_params = call_info.parameters.len(); |
32 | let has_self = fn_def.param_list().and_then(|l| l.self_param()).is_some(); | 35 | let has_self = fn_def.param_list().and_then(|l| l.self_param()).is_some(); |
@@ -110,46 +113,13 @@ impl<'a> FnCallNode<'a> { | |||
110 | } | 113 | } |
111 | 114 | ||
112 | impl CallInfo { | 115 | impl CallInfo { |
113 | fn new(node: &ast::FnDef) -> Option<Self> { | 116 | fn new(db: &RootDatabase, function: hir::Function, node: &ast::FnDef) -> Option<Self> { |
114 | let label: String = if let Some(body) = node.body() { | 117 | let label = crate::completion::function_label(node)?; |
115 | let body_range = body.syntax().range(); | 118 | let doc = function.docs(db); |
116 | let label: String = node | ||
117 | .syntax() | ||
118 | .children() | ||
119 | .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body | ||
120 | .filter(|child| ast::Comment::cast(child).is_none()) // Filter out doc comments | ||
121 | .map(|node| node.text().to_string()) | ||
122 | .collect(); | ||
123 | label | ||
124 | } else { | ||
125 | node.syntax().text().to_string() | ||
126 | }; | ||
127 | |||
128 | let mut doc = None; | ||
129 | if let Some(docs) = node.doc_comment_text() { | ||
130 | // Massage markdown | ||
131 | let mut processed_lines = Vec::new(); | ||
132 | let mut in_code_block = false; | ||
133 | for line in docs.lines() { | ||
134 | if line.starts_with("```") { | ||
135 | in_code_block = !in_code_block; | ||
136 | } | ||
137 | |||
138 | let line = if in_code_block && line.starts_with("```") && !line.contains("rust") { | ||
139 | "```rust".into() | ||
140 | } else { | ||
141 | line.to_string() | ||
142 | }; | ||
143 | |||
144 | processed_lines.push(line); | ||
145 | } | ||
146 | |||
147 | doc = Some(processed_lines.join("\n")); | ||
148 | } | ||
149 | 119 | ||
150 | Some(CallInfo { | 120 | Some(CallInfo { |
151 | parameters: param_list(node), | 121 | parameters: param_list(node), |
152 | label: label.trim().to_owned(), | 122 | label, |
153 | doc, | 123 | doc, |
154 | active_parameter: None, | 124 | active_parameter: None, |
155 | }) | 125 | }) |
@@ -284,7 +254,7 @@ fn bar() { | |||
284 | assert_eq!(info.parameters, vec!["j".to_string()]); | 254 | assert_eq!(info.parameters, vec!["j".to_string()]); |
285 | assert_eq!(info.active_parameter, Some(0)); | 255 | assert_eq!(info.active_parameter, Some(0)); |
286 | assert_eq!(info.label, "fn foo(j: u32) -> u32".to_string()); | 256 | assert_eq!(info.label, "fn foo(j: u32) -> u32".to_string()); |
287 | assert_eq!(info.doc, Some("test".into())); | 257 | assert_eq!(info.doc.map(|it| it.into()), Some("test".to_string())); |
288 | } | 258 | } |
289 | 259 | ||
290 | #[test] | 260 | #[test] |
@@ -313,18 +283,18 @@ pub fn do() { | |||
313 | assert_eq!(info.active_parameter, Some(0)); | 283 | assert_eq!(info.active_parameter, Some(0)); |
314 | assert_eq!(info.label, "pub fn add_one(x: i32) -> i32".to_string()); | 284 | assert_eq!(info.label, "pub fn add_one(x: i32) -> i32".to_string()); |
315 | assert_eq!( | 285 | assert_eq!( |
316 | info.doc, | 286 | info.doc.map(|it| it.into()), |
317 | Some( | 287 | Some( |
318 | r#"Adds one to the number given. | 288 | r#"Adds one to the number given. |
319 | 289 | ||
320 | # Examples | 290 | # Examples |
321 | 291 | ||
322 | ```rust | 292 | ``` |
323 | let five = 5; | 293 | let five = 5; |
324 | 294 | ||
325 | assert_eq!(6, my_crate::add_one(5)); | 295 | assert_eq!(6, my_crate::add_one(5)); |
326 | ```"# | 296 | ```"# |
327 | .into() | 297 | .to_string() |
328 | ) | 298 | ) |
329 | ); | 299 | ); |
330 | } | 300 | } |
@@ -359,18 +329,18 @@ pub fn do_it() { | |||
359 | assert_eq!(info.active_parameter, Some(0)); | 329 | assert_eq!(info.active_parameter, Some(0)); |
360 | assert_eq!(info.label, "pub fn add_one(x: i32) -> i32".to_string()); | 330 | assert_eq!(info.label, "pub fn add_one(x: i32) -> i32".to_string()); |
361 | assert_eq!( | 331 | assert_eq!( |
362 | info.doc, | 332 | info.doc.map(|it| it.into()), |
363 | Some( | 333 | Some( |
364 | r#"Adds one to the number given. | 334 | r#"Adds one to the number given. |
365 | 335 | ||
366 | # Examples | 336 | # Examples |
367 | 337 | ||
368 | ```rust | 338 | ``` |
369 | let five = 5; | 339 | let five = 5; |
370 | 340 | ||
371 | assert_eq!(6, my_crate::add_one(5)); | 341 | assert_eq!(6, my_crate::add_one(5)); |
372 | ```"# | 342 | ```"# |
373 | .into() | 343 | .to_string() |
374 | ) | 344 | ) |
375 | ); | 345 | ); |
376 | } | 346 | } |
@@ -414,12 +384,12 @@ pub fn foo() { | |||
414 | ); | 384 | ); |
415 | assert_eq!(info.active_parameter, Some(1)); | 385 | assert_eq!(info.active_parameter, Some(1)); |
416 | assert_eq!( | 386 | assert_eq!( |
417 | info.doc, | 387 | info.doc.map(|it| it.into()), |
418 | Some( | 388 | Some( |
419 | r#"Method is called when writer finishes. | 389 | r#"Method is called when writer finishes. |
420 | 390 | ||
421 | By default this method stops actor's `Context`."# | 391 | By default this method stops actor's `Context`."# |
422 | .into() | 392 | .to_string() |
423 | ) | 393 | ) |
424 | ); | 394 | ); |
425 | } | 395 | } |
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index b1867de42..722d94f3a 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs | |||
@@ -10,6 +10,7 @@ mod complete_scope; | |||
10 | mod complete_postfix; | 10 | mod complete_postfix; |
11 | 11 | ||
12 | use ra_db::SourceDatabase; | 12 | use ra_db::SourceDatabase; |
13 | use ra_syntax::ast::{self, AstNode}; | ||
13 | 14 | ||
14 | use crate::{ | 15 | use crate::{ |
15 | db, | 16 | db, |
@@ -61,3 +62,21 @@ pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Opti | |||
61 | complete_postfix::complete_postfix(&mut acc, &ctx); | 62 | complete_postfix::complete_postfix(&mut acc, &ctx); |
62 | Some(acc) | 63 | Some(acc) |
63 | } | 64 | } |
65 | |||
66 | pub fn function_label(node: &ast::FnDef) -> Option<String> { | ||
67 | let label: String = if let Some(body) = node.body() { | ||
68 | let body_range = body.syntax().range(); | ||
69 | let label: String = node | ||
70 | .syntax() | ||
71 | .children() | ||
72 | .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body | ||
73 | .filter(|child| ast::Comment::cast(child).is_none()) // Filter out comments | ||
74 | .map(|node| node.text().to_string()) | ||
75 | .collect(); | ||
76 | label | ||
77 | } else { | ||
78 | node.syntax().text().to_string() | ||
79 | }; | ||
80 | |||
81 | Some(label.trim().to_owned()) | ||
82 | } | ||
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index b16ac2b28..d3bc14894 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -1,12 +1,12 @@ | |||
1 | use hir::{Docs, Documentation}; | 1 | use hir::{Docs, Documentation}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::TextRange; |
3 | ast::{self, AstNode}, | ||
4 | TextRange, | ||
5 | }; | ||
6 | use ra_text_edit::TextEdit; | 3 | use ra_text_edit::TextEdit; |
7 | use test_utils::tested_by; | 4 | use test_utils::tested_by; |
8 | 5 | ||
9 | use crate::completion::completion_context::CompletionContext; | 6 | use crate::completion::{ |
7 | completion_context::CompletionContext, | ||
8 | function_label, | ||
9 | }; | ||
10 | 10 | ||
11 | /// `CompletionItem` describes a single completion variant in the editor pop-up. | 11 | /// `CompletionItem` describes a single completion variant in the editor pop-up. |
12 | /// It is basically a POD with various properties. To construct a | 12 | /// It is basically a POD with various properties. To construct a |
@@ -97,8 +97,8 @@ impl CompletionItem { | |||
97 | self.detail.as_ref().map(|it| it.as_str()) | 97 | self.detail.as_ref().map(|it| it.as_str()) |
98 | } | 98 | } |
99 | /// A doc-comment | 99 | /// A doc-comment |
100 | pub fn documentation(&self) -> Option<&str> { | 100 | pub fn documentation(&self) -> Option<Documentation> { |
101 | self.documentation.as_ref().map(|it| it.contents()) | 101 | self.documentation.clone() |
102 | } | 102 | } |
103 | /// What string is used for filtering. | 103 | /// What string is used for filtering. |
104 | pub fn lookup(&self) -> &str { | 104 | pub fn lookup(&self) -> &str { |
@@ -252,7 +252,7 @@ impl Builder { | |||
252 | self.documentation = Some(docs); | 252 | self.documentation = Some(docs); |
253 | } | 253 | } |
254 | 254 | ||
255 | if let Some(label) = function_label(ctx, function) { | 255 | if let Some(label) = function_item_label(ctx, function) { |
256 | self.detail = Some(label); | 256 | self.detail = Some(label); |
257 | } | 257 | } |
258 | 258 | ||
@@ -292,24 +292,9 @@ impl Into<Vec<CompletionItem>> for Completions { | |||
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | fn function_label(ctx: &CompletionContext, function: hir::Function) -> Option<String> { | 295 | fn function_item_label(ctx: &CompletionContext, function: hir::Function) -> Option<String> { |
296 | let node = function.source(ctx.db).1; | 296 | let node = function.source(ctx.db).1; |
297 | 297 | function_label(&node) | |
298 | let label: String = if let Some(body) = node.body() { | ||
299 | let body_range = body.syntax().range(); | ||
300 | let label: String = node | ||
301 | .syntax() | ||
302 | .children() | ||
303 | .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body | ||
304 | .filter(|child| ast::Comment::cast(child).is_none()) // Filter out comments | ||
305 | .map(|node| node.text().to_string()) | ||
306 | .collect(); | ||
307 | label | ||
308 | } else { | ||
309 | node.syntax().text().to_string() | ||
310 | }; | ||
311 | |||
312 | Some(label.trim().to_owned()) | ||
313 | } | 298 | } |
314 | 299 | ||
315 | #[cfg(test)] | 300 | #[cfg(test)] |
@@ -324,10 +309,11 @@ pub(crate) fn check_completion(test_name: &str, code: &str, kind: CompletionKind | |||
324 | }; | 309 | }; |
325 | let completions = completions(&analysis.db, position).unwrap(); | 310 | let completions = completions(&analysis.db, position).unwrap(); |
326 | let completion_items: Vec<CompletionItem> = completions.into(); | 311 | let completion_items: Vec<CompletionItem> = completions.into(); |
327 | let kind_completions: Vec<CompletionItem> = completion_items | 312 | let mut kind_completions: Vec<CompletionItem> = completion_items |
328 | .into_iter() | 313 | .into_iter() |
329 | .filter(|c| c.completion_kind == kind) | 314 | .filter(|c| c.completion_kind == kind) |
330 | .collect(); | 315 | .collect(); |
316 | kind_completions.sort_by_key(|c| c.label.clone()); | ||
331 | assert_debug_snapshot_matches!(test_name, kind_completions); | 317 | assert_debug_snapshot_matches!(test_name, kind_completions); |
332 | } | 318 | } |
333 | 319 | ||
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap index 329309c90..31df6565b 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap | |||
@@ -1,26 +1,12 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T07:42:59.656273+00:00" | 2 | created: "2019-01-27T19:56:59.944446814+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "x", | ||
11 | kind: Some( | ||
12 | Binding | ||
13 | ), | ||
14 | detail: None, | ||
15 | documentation: None, | ||
16 | lookup: None, | ||
17 | insert_text: None, | ||
18 | insert_text_format: PlainText, | ||
19 | source_range: [83; 83), | ||
20 | text_edit: None | ||
21 | }, | ||
22 | CompletionItem { | ||
23 | completion_kind: Reference, | ||
24 | label: "quux", | 10 | label: "quux", |
25 | kind: Some( | 11 | kind: Some( |
26 | Function | 12 | Function |
@@ -36,5 +22,19 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
36 | insert_text_format: Snippet, | 22 | insert_text_format: Snippet, |
37 | source_range: [83; 83), | 23 | source_range: [83; 83), |
38 | text_edit: None | 24 | text_edit: None |
25 | }, | ||
26 | CompletionItem { | ||
27 | completion_kind: Reference, | ||
28 | label: "x", | ||
29 | kind: Some( | ||
30 | Binding | ||
31 | ), | ||
32 | detail: None, | ||
33 | documentation: None, | ||
34 | lookup: None, | ||
35 | insert_text: None, | ||
36 | insert_text_format: PlainText, | ||
37 | source_range: [83; 83), | ||
38 | text_edit: None | ||
39 | } | 39 | } |
40 | ] | 40 | ] |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap index dbbe06c7b..9f37bae36 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap | |||
@@ -1,13 +1,13 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T07:42:59.658419+00:00" | 2 | created: "2019-01-27T19:56:59.946956414+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "b", | 10 | label: "a", |
11 | kind: Some( | 11 | kind: Some( |
12 | Binding | 12 | Binding |
13 | ), | 13 | ), |
@@ -21,7 +21,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
21 | }, | 21 | }, |
22 | CompletionItem { | 22 | CompletionItem { |
23 | completion_kind: Reference, | 23 | completion_kind: Reference, |
24 | label: "a", | 24 | label: "b", |
25 | kind: Some( | 25 | kind: Some( |
26 | Binding | 26 | Binding |
27 | ), | 27 | ), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap index b727bb70c..f4808bc93 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap | |||
@@ -1,21 +1,25 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T07:42:59.657713+00:00" | 2 | created: "2019-01-27T19:56:59.948953759+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "y", | 10 | label: "quux", |
11 | kind: Some( | 11 | kind: Some( |
12 | Binding | 12 | Function |
13 | ), | ||
14 | detail: Some( | ||
15 | "fn quux(x: i32)" | ||
13 | ), | 16 | ), |
14 | detail: None, | ||
15 | documentation: None, | 17 | documentation: None, |
16 | lookup: None, | 18 | lookup: None, |
17 | insert_text: None, | 19 | insert_text: Some( |
18 | insert_text_format: PlainText, | 20 | "quux($0)" |
21 | ), | ||
22 | insert_text_format: Snippet, | ||
19 | source_range: [79; 79), | 23 | source_range: [79; 79), |
20 | text_edit: None | 24 | text_edit: None |
21 | }, | 25 | }, |
@@ -35,19 +39,15 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
35 | }, | 39 | }, |
36 | CompletionItem { | 40 | CompletionItem { |
37 | completion_kind: Reference, | 41 | completion_kind: Reference, |
38 | label: "quux", | 42 | label: "y", |
39 | kind: Some( | 43 | kind: Some( |
40 | Function | 44 | Binding |
41 | ), | ||
42 | detail: Some( | ||
43 | "fn quux(x: i32)" | ||
44 | ), | 45 | ), |
46 | detail: None, | ||
45 | documentation: None, | 47 | documentation: None, |
46 | lookup: None, | 48 | lookup: None, |
47 | insert_text: Some( | 49 | insert_text: None, |
48 | "quux($0)" | 50 | insert_text_format: PlainText, |
49 | ), | ||
50 | insert_text_format: Snippet, | ||
51 | source_range: [79; 79), | 51 | source_range: [79; 79), |
52 | text_edit: None | 52 | text_edit: None |
53 | } | 53 | } |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap index 8dcb773d0..25ccbdb8f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap | |||
@@ -1,13 +1,13 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.197434+00:00" | 2 | created: "2019-01-27T19:56:59.913816522+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Keyword, | 9 | completion_kind: Keyword, |
10 | label: "if", | 10 | label: "break", |
11 | kind: Some( | 11 | kind: Some( |
12 | Keyword | 12 | Keyword |
13 | ), | 13 | ), |
@@ -15,7 +15,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
15 | documentation: None, | 15 | documentation: None, |
16 | lookup: None, | 16 | lookup: None, |
17 | insert_text: Some( | 17 | insert_text: Some( |
18 | "if $0 {}" | 18 | "break;" |
19 | ), | 19 | ), |
20 | insert_text_format: Snippet, | 20 | insert_text_format: Snippet, |
21 | source_range: [55; 55), | 21 | source_range: [55; 55), |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "continue", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "continue;" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [55; 55), | 37 | source_range: [55; 55), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "if", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "if $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [55; 55), | 53 | source_range: [55; 55), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "continue", | 74 | label: "match", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "continue;" | 82 | "match $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [55; 55), | 85 | source_range: [55; 55), |
@@ -87,7 +87,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
87 | }, | 87 | }, |
88 | CompletionItem { | 88 | CompletionItem { |
89 | completion_kind: Keyword, | 89 | completion_kind: Keyword, |
90 | label: "break", | 90 | label: "return", |
91 | kind: Some( | 91 | kind: Some( |
92 | Keyword | 92 | Keyword |
93 | ), | 93 | ), |
@@ -95,7 +95,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
95 | documentation: None, | 95 | documentation: None, |
96 | lookup: None, | 96 | lookup: None, |
97 | insert_text: Some( | 97 | insert_text: Some( |
98 | "break;" | 98 | "return $0;" |
99 | ), | 99 | ), |
100 | insert_text_format: Snippet, | 100 | insert_text_format: Snippet, |
101 | source_range: [55; 55), | 101 | source_range: [55; 55), |
@@ -103,7 +103,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
103 | }, | 103 | }, |
104 | CompletionItem { | 104 | CompletionItem { |
105 | completion_kind: Keyword, | 105 | completion_kind: Keyword, |
106 | label: "return", | 106 | label: "while", |
107 | kind: Some( | 107 | kind: Some( |
108 | Keyword | 108 | Keyword |
109 | ), | 109 | ), |
@@ -111,7 +111,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
111 | documentation: None, | 111 | documentation: None, |
112 | lookup: None, | 112 | lookup: None, |
113 | insert_text: Some( | 113 | insert_text: Some( |
114 | "return $0;" | 114 | "while $0 {}" |
115 | ), | 115 | ), |
116 | insert_text_format: Snippet, | 116 | insert_text_format: Snippet, |
117 | source_range: [55; 55), | 117 | source_range: [55; 55), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap index 1c64c6548..42a888e3a 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.314513+00:00" | 2 | created: "2019-01-27T20:00:15.602646258+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [60; 60), | 37 | source_range: [60; 60), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [60; 60), | 53 | source_range: [60; 60), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return $0;" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [60; 60), | 69 | source_range: [60; 60), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return $0;" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [60; 60), | 85 | source_range: [60; 60), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap index 8c9657b5c..5e4ff6af8 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.197678+00:00" | 2 | created: "2019-01-27T19:56:59.920190685+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [85; 85), | 37 | source_range: [85; 85), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [85; 85), | 53 | source_range: [85; 85), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return $0" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [85; 85), | 69 | source_range: [85; 85), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return $0" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [85; 85), | 85 | source_range: [85; 85), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap index 091bf581e..f4a04ecb3 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_render_function_parens_if_already_call.snap | |||
@@ -1,18 +1,18 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-22T15:38:19.788294+00:00" | 2 | created: "2019-01-27T19:56:59.965130040+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "main", | 10 | label: "frobnicate", |
11 | kind: Some( | 11 | kind: Some( |
12 | Function | 12 | Function |
13 | ), | 13 | ), |
14 | detail: Some( | 14 | detail: Some( |
15 | "fn main()" | 15 | "fn frobnicate()" |
16 | ), | 16 | ), |
17 | documentation: None, | 17 | documentation: None, |
18 | lookup: None, | 18 | lookup: None, |
@@ -23,12 +23,12 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Reference, | 25 | completion_kind: Reference, |
26 | label: "frobnicate", | 26 | label: "main", |
27 | kind: Some( | 27 | kind: Some( |
28 | Function | 28 | Function |
29 | ), | 29 | ), |
30 | detail: Some( | 30 | detail: Some( |
31 | "fn frobnicate()" | 31 | "fn main()" |
32 | ), | 32 | ), |
33 | documentation: None, | 33 | documentation: None, |
34 | lookup: None, | 34 | lookup: None, |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap index 8c84439b2..8ac58006e 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant.snap | |||
@@ -1,5 +1,5 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-25T16:44:04.640545300+00:00" | 2 | created: "2019-01-27T19:56:59.937030324+00:00" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
@@ -7,16 +7,16 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "Foo", | 10 | label: "Bar", |
11 | kind: Some( | 11 | kind: Some( |
12 | EnumVariant | 12 | EnumVariant |
13 | ), | 13 | ), |
14 | detail: Some( | 14 | detail: Some( |
15 | "()" | 15 | "(i32)" |
16 | ), | 16 | ), |
17 | documentation: Some( | 17 | documentation: Some( |
18 | Documentation( | 18 | Documentation( |
19 | "Foo Variant" | 19 | "Bar Variant with i32" |
20 | ) | 20 | ) |
21 | ), | 21 | ), |
22 | lookup: None, | 22 | lookup: None, |
@@ -27,16 +27,16 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
27 | }, | 27 | }, |
28 | CompletionItem { | 28 | CompletionItem { |
29 | completion_kind: Reference, | 29 | completion_kind: Reference, |
30 | label: "Bar", | 30 | label: "Foo", |
31 | kind: Some( | 31 | kind: Some( |
32 | EnumVariant | 32 | EnumVariant |
33 | ), | 33 | ), |
34 | detail: Some( | 34 | detail: Some( |
35 | "(i32)" | 35 | "()" |
36 | ), | 36 | ), |
37 | documentation: Some( | 37 | documentation: Some( |
38 | Documentation( | 38 | Documentation( |
39 | "Bar Variant with i32" | 39 | "Foo Variant" |
40 | ) | 40 | ) |
41 | ), | 41 | ), |
42 | lookup: None, | 42 | lookup: None, |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap index 384634517..9fd2d81ec 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__enum_variant_with_details.snap | |||
@@ -1,5 +1,5 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-25T16:44:04.641542400+00:00" | 2 | created: "2019-01-27T19:56:59.938973454+00:00" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
@@ -7,16 +7,16 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "Foo", | 10 | label: "Bar", |
11 | kind: Some( | 11 | kind: Some( |
12 | EnumVariant | 12 | EnumVariant |
13 | ), | 13 | ), |
14 | detail: Some( | 14 | detail: Some( |
15 | "()" | 15 | "(i32, u32)" |
16 | ), | 16 | ), |
17 | documentation: Some( | 17 | documentation: Some( |
18 | Documentation( | 18 | Documentation( |
19 | "Foo Variant (empty)" | 19 | "Bar Variant with i32 and u32" |
20 | ) | 20 | ) |
21 | ), | 21 | ), |
22 | lookup: None, | 22 | lookup: None, |
@@ -27,16 +27,16 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
27 | }, | 27 | }, |
28 | CompletionItem { | 28 | CompletionItem { |
29 | completion_kind: Reference, | 29 | completion_kind: Reference, |
30 | label: "Bar", | 30 | label: "Foo", |
31 | kind: Some( | 31 | kind: Some( |
32 | EnumVariant | 32 | EnumVariant |
33 | ), | 33 | ), |
34 | detail: Some( | 34 | detail: Some( |
35 | "(i32, u32)" | 35 | "()" |
36 | ), | 36 | ), |
37 | documentation: Some( | 37 | documentation: Some( |
38 | Documentation( | 38 | Documentation( |
39 | "Bar Variant with i32 and u32" | 39 | "Foo Variant (empty)" |
40 | ) | 40 | ) |
41 | ), | 41 | ), |
42 | lookup: None, | 42 | lookup: None, |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap index 13f915446..6b2287951 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap | |||
@@ -1,19 +1,19 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-22T14:45:00.817649800+00:00" | 2 | created: "2019-01-27T19:56:59.944118550+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Postfix, | 9 | completion_kind: Postfix, |
10 | label: "not", | 10 | label: "if", |
11 | kind: None, | 11 | kind: None, |
12 | detail: None, | 12 | detail: None, |
13 | documentation: None, | 13 | documentation: None, |
14 | lookup: None, | 14 | lookup: None, |
15 | insert_text: Some( | 15 | insert_text: Some( |
16 | "!bar" | 16 | "if bar {$0}" |
17 | ), | 17 | ), |
18 | insert_text_format: Snippet, | 18 | insert_text_format: Snippet, |
19 | source_range: [76; 76), | 19 | source_range: [76; 76), |
@@ -30,13 +30,13 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
30 | }, | 30 | }, |
31 | CompletionItem { | 31 | CompletionItem { |
32 | completion_kind: Postfix, | 32 | completion_kind: Postfix, |
33 | label: "if", | 33 | label: "match", |
34 | kind: None, | 34 | kind: None, |
35 | detail: None, | 35 | detail: None, |
36 | documentation: None, | 36 | documentation: None, |
37 | lookup: None, | 37 | lookup: None, |
38 | insert_text: Some( | 38 | insert_text: Some( |
39 | "if bar {$0}" | 39 | "match bar {\n${1:_} => {$0\\},\n}" |
40 | ), | 40 | ), |
41 | insert_text_format: Snippet, | 41 | insert_text_format: Snippet, |
42 | source_range: [76; 76), | 42 | source_range: [76; 76), |
@@ -53,13 +53,13 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
53 | }, | 53 | }, |
54 | CompletionItem { | 54 | CompletionItem { |
55 | completion_kind: Postfix, | 55 | completion_kind: Postfix, |
56 | label: "match", | 56 | label: "not", |
57 | kind: None, | 57 | kind: None, |
58 | detail: None, | 58 | detail: None, |
59 | documentation: None, | 59 | documentation: None, |
60 | lookup: None, | 60 | lookup: None, |
61 | insert_text: Some( | 61 | insert_text: Some( |
62 | "match bar {\n${1:_} => {$0\\},\n}" | 62 | "!bar" |
63 | ), | 63 | ), |
64 | insert_text_format: Snippet, | 64 | insert_text_format: Snippet, |
65 | source_range: [76; 76), | 65 | source_range: [76; 76), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap index fff87574d..6925fd102 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap | |||
@@ -1,19 +1,19 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-22T14:45:00.820642200+00:00" | 2 | created: "2019-01-27T19:56:59.942831213+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Postfix, | 9 | completion_kind: Postfix, |
10 | label: "not", | 10 | label: "if", |
11 | kind: None, | 11 | kind: None, |
12 | detail: None, | 12 | detail: None, |
13 | documentation: None, | 13 | documentation: None, |
14 | lookup: None, | 14 | lookup: None, |
15 | insert_text: Some( | 15 | insert_text: Some( |
16 | "!bar" | 16 | "if bar {$0}" |
17 | ), | 17 | ), |
18 | insert_text_format: Snippet, | 18 | insert_text_format: Snippet, |
19 | source_range: [76; 77), | 19 | source_range: [76; 77), |
@@ -30,13 +30,13 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
30 | }, | 30 | }, |
31 | CompletionItem { | 31 | CompletionItem { |
32 | completion_kind: Postfix, | 32 | completion_kind: Postfix, |
33 | label: "if", | 33 | label: "match", |
34 | kind: None, | 34 | kind: None, |
35 | detail: None, | 35 | detail: None, |
36 | documentation: None, | 36 | documentation: None, |
37 | lookup: None, | 37 | lookup: None, |
38 | insert_text: Some( | 38 | insert_text: Some( |
39 | "if bar {$0}" | 39 | "match bar {\n${1:_} => {$0\\},\n}" |
40 | ), | 40 | ), |
41 | insert_text_format: Snippet, | 41 | insert_text_format: Snippet, |
42 | source_range: [76; 77), | 42 | source_range: [76; 77), |
@@ -53,13 +53,13 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
53 | }, | 53 | }, |
54 | CompletionItem { | 54 | CompletionItem { |
55 | completion_kind: Postfix, | 55 | completion_kind: Postfix, |
56 | label: "match", | 56 | label: "not", |
57 | kind: None, | 57 | kind: None, |
58 | detail: None, | 58 | detail: None, |
59 | documentation: None, | 59 | documentation: None, |
60 | lookup: None, | 60 | lookup: None, |
61 | insert_text: Some( | 61 | insert_text: Some( |
62 | "match bar {\n${1:_} => {$0\\},\n}" | 62 | "!bar" |
63 | ), | 63 | ), |
64 | insert_text_format: Snippet, | 64 | insert_text_format: Snippet, |
65 | source_range: [76; 77), | 65 | source_range: [76; 77), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap index e0f4730e7..22eaf2b4f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap | |||
@@ -1,19 +1,19 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.222118+00:00" | 2 | created: "2019-01-27T19:56:59.944615925+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Postfix, | 9 | completion_kind: Postfix, |
10 | label: "not", | 10 | label: "if", |
11 | kind: None, | 11 | kind: None, |
12 | detail: None, | 12 | detail: None, |
13 | documentation: None, | 13 | documentation: None, |
14 | lookup: None, | 14 | lookup: None, |
15 | insert_text: Some( | 15 | insert_text: Some( |
16 | "!bar" | 16 | "if bar {$0}" |
17 | ), | 17 | ), |
18 | insert_text_format: Snippet, | 18 | insert_text_format: Snippet, |
19 | source_range: [78; 78), | 19 | source_range: [78; 78), |
@@ -30,13 +30,13 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
30 | }, | 30 | }, |
31 | CompletionItem { | 31 | CompletionItem { |
32 | completion_kind: Postfix, | 32 | completion_kind: Postfix, |
33 | label: "if", | 33 | label: "match", |
34 | kind: None, | 34 | kind: None, |
35 | detail: None, | 35 | detail: None, |
36 | documentation: None, | 36 | documentation: None, |
37 | lookup: None, | 37 | lookup: None, |
38 | insert_text: Some( | 38 | insert_text: Some( |
39 | "if bar {$0}" | 39 | "match bar {\n${1:_} => {$0\\},\n}" |
40 | ), | 40 | ), |
41 | insert_text_format: Snippet, | 41 | insert_text_format: Snippet, |
42 | source_range: [78; 78), | 42 | source_range: [78; 78), |
@@ -53,13 +53,13 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
53 | }, | 53 | }, |
54 | CompletionItem { | 54 | CompletionItem { |
55 | completion_kind: Postfix, | 55 | completion_kind: Postfix, |
56 | label: "match", | 56 | label: "not", |
57 | kind: None, | 57 | kind: None, |
58 | detail: None, | 58 | detail: None, |
59 | documentation: None, | 59 | documentation: None, |
60 | lookup: None, | 60 | lookup: None, |
61 | insert_text: Some( | 61 | insert_text: Some( |
62 | "match bar {\n${1:_} => {$0\\},\n}" | 62 | "!bar" |
63 | ), | 63 | ), |
64 | insert_text_format: Snippet, | 64 | insert_text_format: Snippet, |
65 | source_range: [78; 78), | 65 | source_range: [78; 78), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap index b30a4c9e9..339df3c84 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__inserts_parens_for_function_calls1.snap | |||
@@ -1,23 +1,23 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-22T15:38:19.919937+00:00" | 2 | created: "2019-01-27T19:56:59.965550827+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "no_args", | 10 | label: "main", |
11 | kind: Some( | 11 | kind: Some( |
12 | Function | 12 | Function |
13 | ), | 13 | ), |
14 | detail: Some( | 14 | detail: Some( |
15 | "fn no_args()" | 15 | "fn main()" |
16 | ), | 16 | ), |
17 | documentation: None, | 17 | documentation: None, |
18 | lookup: None, | 18 | lookup: None, |
19 | insert_text: Some( | 19 | insert_text: Some( |
20 | "no_args()$0" | 20 | "main()$0" |
21 | ), | 21 | ), |
22 | insert_text_format: Snippet, | 22 | insert_text_format: Snippet, |
23 | source_range: [53; 56), | 23 | source_range: [53; 56), |
@@ -25,17 +25,17 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
25 | }, | 25 | }, |
26 | CompletionItem { | 26 | CompletionItem { |
27 | completion_kind: Reference, | 27 | completion_kind: Reference, |
28 | label: "main", | 28 | label: "no_args", |
29 | kind: Some( | 29 | kind: Some( |
30 | Function | 30 | Function |
31 | ), | 31 | ), |
32 | detail: Some( | 32 | detail: Some( |
33 | "fn main()" | 33 | "fn no_args()" |
34 | ), | 34 | ), |
35 | documentation: None, | 35 | documentation: None, |
36 | lookup: None, | 36 | lookup: None, |
37 | insert_text: Some( | 37 | insert_text: Some( |
38 | "main()$0" | 38 | "no_args()$0" |
39 | ), | 39 | ), |
40 | insert_text_format: Snippet, | 40 | insert_text_format: Snippet, |
41 | source_range: [53; 56), | 41 | source_range: [53; 56), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap index 2b6182578..874c41a02 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.197298+00:00" | 2 | created: "2019-01-27T19:56:59.913826978+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [41; 41), | 37 | source_range: [41; 41), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [41; 41), | 53 | source_range: [41; 41), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return;" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [41; 41), | 69 | source_range: [41; 41), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return;" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [41; 41), | 85 | source_range: [41; 41), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap index a56105f0c..0eec578be 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap | |||
@@ -1,13 +1,13 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.197423+00:00" | 2 | created: "2019-01-27T19:56:59.914744437+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Keyword, | 9 | completion_kind: Keyword, |
10 | label: "if", | 10 | label: "else", |
11 | kind: Some( | 11 | kind: Some( |
12 | Keyword | 12 | Keyword |
13 | ), | 13 | ), |
@@ -15,7 +15,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
15 | documentation: None, | 15 | documentation: None, |
16 | lookup: None, | 16 | lookup: None, |
17 | insert_text: Some( | 17 | insert_text: Some( |
18 | "if $0 {}" | 18 | "else {$0}" |
19 | ), | 19 | ), |
20 | insert_text_format: Snippet, | 20 | insert_text_format: Snippet, |
21 | source_range: [92; 92), | 21 | source_range: [92; 92), |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "else if", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "else if $0 {}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [92; 92), | 37 | source_range: [92; 92), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "if", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "if $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [92; 92), | 53 | source_range: [92; 92), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "else", | 74 | label: "match", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "else {$0}" | 82 | "match $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [92; 92), | 85 | source_range: [92; 92), |
@@ -87,7 +87,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
87 | }, | 87 | }, |
88 | CompletionItem { | 88 | CompletionItem { |
89 | completion_kind: Keyword, | 89 | completion_kind: Keyword, |
90 | label: "else if", | 90 | label: "return", |
91 | kind: Some( | 91 | kind: Some( |
92 | Keyword | 92 | Keyword |
93 | ), | 93 | ), |
@@ -95,7 +95,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
95 | documentation: None, | 95 | documentation: None, |
96 | lookup: None, | 96 | lookup: None, |
97 | insert_text: Some( | 97 | insert_text: Some( |
98 | "else if $0 {}" | 98 | "return;" |
99 | ), | 99 | ), |
100 | insert_text_format: Snippet, | 100 | insert_text_format: Snippet, |
101 | source_range: [92; 92), | 101 | source_range: [92; 92), |
@@ -103,7 +103,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
103 | }, | 103 | }, |
104 | CompletionItem { | 104 | CompletionItem { |
105 | completion_kind: Keyword, | 105 | completion_kind: Keyword, |
106 | label: "return", | 106 | label: "while", |
107 | kind: Some( | 107 | kind: Some( |
108 | Keyword | 108 | Keyword |
109 | ), | 109 | ), |
@@ -111,7 +111,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
111 | documentation: None, | 111 | documentation: None, |
112 | lookup: None, | 112 | lookup: None, |
113 | insert_text: Some( | 113 | insert_text: Some( |
114 | "return;" | 114 | "while $0 {}" |
115 | ), | 115 | ), |
116 | insert_text_format: Snippet, | 116 | insert_text_format: Snippet, |
117 | source_range: [92; 92), | 117 | source_range: [92; 92), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap index 84efab6f6..4b99f15e1 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.200056+00:00" | 2 | created: "2019-01-27T19:56:59.927994050+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [48; 48), | 37 | source_range: [48; 48), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [48; 48), | 53 | source_range: [48; 48), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return $0;" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [48; 48), | 69 | source_range: [48; 48), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return $0;" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [48; 48), | 85 | source_range: [48; 48), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap index 8b254ce99..f8587f147 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.314468+00:00" | 2 | created: "2019-01-27T20:00:15.604538211+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [41; 41), | 37 | source_range: [41; 41), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [41; 41), | 53 | source_range: [41; 41), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return;" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [41; 41), | 69 | source_range: [41; 41), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return;" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [41; 41), | 85 | source_range: [41; 41), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap index d36b555db..3c27e079f 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.197624+00:00" | 2 | created: "2019-01-27T19:56:59.918882346+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [83; 83), | 37 | source_range: [83; 83), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [83; 83), | 53 | source_range: [83; 83), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return $0;" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [83; 83), | 69 | source_range: [83; 83), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return $0;" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [83; 83), | 85 | source_range: [83; 83), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap index d74483c0b..d1be8c6e7 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap | |||
@@ -1,6 +1,6 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T05:27:32.302452+00:00" | 2 | created: "2019-01-27T20:00:15.604282112+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
@@ -23,7 +23,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "loop", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "loop {$0}" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [83; 83), | 37 | source_range: [83; 83), |
@@ -39,7 +39,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "match", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "match $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [83; 83), | 53 | source_range: [83; 83), |
@@ -55,7 +55,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
55 | }, | 55 | }, |
56 | CompletionItem { | 56 | CompletionItem { |
57 | completion_kind: Keyword, | 57 | completion_kind: Keyword, |
58 | label: "loop", | 58 | label: "return", |
59 | kind: Some( | 59 | kind: Some( |
60 | Keyword | 60 | Keyword |
61 | ), | 61 | ), |
@@ -63,7 +63,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
63 | documentation: None, | 63 | documentation: None, |
64 | lookup: None, | 64 | lookup: None, |
65 | insert_text: Some( | 65 | insert_text: Some( |
66 | "loop {$0}" | 66 | "return $0;" |
67 | ), | 67 | ), |
68 | insert_text_format: Snippet, | 68 | insert_text_format: Snippet, |
69 | source_range: [83; 83), | 69 | source_range: [83; 83), |
@@ -71,7 +71,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "return", | 74 | label: "while", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "return $0;" | 82 | "while $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [83; 83), | 85 | source_range: [83; 83), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap index a87880ab3..f6bba49ae 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap | |||
@@ -1,25 +1,21 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T07:42:59.657718+00:00" | 2 | created: "2019-01-27T19:56:59.953151082+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "quux", | 10 | label: "Baz", |
11 | kind: Some( | 11 | kind: Some( |
12 | Function | 12 | Enum |
13 | ), | ||
14 | detail: Some( | ||
15 | "fn quux()" | ||
16 | ), | 13 | ), |
14 | detail: None, | ||
17 | documentation: None, | 15 | documentation: None, |
18 | lookup: None, | 16 | lookup: None, |
19 | insert_text: Some( | 17 | insert_text: None, |
20 | "quux()$0" | 18 | insert_text_format: PlainText, |
21 | ), | ||
22 | insert_text_format: Snippet, | ||
23 | source_range: [89; 89), | 19 | source_range: [89; 89), |
24 | text_edit: None | 20 | text_edit: None |
25 | }, | 21 | }, |
@@ -39,15 +35,19 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
39 | }, | 35 | }, |
40 | CompletionItem { | 36 | CompletionItem { |
41 | completion_kind: Reference, | 37 | completion_kind: Reference, |
42 | label: "Baz", | 38 | label: "quux", |
43 | kind: Some( | 39 | kind: Some( |
44 | Enum | 40 | Function |
41 | ), | ||
42 | detail: Some( | ||
43 | "fn quux()" | ||
45 | ), | 44 | ), |
46 | detail: None, | ||
47 | documentation: None, | 45 | documentation: None, |
48 | lookup: None, | 46 | lookup: None, |
49 | insert_text: None, | 47 | insert_text: Some( |
50 | insert_text_format: PlainText, | 48 | "quux()$0" |
49 | ), | ||
50 | insert_text_format: Snippet, | ||
51 | source_range: [89; 89), | 51 | source_range: [89; 89), |
52 | text_edit: None | 52 | text_edit: None |
53 | } | 53 | } |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap index f95d10926..7c458664e 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap | |||
@@ -1,39 +1,39 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T07:42:59.657837+00:00" | 2 | created: "2019-01-27T19:56:59.959185284+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "quux", | 10 | label: "Bar", |
11 | kind: Some( | 11 | kind: Some( |
12 | Function | 12 | Struct |
13 | ), | ||
14 | detail: Some( | ||
15 | "fn quux()" | ||
16 | ), | 13 | ), |
14 | detail: None, | ||
17 | documentation: None, | 15 | documentation: None, |
18 | lookup: None, | 16 | lookup: None, |
19 | insert_text: Some( | 17 | insert_text: None, |
20 | "quux()$0" | 18 | insert_text_format: PlainText, |
21 | ), | ||
22 | insert_text_format: Snippet, | ||
23 | source_range: [101; 101), | 19 | source_range: [101; 101), |
24 | text_edit: None | 20 | text_edit: None |
25 | }, | 21 | }, |
26 | CompletionItem { | 22 | CompletionItem { |
27 | completion_kind: Reference, | 23 | completion_kind: Reference, |
28 | label: "Bar", | 24 | label: "quux", |
29 | kind: Some( | 25 | kind: Some( |
30 | Struct | 26 | Function |
27 | ), | ||
28 | detail: Some( | ||
29 | "fn quux()" | ||
31 | ), | 30 | ), |
32 | detail: None, | ||
33 | documentation: None, | 31 | documentation: None, |
34 | lookup: None, | 32 | lookup: None, |
35 | insert_text: None, | 33 | insert_text: Some( |
36 | insert_text_format: PlainText, | 34 | "quux()$0" |
35 | ), | ||
36 | insert_text_format: Snippet, | ||
37 | source_range: [101; 101), | 37 | source_range: [101; 101), |
38 | text_edit: None | 38 | text_edit: None |
39 | } | 39 | } |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap index a5164b03e..5a35d9ca9 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__no_semi_after_break_continue_in_expr.snap | |||
@@ -1,13 +1,13 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-22T14:45:00.651095300+00:00" | 2 | created: "2019-01-27T19:56:59.922933445+00:00" |
3 | creator: insta@0.4.0 | 3 | creator: insta@0.5.2 |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
6 | --- | 6 | --- |
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Keyword, | 9 | completion_kind: Keyword, |
10 | label: "if", | 10 | label: "break", |
11 | kind: Some( | 11 | kind: Some( |
12 | Keyword | 12 | Keyword |
13 | ), | 13 | ), |
@@ -15,7 +15,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
15 | documentation: None, | 15 | documentation: None, |
16 | lookup: None, | 16 | lookup: None, |
17 | insert_text: Some( | 17 | insert_text: Some( |
18 | "if $0 {}" | 18 | "break" |
19 | ), | 19 | ), |
20 | insert_text_format: Snippet, | 20 | insert_text_format: Snippet, |
21 | source_range: [106; 108), | 21 | source_range: [106; 108), |
@@ -23,7 +23,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
23 | }, | 23 | }, |
24 | CompletionItem { | 24 | CompletionItem { |
25 | completion_kind: Keyword, | 25 | completion_kind: Keyword, |
26 | label: "match", | 26 | label: "continue", |
27 | kind: Some( | 27 | kind: Some( |
28 | Keyword | 28 | Keyword |
29 | ), | 29 | ), |
@@ -31,7 +31,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
31 | documentation: None, | 31 | documentation: None, |
32 | lookup: None, | 32 | lookup: None, |
33 | insert_text: Some( | 33 | insert_text: Some( |
34 | "match $0 {}" | 34 | "continue" |
35 | ), | 35 | ), |
36 | insert_text_format: Snippet, | 36 | insert_text_format: Snippet, |
37 | source_range: [106; 108), | 37 | source_range: [106; 108), |
@@ -39,7 +39,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
39 | }, | 39 | }, |
40 | CompletionItem { | 40 | CompletionItem { |
41 | completion_kind: Keyword, | 41 | completion_kind: Keyword, |
42 | label: "while", | 42 | label: "if", |
43 | kind: Some( | 43 | kind: Some( |
44 | Keyword | 44 | Keyword |
45 | ), | 45 | ), |
@@ -47,7 +47,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
47 | documentation: None, | 47 | documentation: None, |
48 | lookup: None, | 48 | lookup: None, |
49 | insert_text: Some( | 49 | insert_text: Some( |
50 | "while $0 {}" | 50 | "if $0 {}" |
51 | ), | 51 | ), |
52 | insert_text_format: Snippet, | 52 | insert_text_format: Snippet, |
53 | source_range: [106; 108), | 53 | source_range: [106; 108), |
@@ -71,7 +71,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
71 | }, | 71 | }, |
72 | CompletionItem { | 72 | CompletionItem { |
73 | completion_kind: Keyword, | 73 | completion_kind: Keyword, |
74 | label: "continue", | 74 | label: "match", |
75 | kind: Some( | 75 | kind: Some( |
76 | Keyword | 76 | Keyword |
77 | ), | 77 | ), |
@@ -79,7 +79,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
79 | documentation: None, | 79 | documentation: None, |
80 | lookup: None, | 80 | lookup: None, |
81 | insert_text: Some( | 81 | insert_text: Some( |
82 | "continue" | 82 | "match $0 {}" |
83 | ), | 83 | ), |
84 | insert_text_format: Snippet, | 84 | insert_text_format: Snippet, |
85 | source_range: [106; 108), | 85 | source_range: [106; 108), |
@@ -87,7 +87,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
87 | }, | 87 | }, |
88 | CompletionItem { | 88 | CompletionItem { |
89 | completion_kind: Keyword, | 89 | completion_kind: Keyword, |
90 | label: "break", | 90 | label: "return", |
91 | kind: Some( | 91 | kind: Some( |
92 | Keyword | 92 | Keyword |
93 | ), | 93 | ), |
@@ -95,7 +95,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
95 | documentation: None, | 95 | documentation: None, |
96 | lookup: None, | 96 | lookup: None, |
97 | insert_text: Some( | 97 | insert_text: Some( |
98 | "break" | 98 | "return" |
99 | ), | 99 | ), |
100 | insert_text_format: Snippet, | 100 | insert_text_format: Snippet, |
101 | source_range: [106; 108), | 101 | source_range: [106; 108), |
@@ -103,7 +103,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
103 | }, | 103 | }, |
104 | CompletionItem { | 104 | CompletionItem { |
105 | completion_kind: Keyword, | 105 | completion_kind: Keyword, |
106 | label: "return", | 106 | label: "while", |
107 | kind: Some( | 107 | kind: Some( |
108 | Keyword | 108 | Keyword |
109 | ), | 109 | ), |
@@ -111,7 +111,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" | |||
111 | documentation: None, | 111 | documentation: None, |
112 | lookup: None, | 112 | lookup: None, |
113 | insert_text: Some( | 113 | insert_text: Some( |
114 | "return" | 114 | "while $0 {}" |
115 | ), | 115 | ), |
116 | insert_text_format: Snippet, | 116 | insert_text_format: Snippet, |
117 | source_range: [106; 108), | 117 | source_range: [106; 108), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap index 5f5df0033..4d5c7a869 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_autoderef.snap | |||
@@ -1,5 +1,5 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-23T13:19:23.501353210+00:00" | 2 | created: "2019-01-27T19:56:59.910113268+00:00" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
@@ -7,35 +7,35 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "the_field", | 10 | label: "foo", |
11 | kind: Some( | 11 | kind: Some( |
12 | Field | 12 | Method |
13 | ), | 13 | ), |
14 | detail: Some( | 14 | detail: Some( |
15 | "(u32, i32)" | 15 | "fn foo(&self)" |
16 | ), | 16 | ), |
17 | documentation: None, | 17 | documentation: None, |
18 | lookup: None, | 18 | lookup: None, |
19 | insert_text: None, | 19 | insert_text: Some( |
20 | insert_text_format: PlainText, | 20 | "foo()$0" |
21 | ), | ||
22 | insert_text_format: Snippet, | ||
21 | source_range: [126; 126), | 23 | source_range: [126; 126), |
22 | text_edit: None | 24 | text_edit: None |
23 | }, | 25 | }, |
24 | CompletionItem { | 26 | CompletionItem { |
25 | completion_kind: Reference, | 27 | completion_kind: Reference, |
26 | label: "foo", | 28 | label: "the_field", |
27 | kind: Some( | 29 | kind: Some( |
28 | Method | 30 | Field |
29 | ), | 31 | ), |
30 | detail: Some( | 32 | detail: Some( |
31 | "fn foo(&self)" | 33 | "(u32, i32)" |
32 | ), | 34 | ), |
33 | documentation: None, | 35 | documentation: None, |
34 | lookup: None, | 36 | lookup: None, |
35 | insert_text: Some( | 37 | insert_text: None, |
36 | "foo()$0" | 38 | insert_text_format: PlainText, |
37 | ), | ||
38 | insert_text_format: Snippet, | ||
39 | source_range: [126; 126), | 39 | source_range: [126; 126), |
40 | text_edit: None | 40 | text_edit: None |
41 | } | 41 | } |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap index 580e92a90..1073d90fd 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap | |||
@@ -1,5 +1,5 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-25T19:27:09.519688600+00:00" | 2 | created: "2019-01-27T19:56:59.909689544+00:00" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: crates/ra_ide_api/src/completion/completion_item.rs |
@@ -7,39 +7,39 @@ source: crates/ra_ide_api/src/completion/completion_item.rs | |||
7 | [ | 7 | [ |
8 | CompletionItem { | 8 | CompletionItem { |
9 | completion_kind: Reference, | 9 | completion_kind: Reference, |
10 | label: "the_field", | 10 | label: "foo", |
11 | kind: Some( | 11 | kind: Some( |
12 | Field | 12 | Method |
13 | ), | 13 | ), |
14 | detail: Some( | 14 | detail: Some( |
15 | "(u32,)" | 15 | "fn foo(self)" |
16 | ), | ||
17 | documentation: Some( | ||
18 | Documentation( | ||
19 | "This is the_field" | ||
20 | ) | ||
21 | ), | 16 | ), |
17 | documentation: None, | ||
22 | lookup: None, | 18 | lookup: None, |
23 | insert_text: None, | 19 | insert_text: Some( |
24 | insert_text_format: PlainText, | 20 | "foo()$0" |
21 | ), | ||
22 | insert_text_format: Snippet, | ||
25 | source_range: [187; 187), | 23 | source_range: [187; 187), |
26 | text_edit: None | 24 | text_edit: None |
27 | }, | 25 | }, |
28 | CompletionItem { | 26 | CompletionItem { |
29 | completion_kind: Reference, | 27 | completion_kind: Reference, |
30 | label: "foo", | 28 | label: "the_field", |
31 | kind: Some( | 29 | kind: Some( |
32 | Method | 30 | Field |
33 | ), | 31 | ), |
34 | detail: Some( | 32 | detail: Some( |
35 | "fn foo(self)" | 33 | "(u32,)" |
36 | ), | 34 | ), |
37 | documentation: None, | 35 | documentation: Some( |
38 | lookup: None, | 36 | Documentation( |
39 | insert_text: Some( | 37 | "This is the_field" |
40 | "foo()$0" | 38 | ) |
41 | ), | 39 | ), |
42 | insert_text_format: Snippet, | 40 | lookup: None, |
41 | insert_text: None, | ||
42 | insert_text_format: PlainText, | ||
43 | source_range: [187; 187), | 43 | source_range: [187; 187), |
44 | text_edit: None | 44 | text_edit: None |
45 | } | 45 | } |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 3da93ec35..6850811d7 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,4 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::{ |
2 | sync::Arc, | ||
3 | time, | ||
4 | }; | ||
2 | 5 | ||
3 | use ra_db::{ | 6 | use ra_db::{ |
4 | CheckCanceled, FileId, Canceled, SourceDatabase, | 7 | CheckCanceled, FileId, Canceled, SourceDatabase, |
@@ -17,6 +20,8 @@ use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; | |||
17 | pub(crate) struct RootDatabase { | 20 | pub(crate) struct RootDatabase { |
18 | runtime: salsa::Runtime<RootDatabase>, | 21 | runtime: salsa::Runtime<RootDatabase>, |
19 | interner: Arc<hir::HirInterner>, | 22 | interner: Arc<hir::HirInterner>, |
23 | pub(crate) last_gc: time::Instant, | ||
24 | pub(crate) last_gc_check: time::Instant, | ||
20 | } | 25 | } |
21 | 26 | ||
22 | impl salsa::Database for RootDatabase { | 27 | impl salsa::Database for RootDatabase { |
@@ -33,6 +38,8 @@ impl Default for RootDatabase { | |||
33 | let mut db = RootDatabase { | 38 | let mut db = RootDatabase { |
34 | runtime: salsa::Runtime::default(), | 39 | runtime: salsa::Runtime::default(), |
35 | interner: Default::default(), | 40 | interner: Default::default(), |
41 | last_gc: time::Instant::now(), | ||
42 | last_gc_check: time::Instant::now(), | ||
36 | }; | 43 | }; |
37 | db.set_crate_graph(Default::default()); | 44 | db.set_crate_graph(Default::default()); |
38 | db.set_local_roots(Default::default()); | 45 | db.set_local_roots(Default::default()); |
@@ -46,6 +53,8 @@ impl salsa::ParallelDatabase for RootDatabase { | |||
46 | salsa::Snapshot::new(RootDatabase { | 53 | salsa::Snapshot::new(RootDatabase { |
47 | runtime: self.runtime.snapshot(self), | 54 | runtime: self.runtime.snapshot(self), |
48 | interner: Arc::clone(&self.interner), | 55 | interner: Arc::clone(&self.interner), |
56 | last_gc: self.last_gc.clone(), | ||
57 | last_gc_check: self.last_gc_check.clone(), | ||
49 | }) | 58 | }) |
50 | } | 59 | } |
51 | } | 60 | } |
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index 399433a01..31e0f5d6d 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs | |||
@@ -1,4 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::{ |
2 | sync::Arc, | ||
3 | time, | ||
4 | }; | ||
2 | 5 | ||
3 | use hir::{ | 6 | use hir::{ |
4 | self, Problem, source_binder | 7 | self, Problem, source_binder |
@@ -19,12 +22,14 @@ use crate::{ | |||
19 | CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, | 22 | CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, |
20 | Query, RootChange, SourceChange, SourceFileEdit, | 23 | Query, RootChange, SourceChange, SourceFileEdit, |
21 | symbol_index::{FileSymbol, SymbolsDatabase}, | 24 | symbol_index::{FileSymbol, SymbolsDatabase}, |
25 | status::syntax_tree_stats | ||
22 | }; | 26 | }; |
23 | 27 | ||
28 | const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100); | ||
29 | |||
24 | impl db::RootDatabase { | 30 | impl db::RootDatabase { |
25 | pub(crate) fn apply_change(&mut self, change: AnalysisChange) { | 31 | pub(crate) fn apply_change(&mut self, change: AnalysisChange) { |
26 | log::info!("apply_change {:?}", change); | 32 | log::info!("apply_change {:?}", change); |
27 | // self.gc_syntax_trees(); | ||
28 | if !change.new_roots.is_empty() { | 33 | if !change.new_roots.is_empty() { |
29 | let mut local_roots = Vec::clone(&self.local_roots()); | 34 | let mut local_roots = Vec::clone(&self.local_roots()); |
30 | for (root_id, is_local) in change.new_roots { | 35 | for (root_id, is_local) in change.new_roots { |
@@ -72,18 +77,36 @@ impl db::RootDatabase { | |||
72 | self.set_source_root(root_id, Arc::new(source_root)); | 77 | self.set_source_root(root_id, Arc::new(source_root)); |
73 | } | 78 | } |
74 | 79 | ||
75 | /// Ideally, we should call this function from time to time to collect heavy | 80 | pub(crate) fn maybe_collect_garbage(&mut self) { |
76 | /// syntax trees. However, if we actually do that, everything is recomputed | 81 | if self.last_gc_check.elapsed() > GC_COOLDOWN { |
77 | /// for some reason. Needs investigation. | 82 | self.last_gc_check = time::Instant::now(); |
83 | let retained_trees = syntax_tree_stats(self).retained; | ||
84 | if retained_trees > 100 { | ||
85 | log::info!( | ||
86 | "automatic garbadge collection, {} retained trees", | ||
87 | retained_trees | ||
88 | ); | ||
89 | self.collect_garbage(); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
78 | pub(crate) fn collect_garbage(&mut self) { | 94 | pub(crate) fn collect_garbage(&mut self) { |
79 | self.query(ra_db::ParseQuery) | 95 | self.last_gc = time::Instant::now(); |
80 | .sweep(SweepStrategy::default().discard_values()); | 96 | |
81 | self.query(hir::db::HirParseQuery) | 97 | let sweep = SweepStrategy::default() |
82 | .sweep(SweepStrategy::default().discard_values()); | 98 | .discard_values() |
83 | self.query(hir::db::FileItemsQuery) | 99 | .sweep_all_revisions(); |
84 | .sweep(SweepStrategy::default().discard_values()); | 100 | |
85 | self.query(hir::db::FileItemQuery) | 101 | self.query(ra_db::ParseQuery).sweep(sweep); |
86 | .sweep(SweepStrategy::default().discard_values()); | 102 | |
103 | self.query(hir::db::HirParseQuery).sweep(sweep); | ||
104 | self.query(hir::db::FileItemsQuery).sweep(sweep); | ||
105 | self.query(hir::db::FileItemQuery).sweep(sweep); | ||
106 | |||
107 | self.query(hir::db::LowerModuleQuery).sweep(sweep); | ||
108 | self.query(hir::db::LowerModuleSourceMapQuery).sweep(sweep); | ||
109 | self.query(hir::db::BodySyntaxMappingQuery).sweep(sweep); | ||
87 | } | 110 | } |
88 | } | 111 | } |
89 | 112 | ||
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs new file mode 100644 index 000000000..469d56d63 --- /dev/null +++ b/crates/ra_ide_api/src/impls.rs | |||
@@ -0,0 +1,120 @@ | |||
1 | use ra_db::{SourceDatabase}; | ||
2 | use ra_syntax::{ | ||
3 | AstNode, ast, | ||
4 | algo::find_node_at_offset, | ||
5 | }; | ||
6 | use hir::{db::HirDatabase, source_binder}; | ||
7 | |||
8 | use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; | ||
9 | |||
10 | pub(crate) fn goto_implementation( | ||
11 | db: &RootDatabase, | ||
12 | position: FilePosition, | ||
13 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { | ||
14 | let file = db.parse(position.file_id); | ||
15 | let syntax = file.syntax(); | ||
16 | |||
17 | let module = source_binder::module_from_position(db, position)?; | ||
18 | let krate = module.krate(db)?; | ||
19 | |||
20 | let node = find_node_at_offset::<ast::NominalDef>(syntax, position.offset)?; | ||
21 | let ty = match node.kind() { | ||
22 | ast::NominalDefKind::StructDef(def) => { | ||
23 | source_binder::struct_from_module(db, module, &def).ty(db) | ||
24 | } | ||
25 | ast::NominalDefKind::EnumDef(def) => { | ||
26 | source_binder::enum_from_module(db, module, &def).ty(db) | ||
27 | } | ||
28 | }; | ||
29 | |||
30 | let impls = db.impls_in_crate(krate); | ||
31 | |||
32 | let navs = impls | ||
33 | .lookup_impl_blocks(db, &ty) | ||
34 | .map(|(module, imp)| NavigationTarget::from_impl_block(db, module, &imp)); | ||
35 | |||
36 | Some(RangeInfo::new(node.syntax().range(), navs.collect())) | ||
37 | } | ||
38 | |||
39 | #[cfg(test)] | ||
40 | mod tests { | ||
41 | use crate::mock_analysis::analysis_and_position; | ||
42 | |||
43 | fn check_goto(fixuture: &str, expected: &[&str]) { | ||
44 | let (analysis, pos) = analysis_and_position(fixuture); | ||
45 | |||
46 | let navs = analysis.goto_implementation(pos).unwrap().unwrap().info; | ||
47 | assert_eq!(navs.len(), expected.len()); | ||
48 | navs.into_iter() | ||
49 | .enumerate() | ||
50 | .for_each(|(i, nav)| nav.assert_match(expected[i])); | ||
51 | } | ||
52 | |||
53 | #[test] | ||
54 | fn goto_implementation_works() { | ||
55 | check_goto( | ||
56 | " | ||
57 | //- /lib.rs | ||
58 | struct Foo<|>; | ||
59 | impl Foo {} | ||
60 | ", | ||
61 | &["impl IMPL_BLOCK FileId(1) [12; 23)"], | ||
62 | ); | ||
63 | } | ||
64 | |||
65 | #[test] | ||
66 | fn goto_implementation_works_multiple_blocks() { | ||
67 | check_goto( | ||
68 | " | ||
69 | //- /lib.rs | ||
70 | struct Foo<|>; | ||
71 | impl Foo {} | ||
72 | impl Foo {} | ||
73 | ", | ||
74 | &[ | ||
75 | "impl IMPL_BLOCK FileId(1) [12; 23)", | ||
76 | "impl IMPL_BLOCK FileId(1) [24; 35)", | ||
77 | ], | ||
78 | ); | ||
79 | } | ||
80 | |||
81 | #[test] | ||
82 | fn goto_implementation_works_multiple_mods() { | ||
83 | check_goto( | ||
84 | " | ||
85 | //- /lib.rs | ||
86 | struct Foo<|>; | ||
87 | mod a { | ||
88 | impl super::Foo {} | ||
89 | } | ||
90 | mod b { | ||
91 | impl super::Foo {} | ||
92 | } | ||
93 | ", | ||
94 | &[ | ||
95 | "impl IMPL_BLOCK FileId(1) [24; 42)", | ||
96 | "impl IMPL_BLOCK FileId(1) [57; 75)", | ||
97 | ], | ||
98 | ); | ||
99 | } | ||
100 | |||
101 | #[test] | ||
102 | fn goto_implementation_works_multiple_files() { | ||
103 | check_goto( | ||
104 | " | ||
105 | //- /lib.rs | ||
106 | struct Foo<|>; | ||
107 | mod a; | ||
108 | mod b; | ||
109 | //- /a.rs | ||
110 | impl crate::Foo {} | ||
111 | //- /b.rs | ||
112 | impl crate::Foo {} | ||
113 | ", | ||
114 | &[ | ||
115 | "impl IMPL_BLOCK FileId(2) [0; 18)", | ||
116 | "impl IMPL_BLOCK FileId(3) [0; 18)", | ||
117 | ], | ||
118 | ); | ||
119 | } | ||
120 | } | ||
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 43c8bea71..5d8acf9df 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -25,6 +25,7 @@ mod call_info; | |||
25 | mod syntax_highlighting; | 25 | mod syntax_highlighting; |
26 | mod parent_module; | 26 | mod parent_module; |
27 | mod rename; | 27 | mod rename; |
28 | mod impls; | ||
28 | 29 | ||
29 | #[cfg(test)] | 30 | #[cfg(test)] |
30 | mod marks; | 31 | mod marks; |
@@ -58,6 +59,13 @@ pub use ra_ide_api_light::{ | |||
58 | pub use ra_db::{ | 59 | pub use ra_db::{ |
59 | Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId | 60 | Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId |
60 | }; | 61 | }; |
62 | pub use hir::Documentation; | ||
63 | |||
64 | // We use jemalloc mainly to get heap usage statistics, actual performance | ||
65 | // differnece is not measures. | ||
66 | #[cfg(feature = "jemalloc")] | ||
67 | #[global_allocator] | ||
68 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
61 | 69 | ||
62 | pub type Cancelable<T> = Result<T, Canceled>; | 70 | pub type Cancelable<T> = Result<T, Canceled>; |
63 | 71 | ||
@@ -260,7 +268,7 @@ impl<T> RangeInfo<T> { | |||
260 | #[derive(Debug)] | 268 | #[derive(Debug)] |
261 | pub struct CallInfo { | 269 | pub struct CallInfo { |
262 | pub label: String, | 270 | pub label: String, |
263 | pub doc: Option<String>, | 271 | pub doc: Option<Documentation>, |
264 | pub parameters: Vec<String>, | 272 | pub parameters: Vec<String>, |
265 | pub active_parameter: Option<usize>, | 273 | pub active_parameter: Option<usize>, |
266 | } | 274 | } |
@@ -286,6 +294,10 @@ impl AnalysisHost { | |||
286 | self.db.apply_change(change) | 294 | self.db.apply_change(change) |
287 | } | 295 | } |
288 | 296 | ||
297 | pub fn maybe_collect_garbage(&mut self) { | ||
298 | self.db.maybe_collect_garbage(); | ||
299 | } | ||
300 | |||
289 | pub fn collect_garbage(&mut self) { | 301 | pub fn collect_garbage(&mut self) { |
290 | self.db.collect_garbage(); | 302 | self.db.collect_garbage(); |
291 | } | 303 | } |
@@ -405,6 +417,13 @@ impl Analysis { | |||
405 | self.with_db(|db| goto_definition::goto_definition(db, position)) | 417 | self.with_db(|db| goto_definition::goto_definition(db, position)) |
406 | } | 418 | } |
407 | 419 | ||
420 | pub fn goto_implementation( | ||
421 | &self, | ||
422 | position: FilePosition, | ||
423 | ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> { | ||
424 | self.with_db(|db| impls::goto_implementation(db, position)) | ||
425 | } | ||
426 | |||
408 | /// Finds all usages of the reference at point. | 427 | /// Finds all usages of the reference at point. |
409 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { | 428 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { |
410 | self.with_db(|db| db.find_all_refs(position)) | 429 | self.with_db(|db| db.find_all_refs(position)) |
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index d73d4afa7..5ccb5cc2e 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs | |||
@@ -147,6 +147,16 @@ impl NavigationTarget { | |||
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | pub(crate) fn from_impl_block( | ||
151 | db: &RootDatabase, | ||
152 | module: hir::Module, | ||
153 | impl_block: &hir::ImplBlock, | ||
154 | ) -> NavigationTarget { | ||
155 | let (file_id, _) = module.definition_source(db); | ||
156 | let node = module.impl_source(db, impl_block.id()); | ||
157 | NavigationTarget::from_syntax(file_id, "impl".into(), None, node.syntax()) | ||
158 | } | ||
159 | |||
150 | #[cfg(test)] | 160 | #[cfg(test)] |
151 | pub(crate) fn assert_match(&self, expected: &str) { | 161 | pub(crate) fn assert_match(&self, expected: &str) { |
152 | let actual = self.debug_render(); | 162 | let actual = self.debug_render(); |
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index e11eed223..bd355dd78 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -15,9 +15,13 @@ use crate::{ | |||
15 | symbol_index::{SymbolIndex, LibrarySymbolsQuery}, | 15 | symbol_index::{SymbolIndex, LibrarySymbolsQuery}, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | pub(crate) fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { | ||
19 | db.query(ParseQuery).entries::<SyntaxTreeStats>() | ||
20 | } | ||
21 | |||
18 | pub(crate) fn status(db: &RootDatabase) -> String { | 22 | pub(crate) fn status(db: &RootDatabase) -> String { |
19 | let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); | 23 | let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); |
20 | let syntax_tree_stats = db.query(ParseQuery).entries::<SyntaxTreeStats>(); | 24 | let syntax_tree_stats = syntax_tree_stats(db); |
21 | let symbols_stats = db | 25 | let symbols_stats = db |
22 | .query(LibrarySymbolsQuery) | 26 | .query(LibrarySymbolsQuery) |
23 | .entries::<LibrarySymbolsStats>(); | 27 | .entries::<LibrarySymbolsStats>(); |
@@ -26,8 +30,13 @@ pub(crate) fn status(db: &RootDatabase) -> String { | |||
26 | interner.len() | 30 | interner.len() |
27 | }; | 31 | }; |
28 | format!( | 32 | format!( |
29 | "{}\n{}\n{}\nn_defs {}\n", | 33 | "{}\n{}\n{}\n{} defs\n\nmemory:\n{}\ngc {:?} seconds ago", |
30 | files_stats, symbols_stats, syntax_tree_stats, n_defs | 34 | files_stats, |
35 | symbols_stats, | ||
36 | syntax_tree_stats, | ||
37 | n_defs, | ||
38 | MemoryStats::current(), | ||
39 | db.last_gc.elapsed().as_secs(), | ||
31 | ) | 40 | ) |
32 | } | 41 | } |
33 | 42 | ||
@@ -58,9 +67,9 @@ impl FromIterator<TableEntry<FileId, Arc<String>>> for FilesStats { | |||
58 | } | 67 | } |
59 | 68 | ||
60 | #[derive(Default)] | 69 | #[derive(Default)] |
61 | struct SyntaxTreeStats { | 70 | pub(crate) struct SyntaxTreeStats { |
62 | total: usize, | 71 | total: usize, |
63 | retained: usize, | 72 | pub(crate) retained: usize, |
64 | retained_size: Bytes, | 73 | retained_size: Bytes, |
65 | } | 74 | } |
66 | 75 | ||
@@ -118,6 +127,40 @@ impl FromIterator<TableEntry<SourceRootId, Arc<SymbolIndex>>> for LibrarySymbols | |||
118 | } | 127 | } |
119 | } | 128 | } |
120 | 129 | ||
130 | struct MemoryStats { | ||
131 | allocated: Bytes, | ||
132 | resident: Bytes, | ||
133 | } | ||
134 | |||
135 | impl MemoryStats { | ||
136 | #[cfg(feature = "jemalloc")] | ||
137 | fn current() -> MemoryStats { | ||
138 | jemalloc_ctl::epoch().unwrap(); | ||
139 | MemoryStats { | ||
140 | allocated: Bytes(jemalloc_ctl::stats::allocated().unwrap()), | ||
141 | resident: Bytes(jemalloc_ctl::stats::resident().unwrap()), | ||
142 | } | ||
143 | } | ||
144 | |||
145 | #[cfg(not(feature = "jemalloc"))] | ||
146 | fn current() -> MemoryStats { | ||
147 | MemoryStats { | ||
148 | allocated: Bytes(0), | ||
149 | resident: Bytes(0), | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | impl fmt::Display for MemoryStats { | ||
155 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
156 | write!( | ||
157 | fmt, | ||
158 | "{} allocated {} resident", | ||
159 | self.allocated, self.resident, | ||
160 | ) | ||
161 | } | ||
162 | } | ||
163 | |||
121 | #[derive(Default)] | 164 | #[derive(Default)] |
122 | struct Bytes(usize); | 165 | struct Bytes(usize); |
123 | 166 | ||