From 125744c057a953b2f1b03042e9a6ec49f1eb0a1e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 14 Aug 2020 15:23:27 +0200 Subject: Rename hypothetical -> speculative --- crates/hir/src/semantics.rs | 9 ++++----- crates/ide/src/completion/completion_context.rs | 2 +- crates/ssr/src/resolving.rs | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index d8beac98a..3953017c3 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -112,14 +112,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { pub fn expand(&self, macro_call: &ast::MacroCall) -> Option { self.imp.expand(macro_call) } - - pub fn expand_hypothetical( + pub fn speculative_expand( &self, actual_macro_call: &ast::MacroCall, hypothetical_args: &ast::TokenTree, token_to_map: SyntaxToken, ) -> Option<(SyntaxNode, SyntaxToken)> { - self.imp.expand_hypothetical(actual_macro_call, hypothetical_args, token_to_map) + self.imp.speculative_expand(actual_macro_call, hypothetical_args, token_to_map) } pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { @@ -311,7 +310,7 @@ impl<'db> SemanticsImpl<'db> { Some(node) } - fn expand_hypothetical( + fn speculative_expand( &self, actual_macro_call: &ast::MacroCall, hypothetical_args: &ast::TokenTree, @@ -756,7 +755,7 @@ impl<'a> SemanticsScope<'a> { /// Resolve a path as-if it was written at the given scope. This is /// necessary a heuristic, as it doesn't take hygiene into account. - pub fn resolve_hypothetical(&self, path: &ast::Path) -> Option { + pub fn speculative_resolve(&self, path: &ast::Path) -> Option { let hygiene = Hygiene::new(self.db.upcast(), self.file_id); let path = Path::from_src(path.clone(), &hygiene)?; self.resolve_hir_path(&path) diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 3857dce67..85456a66f 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs @@ -185,7 +185,7 @@ impl<'a> CompletionContext<'a> { }; if let (Some(actual_expansion), Some(hypothetical_expansion)) = ( ctx.sema.expand(&actual_macro_call), - ctx.sema.expand_hypothetical( + ctx.sema.speculative_expand( &actual_macro_call, &hypothetical_args, fake_ident_token, diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs index 4441fb426..b932132d5 100644 --- a/crates/ssr/src/resolving.rs +++ b/crates/ssr/src/resolving.rs @@ -212,13 +212,13 @@ impl<'db> ResolutionScope<'db> { // First try resolving the whole path. This will work for things like // `std::collections::HashMap`, but will fail for things like // `std::collections::HashMap::new`. - if let Some(resolution) = self.scope.resolve_hypothetical(&path) { + if let Some(resolution) = self.scope.speculative_resolve(&path) { return Some(resolution); } // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if // that succeeds, then iterate through the candidates on the resolved type with the provided // name. - let resolved_qualifier = self.scope.resolve_hypothetical(&path.qualifier()?)?; + let resolved_qualifier = self.scope.speculative_resolve(&path.qualifier()?)?; if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier { let name = path.segment()?.name_ref()?; adt.ty(self.scope.db).iterate_path_candidates( -- cgit v1.2.3