mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
rename FnDescriptior -> FnSignatureInfo
This commit is contained in:
parent
67de38ec7d
commit
7207eef716
@ -42,10 +42,15 @@ impl FunctionDescriptor {
|
|||||||
pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
||||||
db.fn_scopes(self.fn_id)
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FnDescriptor {
|
pub struct FnSignatureInfo {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub ret_type: Option<String>,
|
pub ret_type: Option<String>,
|
||||||
@ -53,8 +58,8 @@ pub struct FnDescriptor {
|
|||||||
pub doc: Option<String>,
|
pub doc: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FnDescriptor {
|
impl FnSignatureInfo {
|
||||||
pub fn new(node: ast::FnDef) -> Option<Self> {
|
fn new(node: ast::FnDef) -> Option<Self> {
|
||||||
let name = node.name()?.text().to_string();
|
let name = node.name()?.text().to_string();
|
||||||
|
|
||||||
let mut doc = None;
|
let mut doc = None;
|
||||||
@ -73,7 +78,7 @@ impl FnDescriptor {
|
|||||||
node.syntax().text().to_string()
|
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
|
let comment_range = comment_range
|
||||||
.checked_sub(node.syntax().range().start())
|
.checked_sub(node.syntax().range().start())
|
||||||
.unwrap();
|
.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());
|
let ret_type = node.ret_type().map(|r| r.syntax().text().to_string());
|
||||||
|
|
||||||
Some(FnDescriptor {
|
Some(FnSignatureInfo {
|
||||||
name,
|
name,
|
||||||
ret_type,
|
ret_type,
|
||||||
params,
|
params,
|
||||||
|
@ -29,8 +29,7 @@ pub(crate) use self::{
|
|||||||
function::{FunctionDescriptor, FnScopes},
|
function::{FunctionDescriptor, FnScopes},
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO: FIXME
|
pub use self::function::FnSignatureInfo;
|
||||||
pub use self::function::FnDescriptor;
|
|
||||||
|
|
||||||
pub(crate) enum Def {
|
pub(crate) enum Def {
|
||||||
Module(ModuleDescriptor),
|
Module(ModuleDescriptor),
|
||||||
|
@ -20,7 +20,7 @@ use crate::{
|
|||||||
completion::{completions, CompletionItem},
|
completion::{completions, CompletionItem},
|
||||||
db::{self, FileSyntaxQuery, SyntaxDatabase},
|
db::{self, FileSyntaxQuery, SyntaxDatabase},
|
||||||
hir::{
|
hir::{
|
||||||
FnDescriptor, FunctionDescriptor, ModuleDescriptor,
|
FunctionDescriptor, FnSignatureInfo, ModuleDescriptor,
|
||||||
Problem,
|
Problem,
|
||||||
DeclarationDescriptor,
|
DeclarationDescriptor,
|
||||||
},
|
},
|
||||||
@ -445,7 +445,7 @@ impl AnalysisImpl {
|
|||||||
pub fn resolve_callable(
|
pub fn resolve_callable(
|
||||||
&self,
|
&self,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> {
|
) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> {
|
||||||
let file = self.db.file_syntax(position.file_id);
|
let file = self.db.file_syntax(position.file_id);
|
||||||
let syntax = file.syntax();
|
let syntax = file.syntax();
|
||||||
|
|
||||||
@ -455,11 +455,13 @@ impl AnalysisImpl {
|
|||||||
|
|
||||||
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
||||||
let file_symbols = self.index_resolve(name_ref)?;
|
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 {
|
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(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
|
// If we have a calling expression let's find which argument we are on
|
||||||
let mut current_parameter = None;
|
let mut current_parameter = None;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ use crate::{
|
|||||||
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
completion::CompletionItem,
|
completion::CompletionItem,
|
||||||
hir::FnDescriptor,
|
hir::FnSignatureInfo,
|
||||||
input::{CrateGraph, CrateId, FileId, FileResolver},
|
input::{CrateGraph, CrateId, FileId, FileResolver},
|
||||||
};
|
};
|
||||||
pub use ra_editor::{
|
pub use ra_editor::{
|
||||||
@ -305,7 +305,7 @@ impl Analysis {
|
|||||||
pub fn resolve_callable(
|
pub fn resolve_callable(
|
||||||
&self,
|
&self,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> {
|
) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> {
|
||||||
self.imp.resolve_callable(position)
|
self.imp.resolve_callable(position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user