diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 10 |
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 | ||
3 | use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; | 3 | use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; |
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | use ra_assists::ast_editor::AstEditor; | ||
6 | use ra_db::SourceDatabase; | 5 | use ra_db::SourceDatabase; |
7 | use ra_prof::profile; | 6 | use ra_prof::profile; |
8 | use ra_syntax::{ | 7 | use 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 { |