aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/fixes/create_field.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics/fixes/create_field.rs')
-rw-r--r--crates/ide/src/diagnostics/fixes/create_field.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/crates/ide/src/diagnostics/fixes/create_field.rs b/crates/ide/src/diagnostics/fixes/create_field.rs
index 24e0fda52..a5f457dce 100644
--- a/crates/ide/src/diagnostics/fixes/create_field.rs
+++ b/crates/ide/src/diagnostics/fixes/create_field.rs
@@ -7,18 +7,17 @@ use syntax::{
7use text_edit::TextEdit; 7use text_edit::TextEdit;
8 8
9use crate::{ 9use crate::{
10 diagnostics::{fix, DiagnosticWithFix}, 10 diagnostics::{fix, DiagnosticWithFixes},
11 Assist, AssistResolveStrategy, 11 Assist, AssistResolveStrategy,
12}; 12};
13 13impl DiagnosticWithFixes for NoSuchField {
14impl DiagnosticWithFix for NoSuchField { 14 fn fixes(
15 fn fix(
16 &self, 15 &self,
17 sema: &Semantics<RootDatabase>, 16 sema: &Semantics<RootDatabase>,
18 _resolve: &AssistResolveStrategy, 17 _resolve: &AssistResolveStrategy,
19 ) -> Option<Assist> { 18 ) -> Option<Vec<Assist>> {
20 let root = sema.db.parse_or_expand(self.file)?; 19 let root = sema.db.parse_or_expand(self.file)?;
21 missing_record_expr_field_fix( 20 missing_record_expr_field_fixes(
22 &sema, 21 &sema,
23 self.file.original_file(sema.db), 22 self.file.original_file(sema.db),
24 &self.field.to_node(&root), 23 &self.field.to_node(&root),
@@ -26,11 +25,11 @@ impl DiagnosticWithFix for NoSuchField {
26 } 25 }
27} 26}
28 27
29fn missing_record_expr_field_fix( 28fn missing_record_expr_field_fixes(
30 sema: &Semantics<RootDatabase>, 29 sema: &Semantics<RootDatabase>,
31 usage_file_id: FileId, 30 usage_file_id: FileId,
32 record_expr_field: &ast::RecordExprField, 31 record_expr_field: &ast::RecordExprField,
33) -> Option<Assist> { 32) -> Option<Vec<Assist>> {
34 let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?; 33 let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?;
35 let def_id = sema.resolve_variant(record_lit)?; 34 let def_id = sema.resolve_variant(record_lit)?;
36 let module; 35 let module;
@@ -89,12 +88,12 @@ fn missing_record_expr_field_fix(
89 TextEdit::insert(last_field_syntax.text_range().end(), new_field), 88 TextEdit::insert(last_field_syntax.text_range().end(), new_field),
90 ); 89 );
91 90
92 return Some(fix( 91 return Some(vec![fix(
93 "create_field", 92 "create_field",
94 "Create field", 93 "Create field",
95 source_change, 94 source_change,
96 record_expr_field.syntax().text_range(), 95 record_expr_field.syntax().text_range(),
97 )); 96 )]);
98 97
99 fn record_field_list(field_def_list: ast::FieldList) -> Option<ast::RecordFieldList> { 98 fn record_field_list(field_def_list: ast::FieldList) -> Option<ast::RecordFieldList> {
100 match field_def_list { 99 match field_def_list {