diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display.rs | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 66a769c73..dbb3853d0 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -6,7 +6,6 @@ use ra_syntax::{ | |||
6 | ast::{self, ArgListOwner}, | 6 | ast::{self, ArgListOwner}, |
7 | algo::find_node_at_offset, | 7 | algo::find_node_at_offset, |
8 | }; | 8 | }; |
9 | use hir::Docs; | ||
10 | 9 | ||
11 | use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase}; | 10 | use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase}; |
12 | 11 | ||
@@ -27,7 +26,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
27 | let fn_def = ast::FnDef::cast(fn_def).unwrap(); | 26 | let fn_def = ast::FnDef::cast(fn_def).unwrap(); |
28 | let function = hir::source_binder::function_from_source(db, symbol.file_id, fn_def)?; | 27 | let function = hir::source_binder::function_from_source(db, symbol.file_id, fn_def)?; |
29 | 28 | ||
30 | let mut call_info = CallInfo::new(db, function, fn_def)?; | 29 | let mut call_info = CallInfo::new(db, function); |
31 | 30 | ||
32 | // If we have a calling expression let's find which argument we are on | 31 | // If we have a calling expression let's find which argument we are on |
33 | let num_params = call_info.parameters().len(); | 32 | let num_params = call_info.parameters().len(); |
@@ -107,11 +106,10 @@ impl<'a> FnCallNode<'a> { | |||
107 | } | 106 | } |
108 | 107 | ||
109 | impl CallInfo { | 108 | impl CallInfo { |
110 | fn new(db: &RootDatabase, function: hir::Function, node: &ast::FnDef) -> Option<Self> { | 109 | fn new(db: &RootDatabase, function: hir::Function) -> Self { |
111 | let doc = function.docs(db); | 110 | let signature = FunctionSignature::from_hir(db, function); |
112 | let signature = FunctionSignature::from(node).with_doc_opt(doc); | ||
113 | 111 | ||
114 | Some(CallInfo { signature, active_parameter: None }) | 112 | CallInfo { signature, active_parameter: None } |
115 | } | 113 | } |
116 | 114 | ||
117 | fn parameters(&self) -> &[String] { | 115 | fn parameters(&self) -> &[String] { |
diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide_api/src/display.rs index 4ce362ebb..c05d59689 100644 --- a/crates/ra_ide_api/src/display.rs +++ b/crates/ra_ide_api/src/display.rs | |||
@@ -5,6 +5,7 @@ use std::fmt::{self, Display}; | |||
5 | use join_to_string::join; | 5 | use join_to_string::join; |
6 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner, TypeParamsOwner}; | 6 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner, TypeParamsOwner}; |
7 | use std::convert::From; | 7 | use std::convert::From; |
8 | use hir::Docs; | ||
8 | 9 | ||
9 | /// Contains information about a function signature | 10 | /// Contains information about a function signature |
10 | #[derive(Debug)] | 11 | #[derive(Debug)] |
@@ -30,6 +31,12 @@ impl FunctionSignature { | |||
30 | self.doc = doc; | 31 | self.doc = doc; |
31 | self | 32 | self |
32 | } | 33 | } |
34 | |||
35 | pub(crate) fn from_hir(db: &db::RootDatabase, function: hir::Function) -> Self { | ||
36 | let doc = function.docs(db); | ||
37 | let (_, ast_node) = function.source(db); | ||
38 | FunctionSignature::from(&*ast_node).with_doc_opt(doc) | ||
39 | } | ||
33 | } | 40 | } |
34 | 41 | ||
35 | impl From<&'_ ast::FnDef> for FunctionSignature { | 42 | impl From<&'_ ast::FnDef> for FunctionSignature { |