diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-05 17:43:23 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-05 17:43:23 +0100 |
commit | a9dcd2cdca014d30e35638db4edeacbbf6eae6b3 (patch) | |
tree | 94bf1d637fe613360619b862f0d6126d478ec433 /crates/ra_ide_api | |
parent | 3775e5e27d39301770d396f320aac97b48cd47c0 (diff) | |
parent | 0b5e39919034d11c36655369f60cf9cc256743d0 (diff) |
Merge #1495
1495: use correct file for diagnostics r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index 9ab455b0e..a46289cba 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::cell::RefCell; | 1 | use std::cell::RefCell; |
2 | 2 | ||
3 | use hir::{ | 3 | use hir::{ |
4 | diagnostics::{Diagnostic as _, DiagnosticSink}, | 4 | diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}, |
5 | source_binder, | 5 | source_binder, |
6 | }; | 6 | }; |
7 | use itertools::Itertools; | 7 | use itertools::Itertools; |
@@ -9,7 +9,7 @@ use ra_assists::ast_editor::{AstBuilder, AstEditor}; | |||
9 | use ra_db::SourceDatabase; | 9 | use ra_db::SourceDatabase; |
10 | use ra_prof::profile; | 10 | use ra_prof::profile; |
11 | use ra_syntax::{ | 11 | use ra_syntax::{ |
12 | ast::{self, AstNode, NamedField, NamedFieldList}, | 12 | ast::{self, AstNode, NamedField}, |
13 | Location, SyntaxNode, TextRange, T, | 13 | Location, SyntaxNode, TextRange, T, |
14 | }; | 14 | }; |
15 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 15 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
@@ -34,9 +34,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
34 | fix: None, | 34 | fix: None, |
35 | })); | 35 | })); |
36 | 36 | ||
37 | let source_file = parse.tree; | 37 | for node in parse.tree.syntax().descendants() { |
38 | |||
39 | for node in source_file.syntax().descendants() { | ||
40 | check_unnecessary_braces_in_use_statement(&mut res, file_id, node); | 38 | check_unnecessary_braces_in_use_statement(&mut res, file_id, node); |
41 | check_struct_shorthand_initialization(&mut res, file_id, node); | 39 | check_struct_shorthand_initialization(&mut res, file_id, node); |
42 | } | 40 | } |
@@ -61,9 +59,8 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
61 | }) | 59 | }) |
62 | }) | 60 | }) |
63 | .on::<hir::diagnostics::MissingFields, _>(|d| { | 61 | .on::<hir::diagnostics::MissingFields, _>(|d| { |
64 | let syntax_node = d.syntax_node_ptr(); | 62 | let node = d.ast(db); |
65 | let node = NamedFieldList::cast(syntax_node.to_node(source_file.syntax())).unwrap(); | 63 | let mut ast_editor = AstEditor::new(&*node); |
66 | let mut ast_editor = AstEditor::new(node); | ||
67 | for f in d.missed_fields.iter() { | 64 | for f in d.missed_fields.iter() { |
68 | ast_editor.append_field(&AstBuilder::<NamedField>::from_name(f)); | 65 | ast_editor.append_field(&AstBuilder::<NamedField>::from_name(f)); |
69 | } | 66 | } |