aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api/src/call_info.rs22
1 files changed, 7 insertions, 15 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 1b279615c..c5e8d5843 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -1,7 +1,7 @@
1use test_utils::tested_by; 1use test_utils::tested_by;
2use ra_db::SourceDatabase; 2use ra_db::SourceDatabase;
3use ra_syntax::{ 3use ra_syntax::{
4 AstNode, SyntaxNode, TextUnit, TextRange, 4 AstNode, SyntaxNode, TextUnit,
5 SyntaxKind::FN_DEF, 5 SyntaxKind::FN_DEF,
6 ast::{self, ArgListOwner}, 6 ast::{self, ArgListOwner},
7 algo::find_node_at_offset, 7 algo::find_node_at_offset,
@@ -38,28 +38,20 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
38 } 38 }
39 } else if num_params > 1 { 39 } else if num_params > 1 {
40 // Count how many parameters into the call we are. 40 // Count how many parameters into the call we are.
41 // TODO: This is best effort for now and should be fixed at some point.
42 // It may be better to see where we are in the arg_list and then check
43 // where offset is in that list (or beyond).
44 // Revisit this after we get documentation comments in.
45 if let Some(ref arg_list) = calling_node.arg_list() { 41 if let Some(ref arg_list) = calling_node.arg_list() {
46 let arg_list_range = arg_list.syntax().range(); 42 let arg_list_range = arg_list.syntax().range();
47 if !arg_list_range.contains_inclusive(position.offset) { 43 if !arg_list_range.contains_inclusive(position.offset) {
48 tested_by!(call_info_bad_offset); 44 tested_by!(call_info_bad_offset);
49 return None; 45 return None;
50 } 46 }
51 let start = arg_list_range.start();
52 47
53 let range_search = TextRange::from_to(start, position.offset); 48 let param = arg_list
54 let mut commas: usize = 49 .args()
55 arg_list.syntax().text().slice(range_search).to_string().matches(',').count(); 50 .position(|arg| arg.syntax().range().contains(position.offset))
51 .or(Some(num_params - 1))
52 .unwrap();
56 53
57 // If we have a method call eat the first param since it's just self. 54 call_info.active_parameter = Some(param);
58 if has_self {
59 commas += 1;
60 }
61
62 call_info.active_parameter = Some(commas);
63 } 55 }
64 } 56 }
65 57