From e010b144d5abcbd0947d0490123ef693a6a17c78 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Sep 2019 09:27:26 +0300 Subject: move field list to ast/edit.rs --- crates/ra_ide_api/src/diagnostics.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide_api') 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; use hir::diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSink}; use itertools::Itertools; -use ra_assists::ast_editor::AstEditor; use ra_db::SourceDatabase; use ra_prof::profile; use ra_syntax::{ + algo, ast::{self, make, AstNode}, Location, SyntaxNode, TextRange, T, }; @@ -56,15 +56,15 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec }) }) .on::(|d| { - let node = d.ast(db); - let mut ast_editor = AstEditor::new(node); + let mut field_list = d.ast(db); for f in d.missed_fields.iter() { let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); - ast_editor.append_field(&field); + field_list = field_list.append_field(&field); } let mut builder = TextEditBuilder::default(); - ast_editor.into_text_edit(&mut builder); + algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder); + let fix = SourceChange::source_file_edit_from("fill struct fields", file_id, builder.finish()); res.borrow_mut().push(Diagnostic { -- cgit v1.2.3 From 5a4b4f507e9b90bfe41b451763868cba0a70c392 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Mon, 30 Sep 2019 05:15:03 +0800 Subject: Fix API of Attr --- crates/ra_ide_api/src/display/structure.rs | 2 +- crates/ra_ide_api/src/snapshots/highlighting.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide_api') diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index be042ed17..38a56d752 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs @@ -77,7 +77,7 @@ fn structure_node(node: &SyntaxNode) -> Option { node_range: node.syntax().text_range(), kind: node.syntax().kind(), detail, - deprecated: node.attrs().filter_map(|x| x.as_named()).any(|x| x == "deprecated"), + deprecated: node.attrs().filter_map(|x| x.simple_name()).any(|x| x == "deprecated"), }) } 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 .keyword\.unsafe { color: #DFAF8F; } .keyword\.control { color: #F0DFAF; font-weight: bold; } -
#[derive(Clone, Debug)]
+
#[derive(Clone, Debug)]
 struct Foo {
     pub x: i32,
     pub y: i32,
-- 
cgit v1.2.3