mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
move resolve_local to Scopes
This commit is contained in:
parent
7207eef716
commit
16f67ee384
6 changed files with 105 additions and 109 deletions
|
@ -6,8 +6,8 @@ use std::{
|
|||
};
|
||||
|
||||
use ra_syntax::{
|
||||
TextRange, TextUnit, SyntaxNodeRef,
|
||||
ast::{self, AstNode, DocCommentsOwner, NameOwner},
|
||||
TextRange, TextUnit,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
@ -39,6 +39,32 @@ impl FunctionDescriptor {
|
|||
FunctionDescriptor { 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())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
fn guess_for_node(
|
||||
db: &impl HirDatabase,
|
||||
file_id: FileId,
|
||||
node: SyntaxNodeRef,
|
||||
) -> Option<FunctionDescriptor> {
|
||||
let fn_def = node.ancestors().find_map(ast::FnDef::cast)?;
|
||||
let res = FunctionDescriptor::guess_from_source(db, file_id, fn_def);
|
||||
Some(res)
|
||||
}
|
||||
|
||||
pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
||||
db.fn_scopes(self.fn_id)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue