From 61e1474ab35deb7d54cc2f5d710b901f200b6467 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 28 May 2019 18:46:11 +0300 Subject: fix typos in mbe tests --- crates/ra_ide_api/src/completion/completion_context.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide_api/src/completion') diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index a8c8cc7b0..bda7d9bb2 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -1,6 +1,6 @@ use ra_text_edit::AtomTextEdit; use ra_syntax::{ - AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, + AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, Parse, ast, algo::{find_token_at_offset, find_covering_element, find_node_at_offset}, SyntaxKind::*, @@ -43,11 +43,12 @@ pub(crate) struct CompletionContext<'a> { impl<'a> CompletionContext<'a> { pub(super) fn new( db: &'a db::RootDatabase, - original_file: &'a SourceFile, + original_parse: &'a Parse, position: FilePosition, ) -> Option> { let module = source_binder::module_from_position(db, position); - let token = find_token_at_offset(original_file.syntax(), position.offset).left_biased()?; + let token = + find_token_at_offset(original_parse.tree.syntax(), position.offset).left_biased()?; let analyzer = hir::SourceAnalyzer::new(db, position.file_id, token.parent(), Some(position.offset)); let mut ctx = CompletionContext { @@ -69,7 +70,7 @@ impl<'a> CompletionContext<'a> { dot_receiver: None, is_call: false, }; - ctx.fill(original_file, position.offset); + ctx.fill(&original_parse, position.offset); Some(ctx) } @@ -82,13 +83,13 @@ impl<'a> CompletionContext<'a> { } } - fn fill(&mut self, original_file: &'a SourceFile, offset: TextUnit) { + fn fill(&mut self, original_parse: &'a Parse, 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 // actual completion. let file = { let edit = AtomTextEdit::insert(offset, "intellijRulezz".to_string()); - original_file.reparse(&edit) + original_parse.reparse(&edit).tree }; // First, let's try to complete a reference to some declaration. @@ -99,7 +100,7 @@ impl<'a> CompletionContext<'a> { self.is_param = true; return; } - self.classify_name_ref(original_file, name_ref); + self.classify_name_ref(&original_parse.tree, name_ref); } // Otherwise, see if this is a declaration. We can use heuristics to -- cgit v1.2.3