diff options
author | Ville Penttinen <[email protected]> | 2019-04-08 08:46:26 +0100 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-04-09 12:45:05 +0100 |
commit | dfaebd76aba1cfd7ac13b940d7847eb44b953cac (patch) | |
tree | 1d3e6d2a6809ad3786880dade195bf8cd9a24560 /crates/ra_ide_api/src/display.rs | |
parent | 2fe075f56eff65ee6d326f7ea8bc0efccc4df152 (diff) |
Add FunctionSignature::from_hir
Diffstat (limited to 'crates/ra_ide_api/src/display.rs')
-rw-r--r-- | crates/ra_ide_api/src/display.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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 { |