rename FnDescriptior -> FnSignatureInfo
This commit is contained in:
parent
67de38ec7d
commit
7207eef716
4 changed files with 21 additions and 15 deletions
|
@ -42,10 +42,15 @@ impl FunctionDescriptor {
|
|||
pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
||||
db.fn_scopes(self.fn_id)
|
||||
}
|
||||
|
||||
pub(crate) fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> {
|
||||
let syntax = db.fn_syntax(self.fn_id);
|
||||
FnSignatureInfo::new(syntax.borrowed())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FnDescriptor {
|
||||
pub struct FnSignatureInfo {
|
||||
pub name: String,
|
||||
pub label: String,
|
||||
pub ret_type: Option<String>,
|
||||
|
@ -53,8 +58,8 @@ pub struct FnDescriptor {
|
|||
pub doc: Option<String>,
|
||||
}
|
||||
|
||||
impl FnDescriptor {
|
||||
pub fn new(node: ast::FnDef) -> Option<Self> {
|
||||
impl FnSignatureInfo {
|
||||
fn new(node: ast::FnDef) -> Option<Self> {
|
||||
let name = node.name()?.text().to_string();
|
||||
|
||||
let mut doc = None;
|
||||
|
@ -73,7 +78,7 @@ impl FnDescriptor {
|
|||
node.syntax().text().to_string()
|
||||
};
|
||||
|
||||
if let Some((comment_range, docs)) = FnDescriptor::extract_doc_comments(node) {
|
||||
if let Some((comment_range, docs)) = FnSignatureInfo::extract_doc_comments(node) {
|
||||
let comment_range = comment_range
|
||||
.checked_sub(node.syntax().range().start())
|
||||
.unwrap();
|
||||
|
@ -105,10 +110,10 @@ impl FnDescriptor {
|
|||
}
|
||||
}
|
||||
|
||||
let params = FnDescriptor::param_list(node);
|
||||
let params = FnSignatureInfo::param_list(node);
|
||||
let ret_type = node.ret_type().map(|r| r.syntax().text().to_string());
|
||||
|
||||
Some(FnDescriptor {
|
||||
Some(FnSignatureInfo {
|
||||
name,
|
||||
ret_type,
|
||||
params,
|
||||
|
|
|
@ -29,8 +29,7 @@ pub(crate) use self::{
|
|||
function::{FunctionDescriptor, FnScopes},
|
||||
};
|
||||
|
||||
//TODO: FIXME
|
||||
pub use self::function::FnDescriptor;
|
||||
pub use self::function::FnSignatureInfo;
|
||||
|
||||
pub(crate) enum Def {
|
||||
Module(ModuleDescriptor),
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::{
|
|||
completion::{completions, CompletionItem},
|
||||
db::{self, FileSyntaxQuery, SyntaxDatabase},
|
||||
hir::{
|
||||
FnDescriptor, FunctionDescriptor, ModuleDescriptor,
|
||||
FunctionDescriptor, FnSignatureInfo, ModuleDescriptor,
|
||||
Problem,
|
||||
DeclarationDescriptor,
|
||||
},
|
||||
|
@ -445,7 +445,7 @@ impl AnalysisImpl {
|
|||
pub fn resolve_callable(
|
||||
&self,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> {
|
||||
) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> {
|
||||
let file = self.db.file_syntax(position.file_id);
|
||||
let syntax = file.syntax();
|
||||
|
||||
|
@ -455,11 +455,13 @@ impl AnalysisImpl {
|
|||
|
||||
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
||||
let file_symbols = self.index_resolve(name_ref)?;
|
||||
for (fn_fiel_id, fs) in file_symbols {
|
||||
for (fn_file_id, fs) in file_symbols {
|
||||
if fs.kind == FN_DEF {
|
||||
let fn_file = self.db.file_syntax(fn_fiel_id);
|
||||
let fn_file = self.db.file_syntax(fn_file_id);
|
||||
if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) {
|
||||
if let Some(descriptor) = FnDescriptor::new(fn_def) {
|
||||
let descr =
|
||||
FunctionDescriptor::guess_from_source(&*self.db, fn_file_id, fn_def);
|
||||
if let Some(descriptor) = descr.signature_info(&*self.db) {
|
||||
// If we have a calling expression let's find which argument we are on
|
||||
let mut current_parameter = None;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ use crate::{
|
|||
|
||||
pub use crate::{
|
||||
completion::CompletionItem,
|
||||
hir::FnDescriptor,
|
||||
hir::FnSignatureInfo,
|
||||
input::{CrateGraph, CrateId, FileId, FileResolver},
|
||||
};
|
||||
pub use ra_editor::{
|
||||
|
@ -305,7 +305,7 @@ impl Analysis {
|
|||
pub fn resolve_callable(
|
||||
&self,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> {
|
||||
) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> {
|
||||
self.imp.resolve_callable(position)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue