From a450142aca947b9364e498897f522f854f19781d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 26 Aug 2018 09:12:18 +0300 Subject: fix stray curly --- crates/libeditor/src/completion.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 crates/libeditor/src/completion.rs (limited to 'crates/libeditor/src/completion.rs') diff --git a/crates/libeditor/src/completion.rs b/crates/libeditor/src/completion.rs new file mode 100644 index 000000000..cf61ec784 --- /dev/null +++ b/crates/libeditor/src/completion.rs @@ -0,0 +1,31 @@ +use libsyntax2::{ + File, TextUnit, + ast, + algo::find_leaf_at_offset, +}; + +use { + AtomEdit, find_node_at_offset, +}; + +#[derive(Debug)] +pub struct CompletionItem { + name: String, +} + +pub fn scope_completion(file: &File, offset: TextUnit) -> Option> { + // Insert a fake ident to get a valid parse tree + let file = { + let edit = AtomEdit::insert(offset, "intellijRulezz".to_string()); + // Don't bother with completion if incremental reparse fails + file.incremental_reparse(&edit)? + }; + let name_ref = find_node_at_offset::(file.syntax(), offset)?; + Some(complete(name_ref)) +} + +fn complete(name_ref: ast::NameRef) -> Vec { + vec![CompletionItem { + name: "foo".to_string() + }] +} -- cgit v1.2.3