Add FunctionSignature::from_hir

This commit is contained in:
Ville Penttinen 2019-04-08 10:46:26 +03:00
parent 2fe075f56e
commit dfaebd76ab
2 changed files with 11 additions and 6 deletions

View file

@ -5,6 +5,7 @@ use std::fmt::{self, Display};
use join_to_string::join;
use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner, TypeParamsOwner};
use std::convert::From;
use hir::Docs;
/// Contains information about a function signature
#[derive(Debug)]
@ -30,6 +31,12 @@ impl FunctionSignature {
self.doc = doc;
self
}
pub(crate) fn from_hir(db: &db::RootDatabase, function: hir::Function) -> Self {
let doc = function.docs(db);
let (_, ast_node) = function.source(db);
FunctionSignature::from(&*ast_node).with_doc_opt(doc)
}
}
impl From<&'_ ast::FnDef> for FunctionSignature {