diff options
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r-- | crates/ra_ide_db/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_db/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_ide_db/src/marks.rs | 9 |
4 files changed, 17 insertions, 0 deletions
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 7b285d280..7ff1a536e 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml | |||
@@ -21,6 +21,7 @@ ra_syntax = { path = "../ra_syntax" } | |||
21 | ra_text_edit = { path = "../ra_text_edit" } | 21 | ra_text_edit = { path = "../ra_text_edit" } |
22 | ra_db = { path = "../ra_db" } | 22 | ra_db = { path = "../ra_db" } |
23 | ra_prof = { path = "../ra_prof" } | 23 | ra_prof = { path = "../ra_prof" } |
24 | test_utils = { path = "../test_utils" } | ||
24 | 25 | ||
25 | # ra_ide should depend only on the top-level `hir` package. if you need | 26 | # ra_ide should depend only on the top-level `hir` package. if you need |
26 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. | 27 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. |
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 | }; |
17 | use test_utils::tested_by; | ||
17 | 18 | ||
18 | use crate::RootDatabase; | 19 | use 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(¯o_call) { | 249 | if let Some(macro_def) = sema.resolve_macro_call(¯o_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 | ||
5 | pub mod marks; | ||
5 | pub mod line_index; | 6 | pub mod line_index; |
6 | pub mod line_index_utils; | 7 | pub mod line_index_utils; |
7 | pub mod feature_flags; | 8 | pub 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 | |||
3 | test_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 | ]; | ||