diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-06 17:41:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-06 17:41:53 +0000 |
commit | a42f29166b2b771927fef6061dd427f82eb28d68 (patch) | |
tree | c6433fc26f3557a358696f7b66734ce4688fa988 | |
parent | 8e8c5a73ff3b26a7c919fee6caa3212dca9c6ba5 (diff) | |
parent | 80909f7698edd972e7bb7e3b255c9a12d78cd9a6 (diff) |
Merge #3500
3500: Don't creat public APIs with typos r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_db/src/feature_flags.rs | 3 | ||||
-rw-r--r-- | crates/rust-analyzer/src/conv.rs | 29 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 8 | ||||
-rw-r--r-- | editors/code/package.json | 6 |
5 files changed, 30 insertions, 18 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index d6196a5ce..aada4d025 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -225,7 +225,7 @@ impl Completions { | |||
225 | let snippet = if ctx | 225 | let snippet = if ctx |
226 | .db | 226 | .db |
227 | .feature_flags | 227 | .feature_flags |
228 | .get("completion.insertion.add-argument-sippets") | 228 | .get("completion.insertion.add-argument-snippets") |
229 | { | 229 | { |
230 | let to_skip = if has_self_param { 1 } else { 0 }; | 230 | let to_skip = if has_self_param { 1 } else { 0 }; |
231 | let function_params_snippet = join( | 231 | let function_params_snippet = join( |
diff --git a/crates/ra_ide_db/src/feature_flags.rs b/crates/ra_ide_db/src/feature_flags.rs index d9c9d6cd2..968415072 100644 --- a/crates/ra_ide_db/src/feature_flags.rs +++ b/crates/ra_ide_db/src/feature_flags.rs | |||
@@ -54,8 +54,9 @@ impl Default for FeatureFlags { | |||
54 | FeatureFlags::new(&[ | 54 | FeatureFlags::new(&[ |
55 | ("lsp.diagnostics", true), | 55 | ("lsp.diagnostics", true), |
56 | ("completion.insertion.add-call-parenthesis", true), | 56 | ("completion.insertion.add-call-parenthesis", true), |
57 | ("completion.insertion.add-argument-sippets", true), | 57 | ("completion.insertion.add-argument-snippets", true), |
58 | ("completion.enable-postfix", true), | 58 | ("completion.enable-postfix", true), |
59 | ("call-info.full", true), | ||
59 | ("notifications.workspace-loaded", true), | 60 | ("notifications.workspace-loaded", true), |
60 | ("notifications.cargo-toml-not-found", true), | 61 | ("notifications.cargo-toml-not-found", true), |
61 | ]) | 62 | ]) |
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index fe3b588e4..a2d68c344 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs | |||
@@ -3,10 +3,10 @@ | |||
3 | 3 | ||
4 | use lsp_types::{ | 4 | use lsp_types::{ |
5 | self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation, | 5 | self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation, |
6 | Location, LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, | 6 | Location, LocationLink, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel, |
7 | SemanticTokenModifier, SemanticTokenType, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, | 7 | Position, Range, RenameFile, ResourceOp, SemanticTokenModifier, SemanticTokenType, |
8 | TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, | 8 | SignatureInformation, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, |
9 | WorkspaceEdit, | 9 | TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit, |
10 | }; | 10 | }; |
11 | use ra_ide::{ | 11 | use ra_ide::{ |
12 | translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, | 12 | translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, |
@@ -220,17 +220,20 @@ impl Conv for ra_ide::Documentation { | |||
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | impl Conv for ra_ide::FunctionSignature { | 223 | impl ConvWith<bool> for ra_ide::FunctionSignature { |
224 | type Output = lsp_types::SignatureInformation; | 224 | type Output = lsp_types::SignatureInformation; |
225 | fn conv(self) -> Self::Output { | 225 | fn conv_with(self, concise: bool) -> Self::Output { |
226 | use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation}; | 226 | let (label, documentation, params) = if concise { |
227 | 227 | let mut params = self.parameters; | |
228 | let label = self.to_string(); | 228 | if self.has_self_param { |
229 | 229 | params.remove(0); | |
230 | let documentation = self.doc.map(|it| it.conv()); | 230 | } |
231 | (params.join(", "), None, params) | ||
232 | } else { | ||
233 | (self.to_string(), self.doc.map(|it| it.conv()), self.parameters) | ||
234 | }; | ||
231 | 235 | ||
232 | let parameters: Vec<ParameterInformation> = self | 236 | let parameters: Vec<ParameterInformation> = params |
233 | .parameters | ||
234 | .into_iter() | 237 | .into_iter() |
235 | .map(|param| ParameterInformation { | 238 | .map(|param| ParameterInformation { |
236 | label: ParameterLabel::Simple(param), | 239 | label: ParameterLabel::Simple(param), |
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index b5db1fd38..b498c90c9 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs | |||
@@ -459,8 +459,12 @@ pub fn handle_signature_help( | |||
459 | let _p = profile("handle_signature_help"); | 459 | let _p = profile("handle_signature_help"); |
460 | let position = params.try_conv_with(&world)?; | 460 | let position = params.try_conv_with(&world)?; |
461 | if let Some(call_info) = world.analysis().call_info(position)? { | 461 | if let Some(call_info) = world.analysis().call_info(position)? { |
462 | let active_parameter = call_info.active_parameter.map(|it| it as i64); | 462 | let concise = !world.analysis().feature_flags().get("call-info.full"); |
463 | let sig_info = call_info.signature.conv(); | 463 | let mut active_parameter = call_info.active_parameter.map(|it| it as i64); |
464 | if concise && call_info.signature.has_self_param { | ||
465 | active_parameter = active_parameter.map(|it| it.saturating_sub(1)); | ||
466 | } | ||
467 | let sig_info = call_info.signature.conv_with(concise); | ||
464 | 468 | ||
465 | Ok(Some(req::SignatureHelp { | 469 | Ok(Some(req::SignatureHelp { |
466 | signatures: vec![sig_info], | 470 | signatures: vec![sig_info], |
diff --git a/editors/code/package.json b/editors/code/package.json index 2f442aae8..3a1e6cf23 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -197,7 +197,7 @@ | |||
197 | "type": "boolean", | 197 | "type": "boolean", |
198 | "description": "Whether to add parenthesis when completing functions" | 198 | "description": "Whether to add parenthesis when completing functions" |
199 | }, | 199 | }, |
200 | "completion.insertion.add-argument-sippets": { | 200 | "completion.insertion.add-argument-snippets": { |
201 | "type": "boolean", | 201 | "type": "boolean", |
202 | "description": "Whether to add argument snippets when completing functions" | 202 | "description": "Whether to add argument snippets when completing functions" |
203 | }, | 203 | }, |
@@ -205,6 +205,10 @@ | |||
205 | "type": "boolean", | 205 | "type": "boolean", |
206 | "description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." | 206 | "description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." |
207 | }, | 207 | }, |
208 | "call-info.full": { | ||
209 | "type": "boolean", | ||
210 | "description": "Show function name and docs in parameter hints" | ||
211 | }, | ||
208 | "notifications.workspace-loaded": { | 212 | "notifications.workspace-loaded": { |
209 | "type": "boolean", | 213 | "type": "boolean", |
210 | "description": "Whether to show `workspace loaded` message" | 214 | "description": "Whether to show `workspace loaded` message" |