aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/completion/complete_postfix.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs17
-rw-r--r--crates/ra_ide/src/expand_macro.rs13
-rw-r--r--crates/ra_ide/src/extend_selection.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs54
5 files changed, 41 insertions, 47 deletions
diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs
index 646a30c76..5470dc291 100644
--- a/crates/ra_ide/src/completion/complete_postfix.rs
+++ b/crates/ra_ide/src/completion/complete_postfix.rs
@@ -12,7 +12,7 @@ use crate::{
12}; 12};
13 13
14pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { 14pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
15 if ctx.db.feature_flags.get("completion.enable-postfix") == false { 15 if !ctx.db.feature_flags.get("completion.enable-postfix") {
16 return; 16 return;
17 } 17 }
18 18
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 981da2b79..4894ea2f6 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -239,16 +239,15 @@ impl<'a> CompletionContext<'a> {
239 .expr() 239 .expr()
240 .map(|e| e.syntax().text_range()) 240 .map(|e| e.syntax().text_range())
241 .and_then(|r| find_node_with_range(original_file.syntax(), r)); 241 .and_then(|r| find_node_with_range(original_file.syntax(), r));
242 self.dot_receiver_is_ambiguous_float_literal = if let Some(ast::Expr::Literal(l)) = 242 self.dot_receiver_is_ambiguous_float_literal =
243 &self.dot_receiver 243 if let Some(ast::Expr::Literal(l)) = &self.dot_receiver {
244 { 244 match l.kind() {
245 match l.kind() { 245 ast::LiteralKind::FloatNumber { .. } => l.token().text().ends_with('.'),
246 ast::LiteralKind::FloatNumber { suffix: _ } => l.token().text().ends_with('.'), 246 _ => false,
247 _ => false, 247 }
248 } else {
249 false
248 } 250 }
249 } else {
250 false
251 }
252 } 251 }
253 if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { 252 if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) {
254 // As above 253 // As above
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index 862c03304..bdbc31704 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -86,21 +86,18 @@ fn insert_whitespaces(syn: SyntaxNode) -> String {
86 let mut is_next = |f: fn(SyntaxKind) -> bool, default| -> bool { 86 let mut is_next = |f: fn(SyntaxKind) -> bool, default| -> bool {
87 token_iter.peek().map(|it| f(it.kind())).unwrap_or(default) 87 token_iter.peek().map(|it| f(it.kind())).unwrap_or(default)
88 }; 88 };
89 let is_last = |f: fn(SyntaxKind) -> bool, default| -> bool { 89 let is_last =
90 last.map(|it| f(it)).unwrap_or(default) 90 |f: fn(SyntaxKind) -> bool, default| -> bool { last.map(f).unwrap_or(default) };
91 };
92 91
93 res += &match token.kind() { 92 res += &match token.kind() {
94 k @ _ if is_text(k) && is_next(|it| !it.is_punct(), true) => { 93 k if is_text(k) && is_next(|it| !it.is_punct(), true) => token.text().to_string() + " ",
95 token.text().to_string() + " "
96 }
97 L_CURLY if is_next(|it| it != R_CURLY, true) => { 94 L_CURLY if is_next(|it| it != R_CURLY, true) => {
98 indent += 1; 95 indent += 1;
99 let leading_space = if is_last(|it| is_text(it), false) { " " } else { "" }; 96 let leading_space = if is_last(is_text, false) { " " } else { "" };
100 format!("{}{{\n{}", leading_space, " ".repeat(indent)) 97 format!("{}{{\n{}", leading_space, " ".repeat(indent))
101 } 98 }
102 R_CURLY if is_last(|it| it != L_CURLY, true) => { 99 R_CURLY if is_last(|it| it != L_CURLY, true) => {
103 indent = indent.checked_sub(1).unwrap_or(0); 100 indent = indent.saturating_sub(1);
104 format!("\n{}}}", " ".repeat(indent)) 101 format!("\n{}}}", " ".repeat(indent))
105 } 102 }
106 R_CURLY => format!("}}\n{}", " ".repeat(indent)), 103 R_CURLY => format!("}}\n{}", " ".repeat(indent)),
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index c096ca6ae..1ec41a117 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -138,7 +138,7 @@ fn extend_ws(root: &SyntaxNode, ws: SyntaxToken, offset: TextUnit) -> TextRange
138 ws.text_range() 138 ws.text_range()
139} 139}
140 140
141fn pick_best<'a>(l: SyntaxToken, r: SyntaxToken) -> SyntaxToken { 141fn pick_best(l: SyntaxToken, r: SyntaxToken) -> SyntaxToken {
142 return if priority(&r) > priority(&l) { r } else { l }; 142 return if priority(&r) > priority(&l) { r } else { l };
143 fn priority(n: &SyntaxToken) -> usize { 143 fn priority(n: &SyntaxToken) -> usize {
144 match n.kind() { 144 match n.kind() {
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 657c7b21a..0228ee7e9 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -17,31 +17,31 @@ use crate::{
17}; 17};
18 18
19pub mod tags { 19pub mod tags {
20 pub(crate) const FIELD: &'static str = "field"; 20 pub(crate) const FIELD: &str = "field";
21 pub(crate) const FUNCTION: &'static str = "function"; 21 pub(crate) const FUNCTION: &str = "function";
22 pub(crate) const MODULE: &'static str = "module"; 22 pub(crate) const MODULE: &str = "module";
23 pub(crate) const TYPE: &'static str = "type"; 23 pub(crate) const TYPE: &str = "type";
24 pub(crate) const CONSTANT: &'static str = "constant"; 24 pub(crate) const CONSTANT: &str = "constant";
25 pub(crate) const MACRO: &'static str = "macro"; 25 pub(crate) const MACRO: &str = "macro";
26 pub(crate) const VARIABLE: &'static str = "variable"; 26 pub(crate) const VARIABLE: &str = "variable";
27 pub(crate) const VARIABLE_MUT: &'static str = "variable.mut"; 27 pub(crate) const VARIABLE_MUT: &str = "variable.mut";
28 pub(crate) const TEXT: &'static str = "text"; 28 pub(crate) const TEXT: &str = "text";
29 29
30 pub(crate) const TYPE_BUILTIN: &'static str = "type.builtin"; 30 pub(crate) const TYPE_BUILTIN: &str = "type.builtin";
31 pub(crate) const TYPE_SELF: &'static str = "type.self"; 31 pub(crate) const TYPE_SELF: &str = "type.self";
32 pub(crate) const TYPE_PARAM: &'static str = "type.param"; 32 pub(crate) const TYPE_PARAM: &str = "type.param";
33 pub(crate) const TYPE_LIFETIME: &'static str = "type.lifetime"; 33 pub(crate) const TYPE_LIFETIME: &str = "type.lifetime";
34 34
35 pub(crate) const LITERAL_BYTE: &'static str = "literal.byte"; 35 pub(crate) const LITERAL_BYTE: &str = "literal.byte";
36 pub(crate) const LITERAL_NUMERIC: &'static str = "literal.numeric"; 36 pub(crate) const LITERAL_NUMERIC: &str = "literal.numeric";
37 pub(crate) const LITERAL_CHAR: &'static str = "literal.char"; 37 pub(crate) const LITERAL_CHAR: &str = "literal.char";
38 pub(crate) const LITERAL_COMMENT: &'static str = "comment"; 38 pub(crate) const LITERAL_COMMENT: &str = "comment";
39 pub(crate) const LITERAL_STRING: &'static str = "string"; 39 pub(crate) const LITERAL_STRING: &str = "string";
40 pub(crate) const LITERAL_ATTRIBUTE: &'static str = "attribute"; 40 pub(crate) const LITERAL_ATTRIBUTE: &str = "attribute";
41 41
42 pub(crate) const KEYWORD_UNSAFE: &'static str = "keyword.unsafe"; 42 pub(crate) const KEYWORD_UNSAFE: &str = "keyword.unsafe";
43 pub(crate) const KEYWORD_CONTROL: &'static str = "keyword.control"; 43 pub(crate) const KEYWORD_CONTROL: &str = "keyword.control";
44 pub(crate) const KEYWORD: &'static str = "keyword"; 44 pub(crate) const KEYWORD: &str = "keyword";
45} 45}
46 46
47#[derive(Debug)] 47#[derive(Debug)]
@@ -258,9 +258,7 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
258 SelfType(_) => tags::TYPE_SELF, 258 SelfType(_) => tags::TYPE_SELF,
259 TypeParam(_) => tags::TYPE_PARAM, 259 TypeParam(_) => tags::TYPE_PARAM,
260 Local(local) => { 260 Local(local) => {
261 if local.is_mut(db) { 261 if local.is_mut(db) || local.ty(db).is_mutable_reference() {
262 tags::VARIABLE_MUT
263 } else if local.ty(db).is_mutable_reference() {
264 tags::VARIABLE_MUT 262 tags::VARIABLE_MUT
265 } else { 263 } else {
266 tags::VARIABLE 264 tags::VARIABLE