3500: Don't creat public APIs with typos r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-03-06 17:41:53 +00:00 committed by GitHub
commit a42f29166b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 18 deletions

View file

@ -225,7 +225,7 @@ impl Completions {
let snippet = if ctx let snippet = if ctx
.db .db
.feature_flags .feature_flags
.get("completion.insertion.add-argument-sippets") .get("completion.insertion.add-argument-snippets")
{ {
let to_skip = if has_self_param { 1 } else { 0 }; let to_skip = if has_self_param { 1 } else { 0 };
let function_params_snippet = join( let function_params_snippet = join(

View file

@ -54,8 +54,9 @@ impl Default for FeatureFlags {
FeatureFlags::new(&[ FeatureFlags::new(&[
("lsp.diagnostics", true), ("lsp.diagnostics", true),
("completion.insertion.add-call-parenthesis", true), ("completion.insertion.add-call-parenthesis", true),
("completion.insertion.add-argument-sippets", true), ("completion.insertion.add-argument-snippets", true),
("completion.enable-postfix", true), ("completion.enable-postfix", true),
("call-info.full", true),
("notifications.workspace-loaded", true), ("notifications.workspace-loaded", true),
("notifications.cargo-toml-not-found", true), ("notifications.cargo-toml-not-found", true),
]) ])

View file

@ -3,10 +3,10 @@
use lsp_types::{ use lsp_types::{
self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation, self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation,
Location, LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, Location, LocationLink, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel,
SemanticTokenModifier, SemanticTokenType, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, Position, Range, RenameFile, ResourceOp, SemanticTokenModifier, SemanticTokenType,
TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, SignatureInformation, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem,
WorkspaceEdit, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit,
}; };
use ra_ide::{ use ra_ide::{
translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
@ -220,17 +220,20 @@ impl Conv for ra_ide::Documentation {
} }
} }
impl Conv for ra_ide::FunctionSignature { impl ConvWith<bool> for ra_ide::FunctionSignature {
type Output = lsp_types::SignatureInformation; type Output = lsp_types::SignatureInformation;
fn conv(self) -> Self::Output { fn conv_with(self, concise: bool) -> Self::Output {
use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation}; let (label, documentation, params) = if concise {
let mut params = self.parameters;
if self.has_self_param {
params.remove(0);
}
(params.join(", "), None, params)
} else {
(self.to_string(), self.doc.map(|it| it.conv()), self.parameters)
};
let label = self.to_string(); let parameters: Vec<ParameterInformation> = params
let documentation = self.doc.map(|it| it.conv());
let parameters: Vec<ParameterInformation> = self
.parameters
.into_iter() .into_iter()
.map(|param| ParameterInformation { .map(|param| ParameterInformation {
label: ParameterLabel::Simple(param), label: ParameterLabel::Simple(param),

View file

@ -459,8 +459,12 @@ pub fn handle_signature_help(
let _p = profile("handle_signature_help"); let _p = profile("handle_signature_help");
let position = params.try_conv_with(&world)?; let position = params.try_conv_with(&world)?;
if let Some(call_info) = world.analysis().call_info(position)? { if let Some(call_info) = world.analysis().call_info(position)? {
let active_parameter = call_info.active_parameter.map(|it| it as i64); let concise = !world.analysis().feature_flags().get("call-info.full");
let sig_info = call_info.signature.conv(); let mut active_parameter = call_info.active_parameter.map(|it| it as i64);
if concise && call_info.signature.has_self_param {
active_parameter = active_parameter.map(|it| it.saturating_sub(1));
}
let sig_info = call_info.signature.conv_with(concise);
Ok(Some(req::SignatureHelp { Ok(Some(req::SignatureHelp {
signatures: vec![sig_info], signatures: vec![sig_info],

View file

@ -197,7 +197,7 @@
"type": "boolean", "type": "boolean",
"description": "Whether to add parenthesis when completing functions" "description": "Whether to add parenthesis when completing functions"
}, },
"completion.insertion.add-argument-sippets": { "completion.insertion.add-argument-snippets": {
"type": "boolean", "type": "boolean",
"description": "Whether to add argument snippets when completing functions" "description": "Whether to add argument snippets when completing functions"
}, },
@ -205,6 +205,10 @@
"type": "boolean", "type": "boolean",
"description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." "description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
}, },
"call-info.full": {
"type": "boolean",
"description": "Show function name and docs in parameter hints"
},
"notifications.workspace-loaded": { "notifications.workspace-loaded": {
"type": "boolean", "type": "boolean",
"description": "Whether to show `workspace loaded` message" "description": "Whether to show `workspace loaded` message"