diff options
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/diagnostics.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/folding_ranges.rs | 23 | ||||
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 3 |
5 files changed, 33 insertions, 7 deletions
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index dd8a7ffd9..73c0b8275 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs | |||
@@ -78,8 +78,10 @@ pub(crate) fn diagnostics( | |||
78 | } else { | 78 | } else { |
79 | let mut field_list = d.ast(db); | 79 | let mut field_list = d.ast(db); |
80 | for f in d.missed_fields.iter() { | 80 | for f in d.missed_fields.iter() { |
81 | let field = | 81 | let field = make::record_expr_field( |
82 | make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); | 82 | make::name_ref(&f.to_string()), |
83 | Some(make::expr_unit()), | ||
84 | ); | ||
83 | field_list = field_list.append_field(&field); | 85 | field_list = field_list.append_field(&field); |
84 | } | 86 | } |
85 | 87 | ||
@@ -178,9 +180,9 @@ fn missing_struct_field_fix( | |||
178 | if new_field_type.is_unknown() { | 180 | if new_field_type.is_unknown() { |
179 | return None; | 181 | return None; |
180 | } | 182 | } |
181 | let new_field = make::record_field_def( | 183 | let new_field = make::record_field( |
182 | record_expr.field_name()?, | 184 | record_expr.field_name()?, |
183 | make::type_ref(&new_field_type.display_source_code(sema.db, module.into()).ok()?), | 185 | make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?), |
184 | ); | 186 | ); |
185 | 187 | ||
186 | let last_field = record_fields.fields().last()?; | 188 | let last_field = record_fields.fields().last()?; |
diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs index 903c34996..0fbc9babd 100644 --- a/crates/ra_ide/src/folding_ranges.rs +++ b/crates/ra_ide/src/folding_ranges.rs | |||
@@ -85,7 +85,8 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { | |||
85 | COMMENT => Some(FoldKind::Comment), | 85 | COMMENT => Some(FoldKind::Comment), |
86 | USE => Some(FoldKind::Imports), | 86 | USE => Some(FoldKind::Imports), |
87 | ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), | 87 | ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), |
88 | RECORD_FIELD_LIST | 88 | ASSOC_ITEM_LIST |
89 | | RECORD_FIELD_LIST | ||
89 | | RECORD_PAT_FIELD_LIST | 90 | | RECORD_PAT_FIELD_LIST |
90 | | RECORD_EXPR_FIELD_LIST | 91 | | RECORD_EXPR_FIELD_LIST |
91 | | ITEM_LIST | 92 | | ITEM_LIST |
@@ -337,6 +338,26 @@ fn main() <fold block>{ | |||
337 | } | 338 | } |
338 | 339 | ||
339 | #[test] | 340 | #[test] |
341 | fn test_folds_structs() { | ||
342 | check( | ||
343 | r#" | ||
344 | struct Foo <fold block>{ | ||
345 | }</fold> | ||
346 | "#, | ||
347 | ); | ||
348 | } | ||
349 | |||
350 | #[test] | ||
351 | fn test_folds_traits() { | ||
352 | check( | ||
353 | r#" | ||
354 | trait Foo <fold block>{ | ||
355 | }</fold> | ||
356 | "#, | ||
357 | ); | ||
358 | } | ||
359 | |||
360 | #[test] | ||
340 | fn test_folds_macros() { | 361 | fn test_folds_macros() { |
341 | check( | 362 | check( |
342 | r#" | 363 | r#" |
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 3cd6c815b..c8d80fcf7 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -157,7 +157,7 @@ fn rename_to_self( | |||
157 | } | 157 | } |
158 | let first_param = params.params().next()?; | 158 | let first_param = params.params().next()?; |
159 | let mutable = match first_param.ty() { | 159 | let mutable = match first_param.ty() { |
160 | Some(ast::Type::ReferenceType(rt)) => rt.mut_token().is_some(), | 160 | Some(ast::Type::RefType(rt)) => rt.mut_token().is_some(), |
161 | _ => return None, // not renaming other types | 161 | _ => return None, // not renaming other types |
162 | }; | 162 | }; |
163 | 163 | ||
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 32f34ef10..a32ae0165 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -546,7 +546,7 @@ fn highlight_element( | |||
546 | T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { | 546 | T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { |
547 | HighlightTag::Macro.into() | 547 | HighlightTag::Macro.into() |
548 | } | 548 | } |
549 | T![*] if element.parent().and_then(ast::PointerType::cast).is_some() => { | 549 | T![*] if element.parent().and_then(ast::PtrType::cast).is_some() => { |
550 | HighlightTag::Keyword.into() | 550 | HighlightTag::Keyword.into() |
551 | } | 551 | } |
552 | T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { | 552 | T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { |
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 87a6e2523..2deee404c 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -9,6 +9,9 @@ use crate::{mock_analysis::single_file, FileRange, TextRange}; | |||
9 | fn test_highlighting() { | 9 | fn test_highlighting() { |
10 | check_highlighting( | 10 | check_highlighting( |
11 | r#" | 11 | r#" |
12 | use inner::{self as inner_mod}; | ||
13 | mod inner {} | ||
14 | |||
12 | #[derive(Clone, Debug)] | 15 | #[derive(Clone, Debug)] |
13 | struct Foo { | 16 | struct Foo { |
14 | pub x: i32, | 17 | pub x: i32, |