From fc01c7846d5c6970e194dd223e49b863b3189432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 11 Aug 2020 09:54:33 +0300 Subject: Use Hygiene in completion --- crates/ra_ide/src/completion/completion_context.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 6b03b30bb..4aa761148 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -27,7 +27,7 @@ pub(crate) struct CompletionContext<'a> { pub(super) scope: SemanticsScope<'a>, pub(super) db: &'a RootDatabase, pub(super) config: &'a CompletionConfig, - pub(super) offset: TextSize, + pub(super) position: FilePosition, /// The token before the cursor, in the original file. pub(super) original_token: SyntaxToken, /// The token before the cursor, in the macro-expanded file. @@ -117,7 +117,7 @@ impl<'a> CompletionContext<'a> { config, original_token, token, - offset: position.offset, + position, krate, expected_type: None, name_ref_syntax: None, @@ -209,7 +209,7 @@ impl<'a> CompletionContext<'a> { mark::hit!(completes_if_prefix_is_keyword); self.original_token.text_range() } else { - TextRange::empty(self.offset) + TextRange::empty(self.position.offset) } } @@ -379,8 +379,8 @@ impl<'a> CompletionContext<'a> { self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); self.has_type_args = segment.generic_arg_list().is_some(); - #[allow(deprecated)] - if let Some(path) = hir::Path::from_ast(path.clone()) { + let hygiene = hir::Hygiene::new(self.db, self.position.file_id.into()); + if let Some(path) = hir::Path::from_src(path.clone(), &hygiene) { if let Some(path_prefix) = path.qualifier() { self.path_prefix = Some(path_prefix); return; -- cgit v1.2.3