mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 14:43:58 +00:00
simplify
This commit is contained in:
parent
db794abe66
commit
6f02f176c8
1 changed files with 34 additions and 40 deletions
|
@ -21,12 +21,11 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Cancelable
|
||||||
|
|
||||||
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
||||||
let file_symbols = db.index_resolve(name_ref)?;
|
let file_symbols = db.index_resolve(name_ref)?;
|
||||||
for symbol in file_symbols {
|
let symbol = ctry!(file_symbols.into_iter().find(|it| it.ptr.kind() == FN_DEF));
|
||||||
if symbol.ptr.kind() == FN_DEF {
|
|
||||||
let fn_file = db.source_file(symbol.file_id);
|
let fn_file = db.source_file(symbol.file_id);
|
||||||
let fn_def = symbol.ptr.resolve(&fn_file);
|
let fn_def = symbol.ptr.resolve(&fn_file);
|
||||||
let fn_def = ast::FnDef::cast(&fn_def).unwrap();
|
let fn_def = ast::FnDef::cast(&fn_def).unwrap();
|
||||||
if let Some(mut call_info) = CallInfo::new(fn_def) {
|
let mut call_info = ctry!(CallInfo::new(fn_def));
|
||||||
// If we have a calling expression let's find which argument we are on
|
// If we have a calling expression let's find which argument we are on
|
||||||
let num_params = call_info.parameters.len();
|
let num_params = call_info.parameters.len();
|
||||||
let has_self = fn_def.param_list().and_then(|l| l.self_param()).is_some();
|
let has_self = fn_def.param_list().and_then(|l| l.self_param()).is_some();
|
||||||
|
@ -62,12 +61,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Cancelable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(Some(call_info));
|
Ok(Some(call_info))
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(None)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FnCallNode<'a> {
|
enum FnCallNode<'a> {
|
||||||
|
|
Loading…
Reference in a new issue