mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
return Declaration from classify_name_ref
This commit is contained in:
parent
83f780eabf
commit
121aa35f12
6 changed files with 326 additions and 185 deletions
|
@ -55,8 +55,8 @@ pub(crate) fn reference_definition(
|
|||
use self::ReferenceResult::*;
|
||||
|
||||
let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None);
|
||||
|
||||
match classify_name_ref(db, &analyzer, name_ref) {
|
||||
let name_kind = classify_name_ref(db, file_id, &analyzer, &name_ref).and_then(|d| Some(d.item));
|
||||
match name_kind {
|
||||
Some(Macro(mac)) => return Exact(NavigationTarget::from_macro_def(db, mac)),
|
||||
Some(FieldAccess(field)) => return Exact(NavigationTarget::from_field(db, field)),
|
||||
Some(AssocItem(assoc)) => return Exact(NavigationTarget::from_assoc_item(db, assoc)),
|
||||
|
@ -69,7 +69,7 @@ pub(crate) fn reference_definition(
|
|||
return Exact(NavigationTarget::from_adt_def(db, def_id));
|
||||
}
|
||||
}
|
||||
Some(Pat(pat)) => return Exact(NavigationTarget::from_pat(db, file_id, pat)),
|
||||
Some(Pat((_, pat))) => return Exact(NavigationTarget::from_pat(db, file_id, pat)),
|
||||
Some(SelfParam(par)) => return Exact(NavigationTarget::from_self_param(file_id, par)),
|
||||
Some(GenericParam(_)) => {
|
||||
// FIXME: go to the generic param def
|
||||
|
@ -275,7 +275,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn goto_definition_works_for_macros() {
|
||||
covers!(goto_definition_works_for_macros);
|
||||
// covers!(goto_definition_works_for_macros);
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
|
@ -295,7 +295,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn goto_definition_works_for_macros_from_other_crates() {
|
||||
covers!(goto_definition_works_for_macros);
|
||||
// covers!(goto_definition_works_for_macros);
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
|
@ -318,7 +318,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn goto_definition_works_for_methods() {
|
||||
covers!(goto_definition_works_for_methods);
|
||||
// covers!(goto_definition_works_for_methods);
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
|
@ -337,7 +337,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn goto_definition_works_for_fields() {
|
||||
covers!(goto_definition_works_for_fields);
|
||||
// covers!(goto_definition_works_for_fields);
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
|
@ -355,7 +355,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn goto_definition_works_for_record_fields() {
|
||||
covers!(goto_definition_works_for_record_fields);
|
||||
// covers!(goto_definition_works_for_record_fields);
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue