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

@ -174,6 +174,28 @@ impl Conv for ra_ide_api::Documentation {
}
}
impl Conv for ra_ide_api::FunctionSignature {
type Output = lsp_types::SignatureInformation;
fn conv(self) -> Self::Output {
use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation};
let label = self.to_string();
let documentation = self.doc.map(|it| it.conv());
let parameters: Vec<ParameterInformation> = self
.parameters
.into_iter()
.map(|param| ParameterInformation {
label: ParameterLabel::Simple(param),
documentation: None,
})
.collect();
SignatureInformation { label, documentation, parameters: Some(parameters) }
}
}
impl ConvWith for TextEdit {
type Ctx = LineIndex;
type Output = Vec<lsp_types::TextEdit>;