drop descriptor suffix, use hir:: instead
This commit is contained in:
parent
36b1d20c16
commit
806ea03b64
@ -25,43 +25,43 @@ pub(crate) fn get(db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef) ->
|
||||
}
|
||||
}
|
||||
|
||||
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> {
|
||||
FunctionDescriptor::guess_for_node(db, file_id, name_ref.syntax())
|
||||
) -> Option<Function> {
|
||||
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> {
|
||||
FunctionDescriptor::guess_for_node(db, file_id, bind_pat.syntax())
|
||||
) -> Option<Function> {
|
||||
Function::guess_for_node(db, file_id, bind_pat.syntax())
|
||||
}
|
||||
|
||||
fn guess_for_node(
|
||||
db: &impl HirDatabase,
|
||||
file_id: FileId,
|
||||
node: SyntaxNodeRef,
|
||||
) -> Option<FunctionDescriptor> {
|
||||
) -> Option<Function> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
pub(crate) use self::{
|
||||
path::{Path, PathKind},
|
||||
module::{Module, ModuleId, Problem, nameres::FileItemId},
|
||||
function::{FunctionDescriptor, FnScopes},
|
||||
function::{Function, FnScopes},
|
||||
};
|
||||
|
||||
pub use self::function::FnSignatureInfo;
|
||||
|
@ -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 @@ fn item_map(fixture: &str) -> (Arc<ItemMap>, ModuleId) {
|
||||
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;
|
||||
|
@ -21,7 +21,7 @@
|
||||
db::{self, FileSyntaxQuery, SyntaxDatabase},
|
||||
hir::{
|
||||
self,
|
||||
FunctionDescriptor, FnSignatureInfo,
|
||||
FnSignatureInfo,
|
||||
Problem,
|
||||
},
|
||||
input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE},
|
||||
@ -274,7 +274,7 @@ pub fn approximately_resolve_symbol(
|
||||
let syntax = file.syntax();
|
||||
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(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 @@ fn find_binding<'a>(
|
||||
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::<ast::BindPat>(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::<ast::NameRef>(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 @@ pub fn resolve_callable(
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user