Skip to content

Commit a42f291

Browse files
bors[bot]matklad
andauthored
Merge #3500
3500: Don't creat public APIs with typos r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 8e8c5a7 + 80909f7 commit a42f291

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

crates/ra_ide/src/completion/presentation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Completions {
225225
let snippet = if ctx
226226
.db
227227
.feature_flags
228-
.get("completion.insertion.add-argument-sippets")
228+
.get("completion.insertion.add-argument-snippets")
229229
{
230230
let to_skip = if has_self_param { 1 } else { 0 };
231231
let function_params_snippet = join(

crates/ra_ide_db/src/feature_flags.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ impl Default for FeatureFlags {
5454
FeatureFlags::new(&[
5555
("lsp.diagnostics", true),
5656
("completion.insertion.add-call-parenthesis", true),
57-
("completion.insertion.add-argument-sippets", true),
57+
("completion.insertion.add-argument-snippets", true),
5858
("completion.enable-postfix", true),
59+
("call-info.full", true),
5960
("notifications.workspace-loaded", true),
6061
("notifications.cargo-toml-not-found", true),
6162
])

crates/rust-analyzer/src/conv.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
44
use lsp_types::{
55
self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation,
6-
Location, LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp,
7-
SemanticTokenModifier, SemanticTokenType, SymbolKind, TextDocumentEdit, TextDocumentIdentifier,
8-
TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier,
9-
WorkspaceEdit,
6+
Location, LocationLink, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel,
7+
Position, Range, RenameFile, ResourceOp, SemanticTokenModifier, SemanticTokenType,
8+
SignatureInformation, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem,
9+
TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit,
1010
};
1111
use ra_ide::{
1212
translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
@@ -220,17 +220,20 @@ impl Conv for ra_ide::Documentation {
220220
}
221221
}
222222

223-
impl Conv for ra_ide::FunctionSignature {
223+
impl ConvWith<bool> for ra_ide::FunctionSignature {
224224
type Output = lsp_types::SignatureInformation;
225-
fn conv(self) -> Self::Output {
226-
use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation};
227-
228-
let label = self.to_string();
229-
230-
let documentation = self.doc.map(|it| it.conv());
225+
fn conv_with(self, concise: bool) -> Self::Output {
226+
let (label, documentation, params) = if concise {
227+
let mut params = self.parameters;
228+
if self.has_self_param {
229+
params.remove(0);
230+
}
231+
(params.join(", "), None, params)
232+
} else {
233+
(self.to_string(), self.doc.map(|it| it.conv()), self.parameters)
234+
};
231235

232-
let parameters: Vec<ParameterInformation> = self
233-
.parameters
236+
let parameters: Vec<ParameterInformation> = params
234237
.into_iter()
235238
.map(|param| ParameterInformation {
236239
label: ParameterLabel::Simple(param),

crates/rust-analyzer/src/main_loop/handlers.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,12 @@ pub fn handle_signature_help(
459459
let _p = profile("handle_signature_help");
460460
let position = params.try_conv_with(&world)?;
461461
if let Some(call_info) = world.analysis().call_info(position)? {
462-
let active_parameter = call_info.active_parameter.map(|it| it as i64);
463-
let sig_info = call_info.signature.conv();
462+
let concise = !world.analysis().feature_flags().get("call-info.full");
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);
464468

465469
Ok(Some(req::SignatureHelp {
466470
signatures: vec![sig_info],

editors/code/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,18 @@
197197
"type": "boolean",
198198
"description": "Whether to add parenthesis when completing functions"
199199
},
200-
"completion.insertion.add-argument-sippets": {
200+
"completion.insertion.add-argument-snippets": {
201201
"type": "boolean",
202202
"description": "Whether to add argument snippets when completing functions"
203203
},
204204
"completion.enable-postfix": {
205205
"type": "boolean",
206206
"description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
207207
},
208+
"call-info.full": {
209+
"type": "boolean",
210+
"description": "Show function name and docs in parameter hints"
211+
},
208212
"notifications.workspace-loaded": {
209213
"type": "boolean",
210214
"description": "Whether to show `workspace loaded` message"

0 commit comments

Comments
 (0)