aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 144bc0a70..4fa07e3dc 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -2,10 +2,10 @@ use std::cell::RefCell;
2 2
3use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; 3use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink};
4use itertools::Itertools; 4use itertools::Itertools;
5use ra_assists::ast_editor::AstEditor;
6use ra_db::SourceDatabase; 5use ra_db::SourceDatabase;
7use ra_prof::profile; 6use ra_prof::profile;
8use ra_syntax::{ 7use ra_syntax::{
8 algo,
9 ast::{self, make, AstNode}, 9 ast::{self, make, AstNode},
10 Location, SyntaxNode, TextRange, T, 10 Location, SyntaxNode, TextRange, T,
11}; 11};
@@ -56,15 +56,15 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
56 }) 56 })
57 }) 57 })
58 .on::<hir::diagnostics::MissingFields, _>(|d| { 58 .on::<hir::diagnostics::MissingFields, _>(|d| {
59 let node = d.ast(db); 59 let mut field_list = d.ast(db);
60 let mut ast_editor = AstEditor::new(node);
61 for f in d.missed_fields.iter() { 60 for f in d.missed_fields.iter() {
62 let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); 61 let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit()));
63 ast_editor.append_field(&field); 62 field_list = field_list.append_field(&field);
64 } 63 }
65 64
66 let mut builder = TextEditBuilder::default(); 65 let mut builder = TextEditBuilder::default();
67 ast_editor.into_text_edit(&mut builder); 66 algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder);
67
68 let fix = 68 let fix =
69 SourceChange::source_file_edit_from("fill struct fields", file_id, builder.finish()); 69 SourceChange::source_file_edit_from("fill struct fields", file_id, builder.finish());
70 res.borrow_mut().push(Diagnostic { 70 res.borrow_mut().push(Diagnostic {