From b77d780f0e9e7902695b949a25588fcb66bb5982 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Mon, 21 Jan 2019 21:42:37 -0500 Subject: Thread documentation through FnSignature and CompletionItem --- crates/ra_hir/src/code_model_api.rs | 5 +++++ crates/ra_hir/src/code_model_impl/function.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 88eda5ed0..57f405f4f 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -297,6 +297,7 @@ pub struct FnSignature { /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. pub(crate) has_self_param: bool, + pub(crate) documentation: String, } impl FnSignature { @@ -317,6 +318,10 @@ impl FnSignature { pub fn has_self_param(&self) -> bool { self.has_self_param } + + pub fn documentation(&self) -> &String { + &self.documentation + } } impl Function { diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index 66d7e1713..c848f7a82 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs @@ -2,7 +2,7 @@ mod scope; use std::sync::Arc; -use ra_syntax::{TreeArc, ast::{self, NameOwner}}; +use ra_syntax::{TreeArc, ast::{self, NameOwner, DocCommentsOwner}}; use crate::{ DefId, HirDatabase, Name, AsName, Function, FnSignature, Module, @@ -72,11 +72,15 @@ impl FnSignature { } else { TypeRef::unit() }; + + let comments = node.doc_comment_text(); + let sig = FnSignature { name, params, ret_type, has_self_param, + documentation: comments, }; Arc::new(sig) } -- cgit v1.2.3