mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
restore index-based gotodef
This commit is contained in:
parent
84f2509730
commit
7960c8b276
2 changed files with 21 additions and 5 deletions
|
@ -214,7 +214,7 @@ impl AnalysisImpl {
|
||||||
{
|
{
|
||||||
let scope = fn_descr.scope(&*self.db);
|
let scope = fn_descr.scope(&*self.db);
|
||||||
// First try to resolve the symbol locally
|
// First try to resolve the symbol locally
|
||||||
return if let Some(entry) = scope.resolve_local_name(name_ref) {
|
if let Some(entry) = scope.resolve_local_name(name_ref) {
|
||||||
let mut vec = vec![];
|
let mut vec = vec![];
|
||||||
vec.push((
|
vec.push((
|
||||||
position.file_id,
|
position.file_id,
|
||||||
|
@ -224,12 +224,11 @@ impl AnalysisImpl {
|
||||||
kind: NAME,
|
kind: NAME,
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
Ok(vec)
|
return Ok(vec);
|
||||||
} else {
|
|
||||||
// If that fails try the index based approach.
|
|
||||||
self.index_resolve(name_ref)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// If that fails try the index based approach.
|
||||||
|
return self.index_resolve(name_ref);
|
||||||
}
|
}
|
||||||
if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) {
|
if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) {
|
||||||
if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) {
|
if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) {
|
||||||
|
|
|
@ -18,6 +18,23 @@ fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) {
|
||||||
analysis.resolve_callable(position).unwrap().unwrap()
|
analysis.resolve_callable(position).unwrap().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn approximate_resolve_works_in_items() {
|
||||||
|
let (analysis, pos) = analysis_and_position(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
struct Foo;
|
||||||
|
enum E { X(Foo<|>) }
|
||||||
|
",
|
||||||
|
);
|
||||||
|
|
||||||
|
let symbols = analysis.approximately_resolve_symbol(pos).unwrap();
|
||||||
|
assert_eq_dbg(
|
||||||
|
r#"[(FileId(1), FileSymbol { name: "Foo", node_range: [0; 11), kind: STRUCT_DEF })]"#,
|
||||||
|
&symbols,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_resolve_module() {
|
fn test_resolve_module() {
|
||||||
let (analysis, pos) = analysis_and_position(
|
let (analysis, pos) = analysis_and_position(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue