From 806ea03b64455a0c10fd8a8d6d98ed4e7ac15058 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 28 Nov 2018 01:22:17 +0300 Subject: drop descriptor suffix, use hir:: instead --- crates/ra_analysis/src/hir/function/mod.rs | 20 ++++++++++---------- crates/ra_analysis/src/hir/mod.rs | 2 +- crates/ra_analysis/src/hir/module/nameres.rs | 4 ++-- crates/ra_analysis/src/imp.rs | 13 ++++++------- 4 files changed, 19 insertions(+), 20 deletions(-) (limited to 'crates/ra_analysis') diff --git a/crates/ra_analysis/src/hir/function/mod.rs b/crates/ra_analysis/src/hir/function/mod.rs index d171b6a8d..9ca8f4e7c 100644 --- a/crates/ra_analysis/src/hir/function/mod.rs +++ b/crates/ra_analysis/src/hir/function/mod.rs @@ -25,43 +25,43 @@ impl FnId { } } -pub(crate) struct FunctionDescriptor { +pub(crate) struct Function { fn_id: FnId, } -impl FunctionDescriptor { +impl Function { pub(crate) fn guess_from_source( db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef, - ) -> FunctionDescriptor { + ) -> Function { let fn_id = FnId::get(db, file_id, fn_def); - FunctionDescriptor { fn_id } + Function { fn_id } } pub(crate) fn guess_for_name_ref( db: &impl HirDatabase, file_id: FileId, name_ref: ast::NameRef, - ) -> Option { - FunctionDescriptor::guess_for_node(db, file_id, name_ref.syntax()) + ) -> Option { + Function::guess_for_node(db, file_id, name_ref.syntax()) } pub(crate) fn guess_for_bind_pat( db: &impl HirDatabase, file_id: FileId, bind_pat: ast::BindPat, - ) -> Option { - FunctionDescriptor::guess_for_node(db, file_id, bind_pat.syntax()) + ) -> Option { + Function::guess_for_node(db, file_id, bind_pat.syntax()) } fn guess_for_node( db: &impl HirDatabase, file_id: FileId, node: SyntaxNodeRef, - ) -> Option { + ) -> Option { let fn_def = node.ancestors().find_map(ast::FnDef::cast)?; - let res = FunctionDescriptor::guess_from_source(db, file_id, fn_def); + let res = Function::guess_from_source(db, file_id, fn_def); Some(res) } diff --git a/crates/ra_analysis/src/hir/mod.rs b/crates/ra_analysis/src/hir/mod.rs index 1de8fadcf..863ffd919 100644 --- a/crates/ra_analysis/src/hir/mod.rs +++ b/crates/ra_analysis/src/hir/mod.rs @@ -20,7 +20,7 @@ use crate::{ pub(crate) use self::{ path::{Path, PathKind}, module::{Module, ModuleId, Problem, nameres::FileItemId}, - function::{FunctionDescriptor, FnScopes}, + function::{Function, FnScopes}, }; pub use self::function::FnSignatureInfo; diff --git a/crates/ra_analysis/src/hir/module/nameres.rs b/crates/ra_analysis/src/hir/module/nameres.rs index db5d6d9c0..2ff5e0537 100644 --- a/crates/ra_analysis/src/hir/module/nameres.rs +++ b/crates/ra_analysis/src/hir/module/nameres.rs @@ -371,7 +371,7 @@ mod tests { use crate::{ AnalysisChange, mock_analysis::{MockAnalysis, analysis_and_position}, - hir::{HirDatabase, module::ModuleDescriptor}, + hir::{self, HirDatabase}, input::FilesDatabase, }; use super::*; @@ -380,7 +380,7 @@ mod tests { let (analysis, pos) = analysis_and_position(fixture); let db = analysis.imp.db; let source_root = db.file_source_root(pos.file_id); - let descr = ModuleDescriptor::guess_from_position(&*db, pos) + let descr = hir::Module::guess_from_position(&*db, pos) .unwrap() .unwrap(); let module_id = descr.module_id; diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 9118ed7d4..2e5853949 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -21,7 +21,7 @@ use crate::{ db::{self, FileSyntaxQuery, SyntaxDatabase}, hir::{ self, - FunctionDescriptor, FnSignatureInfo, + FnSignatureInfo, Problem, }, input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, @@ -274,7 +274,7 @@ impl AnalysisImpl { let syntax = file.syntax(); if let Some(name_ref) = find_node_at_offset::(syntax, position.offset) { if let Some(fn_descr) = - FunctionDescriptor::guess_for_name_ref(&*self.db, position.file_id, name_ref) + hir::Function::guess_for_name_ref(&*self.db, position.file_id, name_ref) { let scope = fn_descr.scope(&*self.db); // First try to resolve the symbol locally @@ -344,14 +344,14 @@ impl AnalysisImpl { db: &db::RootDatabase, source_file: &'a SourceFileNode, position: FilePosition, - ) -> Option<(ast::BindPat<'a>, FunctionDescriptor)> { + ) -> Option<(ast::BindPat<'a>, hir::Function)> { let syntax = source_file.syntax(); if let Some(binding) = find_node_at_offset::(syntax, position.offset) { - let descr = FunctionDescriptor::guess_for_bind_pat(db, position.file_id, binding)?; + let descr = hir::Function::guess_for_bind_pat(db, position.file_id, binding)?; return Some((binding, descr)); }; let name_ref = find_node_at_offset::(syntax, position.offset)?; - let descr = FunctionDescriptor::guess_for_name_ref(db, position.file_id, name_ref)?; + let descr = hir::Function::guess_for_name_ref(db, position.file_id, name_ref)?; let scope = descr.scope(db); let resolved = scope.resolve_local_name(name_ref)?; let resolved = resolved.ptr().resolve(source_file); @@ -472,8 +472,7 @@ impl AnalysisImpl { if fs.kind == FN_DEF { let fn_file = self.db.file_syntax(fn_file_id); if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) { - let descr = - FunctionDescriptor::guess_from_source(&*self.db, fn_file_id, fn_def); + let descr = hir::Function::guess_from_source(&*self.db, fn_file_id, fn_def); if let Some(descriptor) = descr.signature_info(&*self.db) { // If we have a calling expression let's find which argument we are on let mut current_parameter = None; -- cgit v1.2.3