mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
No self-imports in completion
This commit is contained in:
parent
2161a1689d
commit
f5669dfc56
2 changed files with 12 additions and 1 deletions
|
@ -42,6 +42,7 @@ pub fn scope_completion(file: &File, offset: TextUnit) -> Option<Vec<CompletionI
|
|||
let scope = ModuleScope::new(root);
|
||||
res.extend(
|
||||
scope.entries().iter()
|
||||
.filter(|entry| entry.syntax() != name_ref.syntax())
|
||||
.map(|entry| CompletionItem {
|
||||
name: entry.name().to_string(),
|
||||
snippet: None,
|
||||
|
@ -232,6 +233,13 @@ mod tests {
|
|||
CompletionItem { name: "quux", snippet: None }]"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_completion_mod_scope_no_self_use() {
|
||||
check_scope_completion(r"
|
||||
use foo<|>;
|
||||
", r#"[]"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_complete_type() {
|
||||
check_scope_completion(r"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use libsyntax2::{
|
||||
AstNode, SyntaxNode, SmolStr, ast
|
||||
AstNode, SyntaxNode, SyntaxNodeRef, SmolStr, ast
|
||||
};
|
||||
|
||||
pub struct ModuleScope {
|
||||
|
@ -67,6 +67,9 @@ impl Entry {
|
|||
.text(),
|
||||
}
|
||||
}
|
||||
pub fn syntax(&self) -> SyntaxNodeRef {
|
||||
self.node.borrowed()
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) {
|
||||
|
|
Loading…
Reference in a new issue