mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
move index_resolve to symbol index
This commit is contained in:
parent
5173c6295b
commit
e4a6343e47
4 changed files with 11 additions and 14 deletions
|
@ -20,7 +20,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
|
||||||
let name_ref = calling_node.name_ref()?;
|
let name_ref = calling_node.name_ref()?;
|
||||||
|
|
||||||
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
||||||
let file_symbols = db.index_resolve(name_ref);
|
let file_symbols = crate::symbol_index::index_resolve(db, name_ref);
|
||||||
let symbol = file_symbols
|
let symbol = file_symbols
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find(|it| it.ptr.kind() == FN_DEF)?;
|
.find(|it| it.ptr.kind() == FN_DEF)?;
|
||||||
|
|
|
@ -118,8 +118,7 @@ pub(crate) fn reference_definition(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If that fails try the index based approach.
|
// If that fails try the index based approach.
|
||||||
let navs = db
|
let navs = crate::symbol_index::index_resolve(db, name_ref)
|
||||||
.index_resolve(name_ref)
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(NavigationTarget::from_symbol)
|
.map(NavigationTarget::from_symbol)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -2,13 +2,11 @@ use hir::{
|
||||||
self, Problem, source_binder
|
self, Problem, source_binder
|
||||||
};
|
};
|
||||||
use ra_ide_api_light::{self, LocalEdit, Severity};
|
use ra_ide_api_light::{self, LocalEdit, Severity};
|
||||||
use ra_syntax::ast;
|
|
||||||
use ra_db::SourceDatabase;
|
use ra_db::SourceDatabase;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db, Diagnostic, FileId, FilePosition, FileSystemEdit,
|
db, Diagnostic, FileId, FilePosition, FileSystemEdit,
|
||||||
Query, SourceChange, SourceFileEdit,
|
SourceChange, SourceFileEdit,
|
||||||
symbol_index::FileSymbol,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl db::RootDatabase {
|
impl db::RootDatabase {
|
||||||
|
@ -75,14 +73,6 @@ impl db::RootDatabase {
|
||||||
};
|
};
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
|
|
||||||
let name = name_ref.text();
|
|
||||||
let mut query = Query::new(name.to_string());
|
|
||||||
query.exact();
|
|
||||||
query.limit(4);
|
|
||||||
crate::symbol_index::world_symbols(self, query)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SourceChange {
|
impl SourceChange {
|
||||||
|
|
|
@ -109,6 +109,14 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol>
|
||||||
query.search(&buf)
|
query.search(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
|
||||||
|
let name = name_ref.text();
|
||||||
|
let mut query = Query::new(name.to_string());
|
||||||
|
query.exact();
|
||||||
|
query.limit(4);
|
||||||
|
crate::symbol_index::world_symbols(db, query)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub(crate) struct SymbolIndex {
|
pub(crate) struct SymbolIndex {
|
||||||
symbols: Vec<FileSymbol>,
|
symbols: Vec<FileSymbol>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue