From 45112aa8c0a55f003acc3b20646e840909dea08f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 24 May 2021 22:21:25 +0300 Subject: internal: rename hypothetical -> speculative Lets steal this good naming from Roslyn before I forget about it yet again. --- crates/ide_completion/src/context.rs | 20 ++++++++++---------- crates/ide_completion/src/lib.rs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 1ec59ff80..2f3fb1710 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -196,46 +196,46 @@ impl<'a> CompletionContext<'a> { }; let mut original_file = original_file.syntax().clone(); - let mut hypothetical_file = file_with_fake_ident.syntax().clone(); + let mut speculative_file = file_with_fake_ident.syntax().clone(); let mut offset = position.offset; let mut fake_ident_token = fake_ident_token; // Are we inside a macro call? while let (Some(actual_macro_call), Some(macro_call_with_fake_ident)) = ( find_node_at_offset::(&original_file, offset), - find_node_at_offset::(&hypothetical_file, offset), + find_node_at_offset::(&speculative_file, offset), ) { if actual_macro_call.path().as_ref().map(|s| s.syntax().text()) != macro_call_with_fake_ident.path().as_ref().map(|s| s.syntax().text()) { break; } - let hypothetical_args = match macro_call_with_fake_ident.token_tree() { + let speculative_args = match macro_call_with_fake_ident.token_tree() { Some(tt) => tt, None => break, }; - if let (Some(actual_expansion), Some(hypothetical_expansion)) = ( + if let (Some(actual_expansion), Some(speculative_expansion)) = ( ctx.sema.expand(&actual_macro_call), ctx.sema.speculative_expand( &actual_macro_call, - &hypothetical_args, + &speculative_args, fake_ident_token, ), ) { - let new_offset = hypothetical_expansion.1.text_range().start(); + let new_offset = speculative_expansion.1.text_range().start(); if new_offset > actual_expansion.text_range().end() { break; } original_file = actual_expansion; - hypothetical_file = hypothetical_expansion.0; - fake_ident_token = hypothetical_expansion.1; + speculative_file = speculative_expansion.0; + fake_ident_token = speculative_expansion.1; offset = new_offset; } else { break; } } - ctx.fill_keyword_patterns(&hypothetical_file, offset); - ctx.fill(&original_file, hypothetical_file, offset); + ctx.fill_keyword_patterns(&speculative_file, offset); + ctx.fill(&original_file, speculative_file, offset); Some(ctx) } diff --git a/crates/ide_completion/src/lib.rs b/crates/ide_completion/src/lib.rs index 645349215..1152a9850 100644 --- a/crates/ide_completion/src/lib.rs +++ b/crates/ide_completion/src/lib.rs @@ -107,7 +107,7 @@ pub use crate::{ /// identifier prefix/fuzzy match should be done higher in the stack, together /// with ordering of completions (currently this is done by the client). /// -/// # Hypothetical Completion Problem +/// # Speculative Completion Problem /// /// There's a curious unsolved problem in the current implementation. Often, you /// want to compute completions on a *slightly different* text document. @@ -121,7 +121,7 @@ pub use crate::{ /// doesn't allow such "phantom" inputs. /// /// Another case where this would be instrumental is macro expansion. We want to -/// insert a fake ident and re-expand code. There's `expand_hypothetical` as a +/// insert a fake ident and re-expand code. There's `expand_speculative` as a /// work-around for this. /// /// A different use-case is completion of injection (examples and links in doc -- cgit v1.2.3