Skip to content

Commit e4a6343

Browse files
committed
move index_resolve to symbol index
1 parent 5173c62 commit e4a6343

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

crates/ra_ide_api/src/call_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
2020
let name_ref = calling_node.name_ref()?;
2121

2222
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
23-
let file_symbols = db.index_resolve(name_ref);
23+
let file_symbols = crate::symbol_index::index_resolve(db, name_ref);
2424
let symbol = file_symbols
2525
.into_iter()
2626
.find(|it| it.ptr.kind() == FN_DEF)?;

crates/ra_ide_api/src/goto_definition.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ pub(crate) fn reference_definition(
118118
}
119119
}
120120
// If that fails try the index based approach.
121-
let navs = db
122-
.index_resolve(name_ref)
121+
let navs = crate::symbol_index::index_resolve(db, name_ref)
123122
.into_iter()
124123
.map(NavigationTarget::from_symbol)
125124
.collect();

crates/ra_ide_api/src/imp.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ use hir::{
22
self, Problem, source_binder
33
};
44
use ra_ide_api_light::{self, LocalEdit, Severity};
5-
use ra_syntax::ast;
65
use ra_db::SourceDatabase;
76

87
use crate::{
98
db, Diagnostic, FileId, FilePosition, FileSystemEdit,
10-
Query, SourceChange, SourceFileEdit,
11-
symbol_index::FileSymbol,
9+
SourceChange, SourceFileEdit,
1210
};
1311

1412
impl db::RootDatabase {
@@ -75,14 +73,6 @@ impl db::RootDatabase {
7573
};
7674
res
7775
}
78-
79-
pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
80-
let name = name_ref.text();
81-
let mut query = Query::new(name.to_string());
82-
query.exact();
83-
query.limit(4);
84-
crate::symbol_index::world_symbols(self, query)
85-
}
8676
}
8777

8878
impl SourceChange {

crates/ra_ide_api/src/symbol_index.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol>
109109
query.search(&buf)
110110
}
111111

112+
pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
113+
let name = name_ref.text();
114+
let mut query = Query::new(name.to_string());
115+
query.exact();
116+
query.limit(4);
117+
crate::symbol_index::world_symbols(db, query)
118+
}
119+
112120
#[derive(Default, Debug)]
113121
pub(crate) struct SymbolIndex {
114122
symbols: Vec<FileSymbol>,

0 commit comments

Comments
 (0)