Thread documentation through FnSignature and CompletionItem
This commit is contained in:
parent
5d110c0ee2
commit
b77d780f0e
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -259,6 +259,11 @@ impl Builder {
|
||||
}
|
||||
self.insert_text_format = InsertTextFormat::Snippet;
|
||||
}
|
||||
let sig = function.signature(ctx.db);
|
||||
if !sig.documentation().is_empty() {
|
||||
self.documentation = Some(sig.documentation().clone());
|
||||
}
|
||||
|
||||
self.kind = Some(CompletionItemKind::Function);
|
||||
self
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user