aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/completion/complete_keyword.rs14
-rw-r--r--crates/ra_ide/src/inlay_hints.rs9
-rw-r--r--crates/ra_ide/src/join_lines.rs5
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs4
4 files changed, 14 insertions, 18 deletions
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs
index b2f621a11..3b174f916 100644
--- a/crates/ra_ide/src/completion/complete_keyword.rs
+++ b/crates/ra_ide/src/completion/complete_keyword.rs
@@ -11,14 +11,14 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
11 let source_range = ctx.source_range(); 11 let source_range = ctx.source_range();
12 match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) { 12 match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) {
13 (Some(_), None) => { 13 (Some(_), None) => {
14 CompletionItem::new(CompletionKind::Keyword, source_range, "crate") 14 CompletionItem::new(CompletionKind::Keyword, source_range, "crate::")
15 .kind(CompletionItemKind::Keyword) 15 .kind(CompletionItemKind::Keyword)
16 .insert_text("crate::") 16 .insert_text("crate::")
17 .add_to(acc); 17 .add_to(acc);
18 CompletionItem::new(CompletionKind::Keyword, source_range, "self") 18 CompletionItem::new(CompletionKind::Keyword, source_range, "self")
19 .kind(CompletionItemKind::Keyword) 19 .kind(CompletionItemKind::Keyword)
20 .add_to(acc); 20 .add_to(acc);
21 CompletionItem::new(CompletionKind::Keyword, source_range, "super") 21 CompletionItem::new(CompletionKind::Keyword, source_range, "super::")
22 .kind(CompletionItemKind::Keyword) 22 .kind(CompletionItemKind::Keyword)
23 .insert_text("super::") 23 .insert_text("super::")
24 .add_to(acc); 24 .add_to(acc);
@@ -27,7 +27,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
27 CompletionItem::new(CompletionKind::Keyword, source_range, "self") 27 CompletionItem::new(CompletionKind::Keyword, source_range, "self")
28 .kind(CompletionItemKind::Keyword) 28 .kind(CompletionItemKind::Keyword)
29 .add_to(acc); 29 .add_to(acc);
30 CompletionItem::new(CompletionKind::Keyword, source_range, "super") 30 CompletionItem::new(CompletionKind::Keyword, source_range, "super::")
31 .kind(CompletionItemKind::Keyword) 31 .kind(CompletionItemKind::Keyword)
32 .insert_text("super::") 32 .insert_text("super::")
33 .add_to(acc); 33 .add_to(acc);
@@ -182,9 +182,9 @@ mod tests {
182 assert_snapshot!( 182 assert_snapshot!(
183 get_keyword_completions(r"use <|>"), 183 get_keyword_completions(r"use <|>"),
184 @r###" 184 @r###"
185 kw crate 185 kw crate::
186 kw self 186 kw self
187 kw super 187 kw super::
188 "### 188 "###
189 ); 189 );
190 190
@@ -192,7 +192,7 @@ mod tests {
192 get_keyword_completions(r"use a::<|>"), 192 get_keyword_completions(r"use a::<|>"),
193 @r###" 193 @r###"
194 kw self 194 kw self
195 kw super 195 kw super::
196 "### 196 "###
197 ); 197 );
198 198
@@ -200,7 +200,7 @@ mod tests {
200 get_keyword_completions(r"use a::{b, <|>}"), 200 get_keyword_completions(r"use a::{b, <|>}"),
201 @r###" 201 @r###"
202 kw self 202 kw self
203 kw super 203 kw super::
204 "### 204 "###
205 ); 205 );
206 } 206 }
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 3fd08b1e8..c87652555 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -258,6 +258,7 @@ fn should_show_param_name_hint(
258 if param_name.is_empty() 258 if param_name.is_empty()
259 || Some(param_name) == fn_signature.name.as_ref().map(|s| s.trim_start_matches('_')) 259 || Some(param_name) == fn_signature.name.as_ref().map(|s| s.trim_start_matches('_'))
260 || is_argument_similar_to_param_name(sema, argument, param_name) 260 || is_argument_similar_to_param_name(sema, argument, param_name)
261 || param_name.starts_with("ra_fixture")
261 { 262 {
262 return false; 263 return false;
263 } 264 }
@@ -270,7 +271,7 @@ fn should_show_param_name_hint(
270 271
271 // avoid displaying hints for common functions like map, filter, etc. 272 // avoid displaying hints for common functions like map, filter, etc.
272 // or other obvious words used in std 273 // or other obvious words used in std
273 parameters_len != 1 || !is_obvious_param(param_name) 274 !(parameters_len == 1 && is_obvious_param(param_name))
274} 275}
275 276
276fn is_argument_similar_to_param_name( 277fn is_argument_similar_to_param_name(
@@ -312,10 +313,8 @@ fn get_string_representation(expr: &ast::Expr) -> Option<String> {
312} 313}
313 314
314fn is_obvious_param(param_name: &str) -> bool { 315fn is_obvious_param(param_name: &str) -> bool {
315 let is_obvious_param_name = match param_name { 316 let is_obvious_param_name =
316 "predicate" | "value" | "pat" | "rhs" | "other" => true, 317 matches!(param_name, "predicate" | "value" | "pat" | "rhs" | "other");
317 _ => false,
318 };
319 param_name.len() == 1 || is_obvious_param_name 318 param_name.len() == 1 || is_obvious_param_name
320} 319}
321 320
diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs
index 5036c1fb0..6907c09e8 100644
--- a/crates/ra_ide/src/join_lines.rs
+++ b/crates/ra_ide/src/join_lines.rs
@@ -165,10 +165,7 @@ fn join_single_use_tree(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Opti
165} 165}
166 166
167fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { 167fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool {
168 match (left, right) { 168 matches!((left, right), (T![,], T![')']) | (T![,], T![']']))
169 (T![,], T![')']) | (T![,], T![']']) => true,
170 _ => false,
171 }
172} 169}
173 170
174#[cfg(test)] 171#[cfg(test)]
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs
index e8e251cfc..13d9dd195 100644
--- a/crates/ra_ide/src/syntax_highlighting/tags.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tags.rs
@@ -25,7 +25,6 @@ pub enum HighlightTag {
25 EnumVariant, 25 EnumVariant,
26 EscapeSequence, 26 EscapeSequence,
27 Field, 27 Field,
28 FormatSpecifier,
29 Function, 28 Function,
30 Generic, 29 Generic,
31 Keyword, 30 Keyword,
@@ -33,7 +32,6 @@ pub enum HighlightTag {
33 Macro, 32 Macro,
34 Module, 33 Module,
35 NumericLiteral, 34 NumericLiteral,
36 Operator,
37 SelfKeyword, 35 SelfKeyword,
38 SelfType, 36 SelfType,
39 Static, 37 Static,
@@ -45,6 +43,8 @@ pub enum HighlightTag {
45 Union, 43 Union,
46 Local, 44 Local,
47 UnresolvedReference, 45 UnresolvedReference,
46 FormatSpecifier,
47 Operator,
48} 48}
49 49
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] 50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]