Refactor CallInfo function signatures to new FunctionSignature type

This is used by CallInfo to create a pretty printed function signature that can
be used with completions and other places as well.
This commit is contained in:
Ville Penttinen 2019-03-12 09:24:46 +02:00
parent 5f700179fc
commit 0e49abb7fb
8 changed files with 212 additions and 71 deletions

View file

@ -37,6 +37,7 @@ mod join_lines;
mod structure;
mod typing;
mod matching_brace;
mod display;
#[cfg(test)]
mod marks;
@ -243,12 +244,36 @@ impl<T> RangeInfo<T> {
#[derive(Debug)]
pub struct CallInfo {
pub label: String,
pub doc: Option<Documentation>,
pub parameters: Vec<String>,
pub signature: FunctionSignature,
pub active_parameter: Option<usize>,
}
/// Contains information about a function signature
#[derive(Debug)]
pub struct FunctionSignature {
/// Optional visibility
pub visibility: Option<String>,
/// Name of the function
pub name: Option<String>,
/// Documentation for the function
pub doc: Option<Documentation>,
/// Generic parameters
pub generic_parameters: Vec<String>,
/// Parameters of the function
pub parameters: Vec<String>,
/// Optional return type
pub ret_type: Option<String>,
/// Where predicates
pub where_predicates: Vec<String>,
}
impl FunctionSignature {
pub(crate) fn with_doc_opt(mut self, doc: Option<Documentation>) -> Self {
self.doc = doc;
self
}
}
/// `AnalysisHost` stores the current state of the world.
#[derive(Debug, Default)]
pub struct AnalysisHost {