mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
itroduce FunctionDescriptor
This commit is contained in:
parent
f4d0cb64fc
commit
109a7f3717
3 changed files with 36 additions and 9 deletions
|
@ -1,7 +1,10 @@
|
|||
pub(super) mod imp;
|
||||
mod scope;
|
||||
|
||||
use std::cmp::{max, min};
|
||||
use std::{
|
||||
cmp::{max, min},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, DocCommentsOwner, NameOwner},
|
||||
|
@ -9,6 +12,7 @@ use ra_syntax::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
hir::HirDatabase,
|
||||
syntax_ptr::SyntaxPtr, FileId,
|
||||
loc2id::IdDatabase,
|
||||
};
|
||||
|
@ -23,6 +27,25 @@ impl FnId {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) struct FunctionDescriptor {
|
||||
fn_id: FnId,
|
||||
}
|
||||
|
||||
impl FunctionDescriptor {
|
||||
pub(crate) fn guess_from_source(
|
||||
db: &impl HirDatabase,
|
||||
file_id: FileId,
|
||||
fn_def: ast::FnDef,
|
||||
) -> FunctionDescriptor {
|
||||
let fn_id = FnId::get(db, file_id, fn_def);
|
||||
FunctionDescriptor { fn_id }
|
||||
}
|
||||
|
||||
pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
||||
db.fn_scopes(self.fn_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FnDescriptor {
|
||||
pub name: String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue