From c847c079fd66d7ed09c64ff398baf05317b16500 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 17 May 2020 12:09:53 +0200 Subject: Add AssistConfig --- crates/ra_ide_db/src/source_change.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/ra_ide_db') diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs index af81a91a4..c64165f3a 100644 --- a/crates/ra_ide_db/src/source_change.rs +++ b/crates/ra_ide_db/src/source_change.rs @@ -13,6 +13,7 @@ pub struct SourceChange { pub source_file_edits: Vec, pub file_system_edits: Vec, pub cursor_position: Option, + pub is_snippet: bool, } impl SourceChange { @@ -28,6 +29,7 @@ impl SourceChange { source_file_edits, file_system_edits, cursor_position: None, + is_snippet: false, } } @@ -41,6 +43,7 @@ impl SourceChange { source_file_edits: edits, file_system_edits: vec![], cursor_position: None, + is_snippet: false, } } @@ -52,6 +55,7 @@ impl SourceChange { source_file_edits: vec![], file_system_edits: edits, cursor_position: None, + is_snippet: false, } } @@ -115,6 +119,7 @@ impl SingleFileChange { source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }], file_system_edits: Vec::new(), cursor_position: self.cursor_position.map(|offset| FilePosition { file_id, offset }), + is_snippet: false, } } } -- cgit v1.2.3 From 5258c817f78ecdfe12d7eec44ab3169134cba71d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 11:54:57 +0200 Subject: Remove cross-crate marks They create quite a bit of friction. Really, we should just move the tests to the same crate, rather than paper over existing split. --- crates/ra_ide_db/src/defs.rs | 10 ++-------- crates/ra_ide_db/src/lib.rs | 1 - crates/ra_ide_db/src/marks.rs | 12 ------------ crates/ra_ide_db/src/search.rs | 2 -- 4 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 crates/ra_ide_db/src/marks.rs (limited to 'crates/ra_ide_db') diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 60c11178e..8b06cbfc5 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -14,7 +14,6 @@ use ra_syntax::{ ast::{self, AstNode}, match_ast, }; -use test_utils::tested_by; use crate::RootDatabase; @@ -118,7 +117,6 @@ fn classify_name_inner(sema: &Semantics, name: &ast::Name) -> Opti match_ast! { match parent { ast::Alias(it) => { - tested_by!(goto_def_for_use_alias; force); let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; let path = use_tree.path()?; let path_segment = path.segment()?; @@ -203,6 +201,8 @@ impl NameRefClass { } } +// Note: we don't have unit-tests for this rather important function. +// It is primarily exercised via goto definition tests in `ra_ide`. pub fn classify_name_ref( sema: &Semantics, name_ref: &ast::NameRef, @@ -212,22 +212,18 @@ pub fn classify_name_ref( let parent = name_ref.syntax().parent()?; if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { - tested_by!(goto_def_for_methods; force); if let Some(func) = sema.resolve_method_call(&method_call) { return Some(NameRefClass::Definition(Definition::ModuleDef(func.into()))); } } if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) { - tested_by!(goto_def_for_fields; force); if let Some(field) = sema.resolve_field(&field_expr) { return Some(NameRefClass::Definition(Definition::Field(field))); } } if let Some(record_field) = ast::RecordField::for_field_name(name_ref) { - tested_by!(goto_def_for_record_fields; force); - tested_by!(goto_def_for_field_init_shorthand; force); if let Some((field, local)) = sema.resolve_record_field(&record_field) { let field = Definition::Field(field); let res = match local { @@ -239,7 +235,6 @@ pub fn classify_name_ref( } if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { - tested_by!(goto_def_for_record_field_pats; force); if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { let field = Definition::Field(field); return Some(NameRefClass::Definition(field)); @@ -247,7 +242,6 @@ pub fn classify_name_ref( } if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { - tested_by!(goto_def_for_macros; force); if let Some(macro_def) = sema.resolve_macro_call(¯o_call) { return Some(NameRefClass::Definition(Definition::Macro(macro_def))); } diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs index 52fcd7b6f..4f37954bf 100644 --- a/crates/ra_ide_db/src/lib.rs +++ b/crates/ra_ide_db/src/lib.rs @@ -2,7 +2,6 @@ //! //! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search. -pub mod marks; pub mod line_index; pub mod line_index_utils; pub mod symbol_index; diff --git a/crates/ra_ide_db/src/marks.rs b/crates/ra_ide_db/src/marks.rs deleted file mode 100644 index 386fe605c..000000000 --- a/crates/ra_ide_db/src/marks.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! See test_utils/src/marks.rs - -test_utils::marks![ - goto_def_for_macros - goto_def_for_use_alias - goto_def_for_methods - goto_def_for_fields - goto_def_for_record_fields - goto_def_for_field_init_shorthand - goto_def_for_record_field_pats - search_filters_by_range -]; diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index b464959fc..589f44771 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -12,7 +12,6 @@ use ra_db::{FileId, FileRange, SourceDatabaseExt}; use ra_prof::profile; use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize}; use rustc_hash::FxHashMap; -use test_utils::tested_by; use crate::{ defs::{classify_name_ref, Definition, NameRefClass}, @@ -209,7 +208,6 @@ impl Definition { for (idx, _) in text.match_indices(pat) { let offset: TextSize = idx.try_into().unwrap(); if !search_range.contains_inclusive(offset) { - tested_by!(search_filters_by_range; force); continue; } -- cgit v1.2.3 From 4fdb1eac08bc29029fe888967dcc11d38d25c205 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 21 May 2020 00:46:08 +0200 Subject: Remove unused cursor positions --- crates/ra_ide_db/src/source_change.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide_db') diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs index c64165f3a..94e118dd8 100644 --- a/crates/ra_ide_db/src/source_change.rs +++ b/crates/ra_ide_db/src/source_change.rs @@ -4,7 +4,7 @@ //! It can be viewed as a dual for `AnalysisChange`. use ra_db::{FileId, FilePosition, RelativePathBuf, SourceRootId}; -use ra_text_edit::{TextEdit, TextSize}; +use ra_text_edit::TextEdit; #[derive(Debug, Clone)] pub struct SourceChange { @@ -109,7 +109,6 @@ pub enum FileSystemEdit { pub struct SingleFileChange { pub label: String, pub edit: TextEdit, - pub cursor_position: Option, } impl SingleFileChange { @@ -118,7 +117,7 @@ impl SingleFileChange { label: self.label, source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }], file_system_edits: Vec::new(), - cursor_position: self.cursor_position.map(|offset| FilePosition { file_id, offset }), + cursor_position: None, is_snippet: false, } } -- cgit v1.2.3