aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/completion.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-31 14:30:42 +0100
committerAleksey Kladov <[email protected]>2018-08-31 14:30:42 +0100
commit7a5bc94774a50837f8c9bf8b96c8272882aca640 (patch)
tree7d96566cbbf7bdd636fd095acb6bff12bba1ec13 /crates/libeditor/src/completion.rs
parentcdb9b4cbf417976739de5147938e2c3080e497b9 (diff)
complete self
Diffstat (limited to 'crates/libeditor/src/completion.rs')
-rw-r--r--crates/libeditor/src/completion.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/libeditor/src/completion.rs b/crates/libeditor/src/completion.rs
index 06a607265..f3058c023 100644
--- a/crates/libeditor/src/completion.rs
+++ b/crates/libeditor/src/completion.rs
@@ -142,6 +142,12 @@ fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<Completi
142 snippet: None, 142 snippet: None,
143 }) 143 })
144 ); 144 );
145 if scopes.self_param.is_some() {
146 acc.push(CompletionItem {
147 name: "self".to_string(),
148 snippet: None,
149 })
150 }
145} 151}
146 152
147#[cfg(test)] 153#[cfg(test)]
@@ -250,6 +256,13 @@ mod tests {
250 } 256 }
251 257
252 #[test] 258 #[test]
259 fn test_complete_self() {
260 check_scope_completion(r"
261 impl S { fn foo(&self) { <|> } }
262 ", r#"[CompletionItem { name: "self", snippet: None }]"#)
263 }
264
265 #[test]
253 fn test_completion_kewords() { 266 fn test_completion_kewords() {
254 check_snippet_completion(r" 267 check_snippet_completion(r"
255 fn quux() { 268 fn quux() {