mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
No self-imports in completion
This commit is contained in:
@@ -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 @@ fn quux() {
|
||||
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 @@ pub fn name(&self) -> SmolStr {
|
||||
.text(),
|
||||
}
|
||||
}
|
||||
pub fn syntax(&self) -> SyntaxNodeRef {
|
||||
self.node.borrowed()
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) {
|
||||
|
||||
Reference in New Issue
Block a user