diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/structure.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/snapshots/highlighting.html | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index d8a712e27..0435188c8 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs | |||
@@ -4,10 +4,10 @@ use std::cell::RefCell; | |||
4 | 4 | ||
5 | use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; | 5 | use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; |
6 | use itertools::Itertools; | 6 | use itertools::Itertools; |
7 | use ra_assists::ast_editor::AstEditor; | ||
8 | use ra_db::SourceDatabase; | 7 | use ra_db::SourceDatabase; |
9 | use ra_prof::profile; | 8 | use ra_prof::profile; |
10 | use ra_syntax::{ | 9 | use ra_syntax::{ |
10 | algo, | ||
11 | ast::{self, make, AstNode}, | 11 | ast::{self, make, AstNode}, |
12 | Location, SyntaxNode, TextRange, T, | 12 | Location, SyntaxNode, TextRange, T, |
13 | }; | 13 | }; |
@@ -58,15 +58,15 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
58 | }) | 58 | }) |
59 | }) | 59 | }) |
60 | .on::<hir::diagnostics::MissingFields, _>(|d| { | 60 | .on::<hir::diagnostics::MissingFields, _>(|d| { |
61 | let node = d.ast(db); | 61 | let mut field_list = d.ast(db); |
62 | let mut ast_editor = AstEditor::new(node); | ||
63 | for f in d.missed_fields.iter() { | 62 | for f in d.missed_fields.iter() { |
64 | let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); | 63 | let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); |
65 | ast_editor.append_field(&field); | 64 | field_list = field_list.append_field(&field); |
66 | } | 65 | } |
67 | 66 | ||
68 | let mut builder = TextEditBuilder::default(); | 67 | let mut builder = TextEditBuilder::default(); |
69 | ast_editor.into_text_edit(&mut builder); | 68 | algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder); |
69 | |||
70 | let fix = | 70 | let fix = |
71 | SourceChange::source_file_edit_from("fill struct fields", file_id, builder.finish()); | 71 | SourceChange::source_file_edit_from("fill struct fields", file_id, builder.finish()); |
72 | res.borrow_mut().push(Diagnostic { | 72 | res.borrow_mut().push(Diagnostic { |
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index cae49567f..8815df747 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs | |||
@@ -79,7 +79,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
79 | node_range: node.syntax().text_range(), | 79 | node_range: node.syntax().text_range(), |
80 | kind: node.syntax().kind(), | 80 | kind: node.syntax().kind(), |
81 | detail, | 81 | detail, |
82 | deprecated: node.attrs().filter_map(|x| x.as_named()).any(|x| x == "deprecated"), | 82 | deprecated: node.attrs().filter_map(|x| x.simple_name()).any(|x| x == "deprecated"), |
83 | }) | 83 | }) |
84 | } | 84 | } |
85 | 85 | ||
diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide_api/src/snapshots/highlighting.html index b39c4d371..ae30ebba3 100644 --- a/crates/ra_ide_api/src/snapshots/highlighting.html +++ b/crates/ra_ide_api/src/snapshots/highlighting.html | |||
@@ -19,7 +19,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
19 | .keyword\.unsafe { color: #DFAF8F; } | 19 | .keyword\.unsafe { color: #DFAF8F; } |
20 | .keyword\.control { color: #F0DFAF; font-weight: bold; } | 20 | .keyword\.control { color: #F0DFAF; font-weight: bold; } |
21 | </style> | 21 | </style> |
22 | <pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span> | 22 | <pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute text">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span> |
23 | <span class="keyword">struct</span> <span class="type">Foo</span> { | 23 | <span class="keyword">struct</span> <span class="type">Foo</span> { |
24 | <span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>, | 24 | <span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>, |
25 | <span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>, | 25 | <span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>, |