diff options
-rw-r--r-- | Cargo.lock | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/early_return.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/autoderef.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/complete_postfix.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 17 | ||||
-rw-r--r-- | crates/ra_ide/src/expand_macro.rs | 13 | ||||
-rw-r--r-- | crates/ra_ide/src/extend_selection.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 54 | ||||
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/caps.rs | 11 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 27 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 20 | ||||
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 3 |
20 files changed, 83 insertions, 113 deletions
diff --git a/Cargo.lock b/Cargo.lock index 3f2cbc8ab..c29ce324e 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -620,7 +620,7 @@ dependencies = [ | |||
620 | 620 | ||
621 | [[package]] | 621 | [[package]] |
622 | name = "lsp-types" | 622 | name = "lsp-types" |
623 | version = "0.63.1" | 623 | version = "0.65.0" |
624 | source = "registry+https://github.com/rust-lang/crates.io-index" | 624 | source = "registry+https://github.com/rust-lang/crates.io-index" |
625 | dependencies = [ | 625 | dependencies = [ |
626 | "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 626 | "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1049,7 +1049,7 @@ dependencies = [ | |||
1049 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1049 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1050 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1050 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1051 | "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1051 | "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1052 | "lsp-types 0.63.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1052 | "lsp-types 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1053 | "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1053 | "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1054 | "ra_ide 0.1.0", | 1054 | "ra_ide 0.1.0", |
1055 | "ra_prof 0.1.0", | 1055 | "ra_prof 0.1.0", |
@@ -1841,7 +1841,7 @@ dependencies = [ | |||
1841 | "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" | 1841 | "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" |
1842 | "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" | 1842 | "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" |
1843 | "checksum lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ba36405bd742139ab79c246ca5adb7fde2fe1a0f495e2c8e2f607b607dedb12" | 1843 | "checksum lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ba36405bd742139ab79c246ca5adb7fde2fe1a0f495e2c8e2f607b607dedb12" |
1844 | "checksum lsp-types 0.63.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70090cea3cd5db0aa923575e03874b33da90c4d0fe1eaf63fa51b8925a78ef03" | 1844 | "checksum lsp-types 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fe9e427e63e6172699737b47f1044bcade7046e2404d59ebd90c459da47cd2b" |
1845 | "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" | 1845 | "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" |
1846 | "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" | 1846 | "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" |
1847 | "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" | 1847 | "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" |
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index 264412526..023917aca 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs | |||
@@ -83,8 +83,8 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
83 | let parent_container = parent_block.syntax().parent()?.parent()?; | 83 | let parent_container = parent_block.syntax().parent()?.parent()?; |
84 | 84 | ||
85 | let early_expression: ast::Expr = match parent_container.kind() { | 85 | let early_expression: ast::Expr = match parent_container.kind() { |
86 | WHILE_EXPR | LOOP_EXPR => make::expr_continue().into(), | 86 | WHILE_EXPR | LOOP_EXPR => make::expr_continue(), |
87 | FN_DEF => make::expr_return().into(), | 87 | FN_DEF => make::expr_return(), |
88 | _ => return None, | 88 | _ => return None, |
89 | }; | 89 | }; |
90 | 90 | ||
@@ -116,13 +116,13 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
116 | ) | 116 | ) |
117 | .into(), | 117 | .into(), |
118 | ), | 118 | ), |
119 | make::expr_path(make::path_from_name_ref(make::name_ref("it"))).into(), | 119 | make::expr_path(make::path_from_name_ref(make::name_ref("it"))), |
120 | ); | 120 | ); |
121 | 121 | ||
122 | let sad_arm = make::match_arm( | 122 | let sad_arm = make::match_arm( |
123 | // FIXME: would be cool to use `None` or `Err(_)` if appropriate | 123 | // FIXME: would be cool to use `None` or `Err(_)` if appropriate |
124 | once(make::placeholder_pat().into()), | 124 | once(make::placeholder_pat().into()), |
125 | early_expression.into(), | 125 | early_expression, |
126 | ); | 126 | ); |
127 | 127 | ||
128 | make::expr_match(cond_expr, make::match_arm_list(vec![happy_arm, sad_arm])) | 128 | make::expr_match(cond_expr, make::match_arm_list(vec![happy_arm, sad_arm])) |
@@ -130,7 +130,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
130 | 130 | ||
131 | let let_stmt = make::let_stmt( | 131 | let let_stmt = make::let_stmt( |
132 | make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(), | 132 | make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(), |
133 | Some(match_expr.into()), | 133 | Some(match_expr), |
134 | ); | 134 | ); |
135 | let let_stmt = if_indent_level.increase_indent(let_stmt); | 135 | let let_stmt = if_indent_level.increase_indent(let_stmt); |
136 | replace(let_stmt.syntax(), &then_block, &parent_block, &if_expr) | 136 | replace(let_stmt.syntax(), &then_block, &parent_block, &if_expr) |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 8b641d8b5..45199fa11 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -399,14 +399,14 @@ where | |||
399 | let resolutions = enum_data | 399 | let resolutions = enum_data |
400 | .variants | 400 | .variants |
401 | .iter() | 401 | .iter() |
402 | .filter_map(|(local_id, variant_data)| { | 402 | .map(|(local_id, variant_data)| { |
403 | let name = variant_data.name.clone(); | 403 | let name = variant_data.name.clone(); |
404 | let variant = EnumVariantId { parent: e, local_id }; | 404 | let variant = EnumVariantId { parent: e, local_id }; |
405 | let res = Resolution { | 405 | let res = Resolution { |
406 | def: PerNs::both(variant.into(), variant.into()), | 406 | def: PerNs::both(variant.into(), variant.into()), |
407 | import: Some(import_id), | 407 | import: Some(import_id), |
408 | }; | 408 | }; |
409 | Some((name, res)) | 409 | (name, res) |
410 | }) | 410 | }) |
411 | .collect::<Vec<_>>(); | 411 | .collect::<Vec<_>>(); |
412 | self.update(module_id, Some(import_id), &resolutions); | 412 | self.update(module_id, Some(import_id), &resolutions); |
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 1749b491b..857f8a444 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -138,7 +138,7 @@ fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize | |||
138 | if c == '\n' { | 138 | if c == '\n' { |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | col_num = col_num + 1; | 141 | col_num += 1; |
142 | } | 142 | } |
143 | col_num | 143 | col_num |
144 | } | 144 | } |
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index d86445abf..2e12e126f 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -93,12 +93,11 @@ pub(crate) fn macro_def( | |||
93 | Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) | 93 | Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) |
94 | } | 94 | } |
95 | MacroDefKind::BuiltIn(expander) => { | 95 | MacroDefKind::BuiltIn(expander) => { |
96 | Some(Arc::new((TokenExpander::Builtin(expander.clone()), mbe::TokenMap::default()))) | 96 | Some(Arc::new((TokenExpander::Builtin(expander), mbe::TokenMap::default()))) |
97 | } | ||
98 | MacroDefKind::BuiltInDerive(expander) => { | ||
99 | Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default()))) | ||
97 | } | 100 | } |
98 | MacroDefKind::BuiltInDerive(expander) => Some(Arc::new(( | ||
99 | TokenExpander::BuiltinDerive(expander.clone()), | ||
100 | mbe::TokenMap::default(), | ||
101 | ))), | ||
102 | } | 101 | } |
103 | } | 102 | } |
104 | 103 | ||
diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/ra_hir_ty/src/autoderef.rs index ee48fa537..f32d5786a 100644 --- a/crates/ra_hir_ty/src/autoderef.rs +++ b/crates/ra_hir_ty/src/autoderef.rs | |||
@@ -48,7 +48,7 @@ fn deref_by_trait( | |||
48 | krate: CrateId, | 48 | krate: CrateId, |
49 | ty: InEnvironment<&Canonical<Ty>>, | 49 | ty: InEnvironment<&Canonical<Ty>>, |
50 | ) -> Option<Canonical<Ty>> { | 50 | ) -> Option<Canonical<Ty>> { |
51 | let deref_trait = match db.lang_item(krate.into(), "deref".into())? { | 51 | let deref_trait = match db.lang_item(krate, "deref".into())? { |
52 | LangItemTarget::TraitId(it) => it, | 52 | LangItemTarget::TraitId(it) => it, |
53 | _ => return None, | 53 | _ => return None, |
54 | }; | 54 | }; |
@@ -78,7 +78,7 @@ fn deref_by_trait( | |||
78 | 78 | ||
79 | let canonical = super::Canonical { num_vars: 1 + ty.value.num_vars, value: in_env }; | 79 | let canonical = super::Canonical { num_vars: 1 + ty.value.num_vars, value: in_env }; |
80 | 80 | ||
81 | let solution = db.trait_solve(krate.into(), canonical)?; | 81 | let solution = db.trait_solve(krate, canonical)?; |
82 | 82 | ||
83 | match &solution { | 83 | match &solution { |
84 | Solution::Unique(vars) => { | 84 | Solution::Unique(vars) => { |
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 7310ef10d..48abf97c9 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -919,7 +919,7 @@ impl HirDisplay for ApplicationTy { | |||
919 | { | 919 | { |
920 | Option::None => self.parameters.0.as_ref(), | 920 | Option::None => self.parameters.0.as_ref(), |
921 | Option::Some(default_parameters) => { | 921 | Option::Some(default_parameters) => { |
922 | for (i, parameter) in self.parameters.into_iter().enumerate() { | 922 | for (i, parameter) in self.parameters.iter().enumerate() { |
923 | match (parameter, default_parameters.get(i)) { | 923 | match (parameter, default_parameters.get(i)) { |
924 | (&Ty::Unknown, _) | (_, None) => { | 924 | (&Ty::Unknown, _) | (_, None) => { |
925 | non_default_parameters.push(parameter.clone()) | 925 | non_default_parameters.push(parameter.clone()) |
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 | ||
14 | pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { | 14 | pub(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 | ||
141 | fn pick_best<'a>(l: SyntaxToken, r: SyntaxToken) -> SyntaxToken { | 141 | fn 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 | ||
19 | pub mod tags { | 19 | pub 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 |
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index e29b688fd..e826c10ef 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -14,7 +14,7 @@ serde_json = "1.0.34" | |||
14 | serde = { version = "1.0.83", features = ["derive"] } | 14 | serde = { version = "1.0.83", features = ["derive"] } |
15 | crossbeam-channel = "0.4" | 15 | crossbeam-channel = "0.4" |
16 | log = "0.4.3" | 16 | log = "0.4.3" |
17 | lsp-types = { version = "0.63.1", features = ["proposed"] } | 17 | lsp-types = { version = "0.65.0", features = ["proposed"] } |
18 | rustc-hash = "1.0" | 18 | rustc-hash = "1.0" |
19 | parking_lot = "0.10.0" | 19 | parking_lot = "0.10.0" |
20 | jod-thread = "0.1.0" | 20 | jod-thread = "0.1.0" |
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index e0bb75666..d812ff7ca 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs | |||
@@ -2,10 +2,11 @@ | |||
2 | 2 | ||
3 | use lsp_types::{ | 3 | use lsp_types::{ |
4 | CodeActionProviderCapability, CodeLensOptions, CompletionOptions, | 4 | CodeActionProviderCapability, CodeLensOptions, CompletionOptions, |
5 | DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, | 5 | DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, |
6 | ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, | 6 | ImplementationProviderCapability, RenameOptions, RenameProviderCapability, |
7 | SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, | 7 | SelectionRangeProviderCapability, ServerCapabilities, SignatureHelpOptions, |
8 | TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, | 8 | TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, |
9 | TypeDefinitionProviderCapability, WorkDoneProgressOptions, | ||
9 | }; | 10 | }; |
10 | 11 | ||
11 | pub fn server_capabilities() -> ServerCapabilities { | 12 | pub fn server_capabilities() -> ServerCapabilities { |
@@ -44,7 +45,7 @@ pub fn server_capabilities() -> ServerCapabilities { | |||
44 | first_trigger_character: "=".to_string(), | 45 | first_trigger_character: "=".to_string(), |
45 | more_trigger_character: Some(vec![".".to_string(), ">".to_string()]), | 46 | more_trigger_character: Some(vec![".".to_string(), ">".to_string()]), |
46 | }), | 47 | }), |
47 | selection_range_provider: Some(GenericCapability::default()), | 48 | selection_range_provider: Some(SelectionRangeProviderCapability::Simple(true)), |
48 | folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), | 49 | folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), |
49 | rename_provider: Some(RenameProviderCapability::Options(RenameOptions { | 50 | rename_provider: Some(RenameProviderCapability::Options(RenameOptions { |
50 | prepare_provider: Some(true), | 51 | prepare_provider: Some(true), |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 965e7c53c..9e207415e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -131,7 +131,7 @@ pub fn main_loop( | |||
131 | let feature_flags = { | 131 | let feature_flags = { |
132 | let mut ff = FeatureFlags::default(); | 132 | let mut ff = FeatureFlags::default(); |
133 | for (flag, value) in config.feature_flags { | 133 | for (flag, value) in config.feature_flags { |
134 | if let Err(_) = ff.set(flag.as_str(), value) { | 134 | if ff.set(flag.as_str(), value).is_err() { |
135 | log::error!("unknown feature flag: {:?}", flag); | 135 | log::error!("unknown feature flag: {:?}", flag); |
136 | show_message( | 136 | show_message( |
137 | req::MessageType::Error, | 137 | req::MessageType::Error, |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5b64b27cd..5e3b1a73f 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -164,7 +164,7 @@ pub fn handle_on_type_formatting( | |||
164 | 164 | ||
165 | // in `ra_ide`, the `on_type` invariant is that | 165 | // in `ra_ide`, the `on_type` invariant is that |
166 | // `text.char_at(position) == typed_char`. | 166 | // `text.char_at(position) == typed_char`. |
167 | position.offset = position.offset - TextUnit::of_char('.'); | 167 | position.offset -= TextUnit::of_char('.'); |
168 | let char_typed = params.ch.chars().next().unwrap_or('\0'); | 168 | let char_typed = params.ch.chars().next().unwrap_or('\0'); |
169 | 169 | ||
170 | // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, | 170 | // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, |
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 39361b7e8..2a22b655c 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -10,8 +10,9 @@ pub use lsp_types::{ | |||
10 | DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions, | 10 | DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions, |
11 | DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, | 11 | DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, |
12 | FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, | 12 | FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, |
13 | ReferenceParams, Registration, RegistrationParams, ShowMessageParams, SignatureHelp, | 13 | ReferenceParams, Registration, RegistrationParams, SelectionRange, SelectionRangeParams, |
14 | TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, | 14 | ShowMessageParams, SignatureHelp, TextDocumentEdit, TextDocumentPositionParams, TextEdit, |
15 | WorkspaceEdit, WorkspaceSymbolParams, | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | pub enum AnalyzerStatus {} | 18 | pub enum AnalyzerStatus {} |
@@ -67,28 +68,6 @@ pub struct ExpandMacroParams { | |||
67 | pub position: Option<Position>, | 68 | pub position: Option<Position>, |
68 | } | 69 | } |
69 | 70 | ||
70 | pub enum SelectionRangeRequest {} | ||
71 | |||
72 | impl Request for SelectionRangeRequest { | ||
73 | type Params = SelectionRangeParams; | ||
74 | type Result = Vec<SelectionRange>; | ||
75 | const METHOD: &'static str = "textDocument/selectionRange"; | ||
76 | } | ||
77 | |||
78 | #[derive(Deserialize, Debug)] | ||
79 | #[serde(rename_all = "camelCase")] | ||
80 | pub struct SelectionRangeParams { | ||
81 | pub text_document: TextDocumentIdentifier, | ||
82 | pub positions: Vec<Position>, | ||
83 | } | ||
84 | |||
85 | #[derive(Serialize, Debug)] | ||
86 | #[serde(rename_all = "camelCase")] | ||
87 | pub struct SelectionRange { | ||
88 | pub range: Range, | ||
89 | pub parent: Option<Box<SelectionRange>>, | ||
90 | } | ||
91 | |||
92 | pub enum FindMatchingBrace {} | 71 | pub enum FindMatchingBrace {} |
93 | 72 | ||
94 | impl Request for FindMatchingBrace { | 73 | impl Request for FindMatchingBrace { |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 16cc11e8c..f89b23089 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -287,19 +287,15 @@ impl WorldSnapshot { | |||
287 | /// | 287 | /// |
288 | /// When processing non-windows path, this is essentially the same as `Url::from_file_path`. | 288 | /// When processing non-windows path, this is essentially the same as `Url::from_file_path`. |
289 | fn url_from_path_with_drive_lowercasing(path: impl AsRef<Path>) -> Result<Url> { | 289 | fn url_from_path_with_drive_lowercasing(path: impl AsRef<Path>) -> Result<Url> { |
290 | let component_has_windows_drive = path | 290 | let component_has_windows_drive = path.as_ref().components().any(|comp| { |
291 | .as_ref() | 291 | if let Component::Prefix(c) = comp { |
292 | .components() | 292 | match c.kind() { |
293 | .find(|comp| { | 293 | Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, |
294 | if let Component::Prefix(c) = comp { | 294 | _ => return false, |
295 | match c.kind() { | ||
296 | Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, | ||
297 | _ => return false, | ||
298 | } | ||
299 | } | 295 | } |
300 | false | 296 | } |
301 | }) | 297 | false |
302 | .is_some(); | 298 | }); |
303 | 299 | ||
304 | // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. | 300 | // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. |
305 | if component_has_windows_drive { | 301 | if component_has_windows_drive { |
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 45dad2d10..2c6ae5658 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -97,7 +97,9 @@ impl Shift { | |||
97 | tt::Leaf::Literal(lit) => lit.id = self.shift(lit.id), | 97 | tt::Leaf::Literal(lit) => lit.id = self.shift(lit.id), |
98 | }, | 98 | }, |
99 | tt::TokenTree::Subtree(tt) => { | 99 | tt::TokenTree::Subtree(tt) => { |
100 | tt.delimiter.as_mut().map(|it: &mut Delimiter| it.id = self.shift(it.id)); | 100 | if let Some(it) = tt.delimiter.as_mut() { |
101 | it.id = self.shift(it.id); | ||
102 | }; | ||
101 | self.shift_all(tt) | 103 | self.shift_all(tt) |
102 | } | 104 | } |
103 | } | 105 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 40db570da..04a5408fe 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -168,8 +168,7 @@ pub fn let_stmt(pattern: ast::Pat, initializer: Option<ast::Expr>) -> ast::LetSt | |||
168 | 168 | ||
169 | fn ast_from_text<N: AstNode>(text: &str) -> N { | 169 | fn ast_from_text<N: AstNode>(text: &str) -> N { |
170 | let parse = SourceFile::parse(text); | 170 | let parse = SourceFile::parse(text); |
171 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); | 171 | parse.tree().syntax().descendants().find_map(N::cast).unwrap() |
172 | res | ||
173 | } | 172 | } |
174 | 173 | ||
175 | pub mod tokens { | 174 | pub mod tokens { |