only def-with-body remains
This commit is contained in:
parent
d88269bc2d
commit
d4043a8dba
1 changed files with 3 additions and 13 deletions
|
@ -12,6 +12,7 @@ use ra_syntax::{
|
||||||
SyntaxNode, AstPtr, TextUnit,
|
SyntaxNode, AstPtr, TextUnit,
|
||||||
ast::{self, AstNode, NameOwner},
|
ast::{self, AstNode, NameOwner},
|
||||||
algo::find_node_at_offset,
|
algo::find_node_at_offset,
|
||||||
|
SyntaxKind::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -90,17 +91,6 @@ fn module_from_source(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn function_from_source(
|
|
||||||
db: &impl HirDatabase,
|
|
||||||
file_id: FileId,
|
|
||||||
fn_def: &ast::FnDef,
|
|
||||||
) -> Option<Function> {
|
|
||||||
let module = module_from_child_node(db, file_id, fn_def.syntax())?;
|
|
||||||
let file_id = file_id.into();
|
|
||||||
let ctx = LocationCtx::new(db, module, file_id);
|
|
||||||
Some(Function { id: ctx.to_def(fn_def) })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn struct_from_module(
|
pub fn struct_from_module(
|
||||||
db: &impl HirDatabase,
|
db: &impl HirDatabase,
|
||||||
module: Module,
|
module: Module,
|
||||||
|
@ -168,8 +158,8 @@ fn try_get_resolver_for_node(
|
||||||
} else if let Some(e) = ast::EnumDef::cast(node) {
|
} else if let Some(e) = ast::EnumDef::cast(node) {
|
||||||
let module = module_from_child_node(db, file_id, e.syntax())?;
|
let module = module_from_child_node(db, file_id, e.syntax())?;
|
||||||
Some(enum_from_module(db, module, e).resolver(db))
|
Some(enum_from_module(db, module, e).resolver(db))
|
||||||
} else if let Some(f) = ast::FnDef::cast(node) {
|
} else if node.kind() == FN_DEF || node.kind() == CONST_DEF || node.kind() == STATIC_DEF {
|
||||||
function_from_source(db, file_id, f).map(|f| f.resolver(db))
|
Some(def_with_body_from_child_node(db, file_id, node)?.resolver(db))
|
||||||
} else {
|
} else {
|
||||||
// FIXME add missing cases
|
// FIXME add missing cases
|
||||||
None
|
None
|
||||||
|
|
Loading…
Add table
Reference in a new issue