From d08e81cdd818dd3378c292767e15a38e6bbc6f6c Mon Sep 17 00:00:00 2001 From: gfreezy Date: Sat, 19 Jan 2019 22:02:50 +0800 Subject: refactor completions to use TextEdit instead of InsertText --- crates/ra_ide_api/src/completion/completion_context.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/completion/completion_context.rs') diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index e537e0082..de9b95c81 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -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 -- cgit v1.2.3