diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-12 14:06:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-12 14:06:38 +0100 |
commit | 2d41cc0ea323e3c4d97300e4d66de11d6b7148ef (patch) | |
tree | a7b048b0d394fa48e6c9ccf08947cbb52a87ab9d /crates/ra_ide | |
parent | 441fbe3b0aff2e6b141912d18f22ee5866b38516 (diff) | |
parent | 1c359ab634edb81b51e3c7eadfb83d46c926e890 (diff) |
Merge #5722
5722: Replace SepBy with Itertools
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 31 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/injection.rs | 5 |
2 files changed, 17 insertions, 19 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 9a94ff476..59f1b1424 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -2,8 +2,8 @@ | |||
2 | //! It also handles scoring (sorting) completions. | 2 | //! It also handles scoring (sorting) completions. |
3 | 3 | ||
4 | use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; | 4 | use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; |
5 | use itertools::Itertools; | ||
5 | use ra_syntax::ast::NameOwner; | 6 | use ra_syntax::ast::NameOwner; |
6 | use stdx::SepBy; | ||
7 | use test_utils::mark; | 7 | use test_utils::mark; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
@@ -289,16 +289,16 @@ impl Completions { | |||
289 | .map(|field| (field.name(ctx.db), field.signature_ty(ctx.db))); | 289 | .map(|field| (field.name(ctx.db), field.signature_ty(ctx.db))); |
290 | let variant_kind = variant.kind(ctx.db); | 290 | let variant_kind = variant.kind(ctx.db); |
291 | let detail = match variant_kind { | 291 | let detail = match variant_kind { |
292 | StructKind::Tuple | StructKind::Unit => detail_types | 292 | StructKind::Tuple | StructKind::Unit => format!( |
293 | .map(|(_, t)| t.display(ctx.db).to_string()) | 293 | "({})", |
294 | .sep_by(", ") | 294 | detail_types.map(|(_, t)| t.display(ctx.db).to_string()).format(", ") |
295 | .surround_with("(", ")") | 295 | ), |
296 | .to_string(), | 296 | StructKind::Record => format!( |
297 | StructKind::Record => detail_types | 297 | "{{ {} }}", |
298 | .map(|(n, t)| format!("{}: {}", n, t.display(ctx.db).to_string())) | 298 | detail_types |
299 | .sep_by(", ") | 299 | .map(|(n, t)| format!("{}: {}", n, t.display(ctx.db).to_string())) |
300 | .surround_with("{ ", " }") | 300 | .format(", ") |
301 | .to_string(), | 301 | ), |
302 | }; | 302 | }; |
303 | let mut res = CompletionItem::new( | 303 | let mut res = CompletionItem::new( |
304 | CompletionKind::Reference, | 304 | CompletionKind::Reference, |
@@ -412,11 +412,10 @@ impl Builder { | |||
412 | self = self.trigger_call_info(); | 412 | self = self.trigger_call_info(); |
413 | let snippet = match (ctx.config.add_call_argument_snippets, params) { | 413 | let snippet = match (ctx.config.add_call_argument_snippets, params) { |
414 | (true, Params::Named(params)) => { | 414 | (true, Params::Named(params)) => { |
415 | let function_params_snippet = params | 415 | let function_params_snippet = |
416 | .iter() | 416 | params.iter().enumerate().format_with(", ", |(index, param_name), f| { |
417 | .enumerate() | 417 | f(&format_args!("${{{}:{}}}", index + 1, param_name)) |
418 | .map(|(index, param_name)| format!("${{{}:{}}}", index + 1, param_name)) | 418 | }); |
419 | .sep_by(", "); | ||
420 | format!("{}({})$0", name, function_params_snippet) | 419 | format!("{}({})$0", name, function_params_snippet) |
421 | } | 420 | } |
422 | _ => { | 421 | _ => { |
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs index 8665b480f..6046643ef 100644 --- a/crates/ra_ide/src/syntax_highlighting/injection.rs +++ b/crates/ra_ide/src/syntax_highlighting/injection.rs | |||
@@ -4,8 +4,8 @@ use std::{collections::BTreeMap, convert::TryFrom}; | |||
4 | 4 | ||
5 | use ast::{HasQuotes, HasStringValue}; | 5 | use ast::{HasQuotes, HasStringValue}; |
6 | use hir::Semantics; | 6 | use hir::Semantics; |
7 | use itertools::Itertools; | ||
7 | use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; | 8 | use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; |
8 | use stdx::SepBy; | ||
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, | 11 | call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, |
@@ -129,8 +129,7 @@ pub(super) fn extract_doc_comments( | |||
129 | 129 | ||
130 | line[pos..].to_owned() | 130 | line[pos..].to_owned() |
131 | }) | 131 | }) |
132 | .sep_by("\n") | 132 | .join("\n"); |
133 | .to_string(); | ||
134 | 133 | ||
135 | if doctest.is_empty() { | 134 | if doctest.is_empty() { |
136 | return None; | 135 | return None; |