diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 5 |
3 files changed, 15 insertions, 1 deletions
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 { | |||
297 | /// True if the first param is `self`. This is relevant to decide whether this | 297 | /// True if the first param is `self`. This is relevant to decide whether this |
298 | /// can be called as a method. | 298 | /// can be called as a method. |
299 | pub(crate) has_self_param: bool, | 299 | pub(crate) has_self_param: bool, |
300 | pub(crate) documentation: String, | ||
300 | } | 301 | } |
301 | 302 | ||
302 | impl FnSignature { | 303 | impl FnSignature { |
@@ -317,6 +318,10 @@ impl FnSignature { | |||
317 | pub fn has_self_param(&self) -> bool { | 318 | pub fn has_self_param(&self) -> bool { |
318 | self.has_self_param | 319 | self.has_self_param |
319 | } | 320 | } |
321 | |||
322 | pub fn documentation(&self) -> &String { | ||
323 | &self.documentation | ||
324 | } | ||
320 | } | 325 | } |
321 | 326 | ||
322 | impl Function { | 327 | 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; | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use ra_syntax::{TreeArc, ast::{self, NameOwner}}; | 5 | use ra_syntax::{TreeArc, ast::{self, NameOwner, DocCommentsOwner}}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | DefId, HirDatabase, Name, AsName, Function, FnSignature, Module, | 8 | DefId, HirDatabase, Name, AsName, Function, FnSignature, Module, |
@@ -72,11 +72,15 @@ impl FnSignature { | |||
72 | } else { | 72 | } else { |
73 | TypeRef::unit() | 73 | TypeRef::unit() |
74 | }; | 74 | }; |
75 | |||
76 | let comments = node.doc_comment_text(); | ||
77 | |||
75 | let sig = FnSignature { | 78 | let sig = FnSignature { |
76 | name, | 79 | name, |
77 | params, | 80 | params, |
78 | ret_type, | 81 | ret_type, |
79 | has_self_param, | 82 | has_self_param, |
83 | documentation: comments, | ||
80 | }; | 84 | }; |
81 | Arc::new(sig) | 85 | Arc::new(sig) |
82 | } | 86 | } |
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 672c7ed0e..dfaadbb20 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -259,6 +259,11 @@ impl Builder { | |||
259 | } | 259 | } |
260 | self.insert_text_format = InsertTextFormat::Snippet; | 260 | self.insert_text_format = InsertTextFormat::Snippet; |
261 | } | 261 | } |
262 | let sig = function.signature(ctx.db); | ||
263 | if !sig.documentation().is_empty() { | ||
264 | self.documentation = Some(sig.documentation().clone()); | ||
265 | } | ||
266 | |||
262 | self.kind = Some(CompletionItemKind::Function); | 267 | self.kind = Some(CompletionItemKind::Function); |
263 | self | 268 | self |
264 | } | 269 | } |