mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Simplify
This commit is contained in:
parent
7b34c4c002
commit
80113876e2
1 changed files with 14 additions and 13 deletions
|
@ -40,13 +40,8 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
|
||||||
} else if num_params > 1 {
|
} else if num_params > 1 {
|
||||||
// Count how many parameters into the call we are.
|
// Count how many parameters into the call we are.
|
||||||
if let Some(arg_list) = calling_node.arg_list() {
|
if let Some(arg_list) = calling_node.arg_list() {
|
||||||
// Number of arguments specified at the caller site
|
// Number of arguments specified at the call site
|
||||||
let mut num_args_of_call = arg_list.args().count();
|
let num_args_at_callsite = arg_list.args().count();
|
||||||
|
|
||||||
// If we are calling a method account for the `self` argument.
|
|
||||||
if has_self {
|
|
||||||
num_args_of_call = num_args_of_call + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let arg_list_range = arg_list.syntax().range();
|
let arg_list_range = arg_list.syntax().range();
|
||||||
if !arg_list_range.contains_inclusive(position.offset) {
|
if !arg_list_range.contains_inclusive(position.offset) {
|
||||||
|
@ -54,12 +49,18 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let param = arg_list
|
let mut param = std::cmp::min(
|
||||||
.args()
|
num_args_at_callsite,
|
||||||
.position(|arg| arg.syntax().range().contains(position.offset))
|
arg_list
|
||||||
.or(Some(num_params - 1))
|
.args()
|
||||||
.min(Some(num_args_of_call))
|
.take_while(|arg| arg.syntax().range().end() < position.offset)
|
||||||
.unwrap();
|
.count(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// If we are in a method account for `self`
|
||||||
|
if has_self {
|
||||||
|
param = param + 1;
|
||||||
|
}
|
||||||
|
|
||||||
call_info.active_parameter = Some(param);
|
call_info.active_parameter = Some(param);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue