diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 15:27:44 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 15:27:44 +0000 |
commit | 256ec6e8d4ac46b2569713d2ffe92d102595f5d2 (patch) | |
tree | d28e4a31ff14549d6495f5fa307174d3884a0a08 /crates/ra_analysis | |
parent | e6a4383bb475b866b67df6bb83ecbdf823d73667 (diff) |
introduce CallInfo
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/call_info.rs | 15 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 13 |
2 files changed, 22 insertions, 6 deletions
diff --git a/crates/ra_analysis/src/call_info.rs b/crates/ra_analysis/src/call_info.rs index a31a54ef6..8da19a648 100644 --- a/crates/ra_analysis/src/call_info.rs +++ b/crates/ra_analysis/src/call_info.rs | |||
@@ -7,10 +7,21 @@ use ra_syntax::{ | |||
7 | use ra_editor::find_node_at_offset; | 7 | use ra_editor::find_node_at_offset; |
8 | use hir::FnSignatureInfo; | 8 | use hir::FnSignatureInfo; |
9 | 9 | ||
10 | use crate::{FilePosition, db::RootDatabase}; | 10 | use crate::{FilePosition, CallInfo, db::RootDatabase}; |
11 | |||
12 | pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Cancelable<Option<CallInfo>> { | ||
13 | let (sig_info, active_parameter) = ctry!(call_info_(db, position)?); | ||
14 | let res = CallInfo { | ||
15 | label: sig_info.label, | ||
16 | doc: sig_info.doc, | ||
17 | parameters: sig_info.params, | ||
18 | active_parameter, | ||
19 | }; | ||
20 | Ok(Some(res)) | ||
21 | } | ||
11 | 22 | ||
12 | /// Computes parameter information for the given call expression. | 23 | /// Computes parameter information for the given call expression. |
13 | pub(crate) fn call_info( | 24 | fn call_info_( |
14 | db: &RootDatabase, | 25 | db: &RootDatabase, |
15 | position: FilePosition, | 26 | position: FilePosition, |
16 | ) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> { | 27 | ) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> { |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 9192f66e8..4fa6750aa 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -273,6 +273,14 @@ impl<T> RangeInfo<T> { | |||
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | #[derive(Debug)] | ||
277 | pub struct CallInfo { | ||
278 | pub label: String, | ||
279 | pub doc: Option<String>, | ||
280 | pub parameters: Vec<String>, | ||
281 | pub active_parameter: Option<usize>, | ||
282 | } | ||
283 | |||
276 | /// `AnalysisHost` stores the current state of the world. | 284 | /// `AnalysisHost` stores the current state of the world. |
277 | #[derive(Debug, Default)] | 285 | #[derive(Debug, Default)] |
278 | pub struct AnalysisHost { | 286 | pub struct AnalysisHost { |
@@ -393,10 +401,7 @@ impl Analysis { | |||
393 | hover::hover(&*self.db, position) | 401 | hover::hover(&*self.db, position) |
394 | } | 402 | } |
395 | /// Computes parameter information for the given call expression. | 403 | /// Computes parameter information for the given call expression. |
396 | pub fn call_info( | 404 | pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { |
397 | &self, | ||
398 | position: FilePosition, | ||
399 | ) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> { | ||
400 | call_info::call_info(&*self.db, position) | 405 | call_info::call_info(&*self.db, position) |
401 | } | 406 | } |
402 | /// Returns a `mod name;` declaration which created the current module. | 407 | /// Returns a `mod name;` declaration which created the current module. |