aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src')
-rw-r--r--crates/ra_ide_db/src/defs.rs6
-rw-r--r--crates/ra_ide_db/src/lib.rs1
-rw-r--r--crates/ra_ide_db/src/marks.rs9
3 files changed, 16 insertions, 0 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index f057435bf..97961bb6d 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -14,6 +14,7 @@ use ra_syntax::{
14 ast::{self, AstNode, VisibilityOwner}, 14 ast::{self, AstNode, VisibilityOwner},
15 match_ast, 15 match_ast,
16}; 16};
17use test_utils::tested_by;
17 18
18use crate::RootDatabase; 19use crate::RootDatabase;
19 20
@@ -217,18 +218,22 @@ pub fn classify_name_ref(
217 let parent = name_ref.syntax().parent()?; 218 let parent = name_ref.syntax().parent()?;
218 219
219 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { 220 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
221 tested_by!(goto_def_for_methods; force);
220 if let Some(func) = sema.resolve_method_call(&method_call) { 222 if let Some(func) = sema.resolve_method_call(&method_call) {
221 return Some(NameRefClass::Definition(Definition::ModuleDef(func.into()))); 223 return Some(NameRefClass::Definition(Definition::ModuleDef(func.into())));
222 } 224 }
223 } 225 }
224 226
225 if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) { 227 if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) {
228 tested_by!(goto_def_for_fields; force);
226 if let Some(field) = sema.resolve_field(&field_expr) { 229 if let Some(field) = sema.resolve_field(&field_expr) {
227 return Some(NameRefClass::Definition(Definition::StructField(field))); 230 return Some(NameRefClass::Definition(Definition::StructField(field)));
228 } 231 }
229 } 232 }
230 233
231 if let Some(record_field) = ast::RecordField::cast(parent.clone()) { 234 if let Some(record_field) = ast::RecordField::cast(parent.clone()) {
235 tested_by!(goto_def_for_record_fields; force);
236 tested_by!(goto_def_for_field_init_shorthand; force);
232 if let Some((field, local)) = sema.resolve_record_field(&record_field) { 237 if let Some((field, local)) = sema.resolve_record_field(&record_field) {
233 let field = Definition::StructField(field); 238 let field = Definition::StructField(field);
234 let res = match local { 239 let res = match local {
@@ -240,6 +245,7 @@ pub fn classify_name_ref(
240 } 245 }
241 246
242 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { 247 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) {
248 tested_by!(goto_def_for_macros; force);
243 if let Some(macro_def) = sema.resolve_macro_call(&macro_call) { 249 if let Some(macro_def) = sema.resolve_macro_call(&macro_call) {
244 return Some(NameRefClass::Definition(Definition::Macro(macro_def))); 250 return Some(NameRefClass::Definition(Definition::Macro(macro_def)));
245 } 251 }
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs
index 877ac3c38..aa312c140 100644
--- a/crates/ra_ide_db/src/lib.rs
+++ b/crates/ra_ide_db/src/lib.rs
@@ -2,6 +2,7 @@
2//! 2//!
3//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search. 3//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
4 4
5pub mod marks;
5pub mod line_index; 6pub mod line_index;
6pub mod line_index_utils; 7pub mod line_index_utils;
7pub mod feature_flags; 8pub mod feature_flags;
diff --git a/crates/ra_ide_db/src/marks.rs b/crates/ra_ide_db/src/marks.rs
new file mode 100644
index 000000000..d088fa257
--- /dev/null
+++ b/crates/ra_ide_db/src/marks.rs
@@ -0,0 +1,9 @@
1//! See test_utils/src/marks.rs
2
3test_utils::marks![
4 goto_def_for_macros
5 goto_def_for_methods
6 goto_def_for_fields
7 goto_def_for_record_fields
8 goto_def_for_field_init_shorthand
9];