aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libeditor/src/completion.rs8
-rw-r--r--crates/libeditor/src/scope/mod_scope.rs5
2 files changed, 12 insertions, 1 deletions
diff --git a/crates/libeditor/src/completion.rs b/crates/libeditor/src/completion.rs
index f3058c023..be37fb6bf 100644
--- a/crates/libeditor/src/completion.rs
+++ b/crates/libeditor/src/completion.rs
@@ -42,6 +42,7 @@ pub fn scope_completion(file: &File, offset: TextUnit) -> Option<Vec<CompletionI
42 let scope = ModuleScope::new(root); 42 let scope = ModuleScope::new(root);
43 res.extend( 43 res.extend(
44 scope.entries().iter() 44 scope.entries().iter()
45 .filter(|entry| entry.syntax() != name_ref.syntax())
45 .map(|entry| CompletionItem { 46 .map(|entry| CompletionItem {
46 name: entry.name().to_string(), 47 name: entry.name().to_string(),
47 snippet: None, 48 snippet: None,
@@ -233,6 +234,13 @@ mod tests {
233 } 234 }
234 235
235 #[test] 236 #[test]
237 fn test_completion_mod_scope_no_self_use() {
238 check_scope_completion(r"
239 use foo<|>;
240 ", r#"[]"#);
241 }
242
243 #[test]
236 fn test_complete_type() { 244 fn test_complete_type() {
237 check_scope_completion(r" 245 check_scope_completion(r"
238 struct Foo; 246 struct Foo;
diff --git a/crates/libeditor/src/scope/mod_scope.rs b/crates/libeditor/src/scope/mod_scope.rs
index 052f70569..67baa8678 100644
--- a/crates/libeditor/src/scope/mod_scope.rs
+++ b/crates/libeditor/src/scope/mod_scope.rs
@@ -1,5 +1,5 @@
1use libsyntax2::{ 1use libsyntax2::{
2 AstNode, SyntaxNode, SmolStr, ast 2 AstNode, SyntaxNode, SyntaxNodeRef, SmolStr, ast
3}; 3};
4 4
5pub struct ModuleScope { 5pub struct ModuleScope {
@@ -67,6 +67,9 @@ impl Entry {
67 .text(), 67 .text(),
68 } 68 }
69 } 69 }
70 pub fn syntax(&self) -> SyntaxNodeRef {
71 self.node.borrowed()
72 }
70} 73}
71 74
72fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) { 75fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) {