mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
parent
b85c189500
commit
1cd5966462
1 changed files with 7 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
use ra_db::SourceDatabase;
|
use ra_db::SourceDatabase;
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
AstNode, SyntaxNode, TextUnit, TextRange,
|
AstNode, SyntaxNode, TextUnit,
|
||||||
SyntaxKind::FN_DEF,
|
SyntaxKind::FN_DEF,
|
||||||
ast::{self, ArgListOwner},
|
ast::{self, ArgListOwner},
|
||||||
algo::find_node_at_offset,
|
algo::find_node_at_offset,
|
||||||
|
@ -38,28 +38,20 @@ 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.
|
||||||
// TODO: This is best effort for now and should be fixed at some point.
|
|
||||||
// It may be better to see where we are in the arg_list and then check
|
|
||||||
// where offset is in that list (or beyond).
|
|
||||||
// Revisit this after we get documentation comments in.
|
|
||||||
if let Some(ref arg_list) = calling_node.arg_list() {
|
if let Some(ref arg_list) = calling_node.arg_list() {
|
||||||
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) {
|
||||||
tested_by!(call_info_bad_offset);
|
tested_by!(call_info_bad_offset);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let start = arg_list_range.start();
|
|
||||||
|
|
||||||
let range_search = TextRange::from_to(start, position.offset);
|
let param = arg_list
|
||||||
let mut commas: usize =
|
.args()
|
||||||
arg_list.syntax().text().slice(range_search).to_string().matches(',').count();
|
.position(|arg| arg.syntax().range().contains(position.offset))
|
||||||
|
.or(Some(num_params - 1))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// If we have a method call eat the first param since it's just self.
|
call_info.active_parameter = Some(param);
|
||||||
if has_self {
|
|
||||||
commas += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
call_info.active_parameter = Some(commas);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue