aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-05 17:40:02 +0100
committerAleksey Kladov <[email protected]>2019-07-05 17:40:02 +0100
commit0b5e39919034d11c36655369f60cf9cc256743d0 (patch)
treec175d87985271961227a1716ce54fd1d2229e254 /crates/ra_ide_api
parentfd30ec406ba776e670dbd46b964de626f28e2857 (diff)
use correct file for diagnostics
closes #1475
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs13
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 @@
1use std::cell::RefCell; 1use std::cell::RefCell;
2 2
3use hir::{ 3use hir::{
4 diagnostics::{Diagnostic as _, DiagnosticSink}, 4 diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink},
5 source_binder, 5 source_binder,
6}; 6};
7use itertools::Itertools; 7use itertools::Itertools;
@@ -9,7 +9,7 @@ use ra_assists::ast_editor::{AstBuilder, AstEditor};
9use ra_db::SourceDatabase; 9use ra_db::SourceDatabase;
10use ra_prof::profile; 10use ra_prof::profile;
11use ra_syntax::{ 11use 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};
15use ra_text_edit::{TextEdit, TextEditBuilder}; 15use 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 }