refactor completions to use TextEdit instead of InsertText

This commit is contained in:
gfreezy
2019-01-19 22:02:50 +08:00
parent fa43ef30f4
commit d08e81cdd8
54 changed files with 2320 additions and 313 deletions

View File

@@ -12,7 +12,7 @@ use crate::{db, FilePosition};
/// `CompletionContext` is created early during completion to figure out, where
/// exactly is the cursor, syntax-wise.
#[derive(Debug)]
pub(super) struct CompletionContext<'a> {
pub(crate) struct CompletionContext<'a> {
pub(super) db: &'a db::RootDatabase,
pub(super) offset: TextUnit,
pub(super) leaf: &'a SyntaxNode,
@@ -65,6 +65,10 @@ impl<'a> CompletionContext<'a> {
Some(ctx)
}
pub(crate) fn leaf_range(&self) -> TextRange {
self.leaf.range()
}
fn fill(&mut self, original_file: &'a SourceFile, offset: TextUnit) {
// Insert a fake ident to get a valid parse tree. We will use this file
// to determine context, though the original_file will be used for