diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 57f405f4f..9ae620efd 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -2,7 +2,7 @@ use std::sync::Arc; | |||
2 | 2 | ||
3 | use relative_path::RelativePathBuf; | 3 | use relative_path::RelativePathBuf; |
4 | use ra_db::{CrateId, FileId}; | 4 | use ra_db::{CrateId, FileId}; |
5 | use ra_syntax::{ast, TreeArc, SyntaxNode}; | 5 | use ra_syntax::{ast::{self, AstNode, DocCommentsOwner}, TreeArc, SyntaxNode}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | Name, DefId, Path, PerNs, ScopesWithSyntaxMapping, Ty, HirFileId, | 8 | Name, DefId, Path, PerNs, ScopesWithSyntaxMapping, Ty, HirFileId, |
@@ -297,7 +297,6 @@ 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, | ||
301 | } | 300 | } |
302 | 301 | ||
303 | impl FnSignature { | 302 | impl FnSignature { |
@@ -318,10 +317,6 @@ impl FnSignature { | |||
318 | pub fn has_self_param(&self) -> bool { | 317 | pub fn has_self_param(&self) -> bool { |
319 | self.has_self_param | 318 | self.has_self_param |
320 | } | 319 | } |
321 | |||
322 | pub fn documentation(&self) -> &String { | ||
323 | &self.documentation | ||
324 | } | ||
325 | } | 320 | } |
326 | 321 | ||
327 | impl Function { | 322 | impl Function { |
@@ -357,6 +352,20 @@ impl Function { | |||
357 | pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> { | 352 | pub fn generic_params(&self, db: &impl HirDatabase) -> Arc<GenericParams> { |
358 | db.generic_params(self.def_id) | 353 | db.generic_params(self.def_id) |
359 | } | 354 | } |
355 | |||
356 | pub fn docs(&self, db: &impl HirDatabase) -> Option<String> { | ||
357 | let def_loc = self.def_id.loc(db); | ||
358 | let syntax = db.file_item(def_loc.source_item_id); | ||
359 | let fn_def = ast::FnDef::cast(&syntax).expect("fn def should point to FnDef node"); | ||
360 | |||
361 | // doc_comment_text unconditionally returns a String | ||
362 | let comments = fn_def.doc_comment_text(); | ||
363 | if comments.is_empty() { | ||
364 | None | ||
365 | } else { | ||
366 | Some(comments) | ||
367 | } | ||
368 | } | ||
360 | } | 369 | } |
361 | 370 | ||
362 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |