completion snippets

This commit is contained in:
Aleksey Kladov 2018-08-28 20:26:57 +03:00
parent b6c654e233
commit 4c1f17af7d

View file

@ -14,6 +14,7 @@ use {
#[derive(Debug)] #[derive(Debug)]
pub struct CompletionItem { pub struct CompletionItem {
pub name: String, pub name: String,
pub snippet: Option<String>
} }
pub fn scope_completion(file: &File, offset: TextUnit) -> Option<Vec<CompletionItem>> { pub fn scope_completion(file: &File, offset: TextUnit) -> Option<Vec<CompletionItem>> {
@ -33,7 +34,10 @@ pub fn scope_completion(file: &File, offset: TextUnit) -> Option<Vec<CompletionI
let scope = ModuleScope::new(root); let scope = ModuleScope::new(root);
res.extend( res.extend(
scope.entries().iter() scope.entries().iter()
.map(|entry| CompletionItem { name: entry.name().to_string() }) .map(|entry| CompletionItem {
name: entry.name().to_string(),
snippet: None,
})
) )
} }
Some(res) Some(res)
@ -43,7 +47,10 @@ fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<Completi
acc.extend( acc.extend(
scopes.scope_chain(name_ref.syntax()) scopes.scope_chain(name_ref.syntax())
.flat_map(|scope| scopes.entries(scope).iter()) .flat_map(|scope| scopes.entries(scope).iter())
.map(|entry| CompletionItem { name: entry.name().to_string() }) .map(|entry| CompletionItem {
name: entry.name().to_string(),
snippet: None,
})
) )
} }