aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_api.rs
diff options
context:
space:
mode:
authorJeremy Kolb <[email protected]>2019-01-22 13:55:05 +0000
committerJeremy Kolb <[email protected]>2019-01-22 13:55:05 +0000
commitb5404514834a27c682dc22d86bc5585c0cae3076 (patch)
tree38c6f5d9abb55d335894a69e2db3f6df31573dcf /crates/ra_hir/src/code_model_api.rs
parentb77d780f0e9e7902695b949a25588fcb66bb5982 (diff)
Move docs to Function
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r--crates/ra_hir/src/code_model_api.rs21
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
3use relative_path::RelativePathBuf; 3use relative_path::RelativePathBuf;
4use ra_db::{CrateId, FileId}; 4use ra_db::{CrateId, FileId};
5use ra_syntax::{ast, TreeArc, SyntaxNode}; 5use ra_syntax::{ast::{self, AstNode, DocCommentsOwner}, TreeArc, SyntaxNode};
6 6
7use crate::{ 7use 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
303impl FnSignature { 302impl 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
327impl Function { 322impl 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)]