mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
use LocalSyntaxPtr for file symbol
This commit is contained in:
parent
f534d2132b
commit
267a89bca2
3 changed files with 47 additions and 51 deletions
|
@ -360,9 +360,10 @@ impl db::RootDatabase {
|
|||
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
|
||||
let file_symbols = self.index_resolve(name_ref)?;
|
||||
for (fn_file_id, fs) in file_symbols {
|
||||
if fs.kind == FN_DEF {
|
||||
if fs.ptr.kind() == FN_DEF {
|
||||
let fn_file = self.source_file(fn_file_id);
|
||||
if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) {
|
||||
let fn_def = fs.ptr.resolve(&fn_file);
|
||||
let fn_def = ast::FnDef::cast(fn_def.borrowed()).unwrap();
|
||||
let descr = ctry!(source_binder::function_from_source(
|
||||
self, fn_file_id, fn_def
|
||||
)?);
|
||||
|
@ -408,7 +409,6 @@ impl db::RootDatabase {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
@ -231,9 +231,9 @@ impl NavigationTarget {
|
|||
fn from_symbol(file_id: FileId, symbol: FileSymbol) -> NavigationTarget {
|
||||
NavigationTarget {
|
||||
name: symbol.name.clone(),
|
||||
kind: symbol.kind.clone(),
|
||||
kind: symbol.ptr.kind(),
|
||||
file_id,
|
||||
range: symbol.node_range.clone(),
|
||||
range: symbol.ptr.range(),
|
||||
}
|
||||
}
|
||||
pub fn name(&self) -> &SmolStr {
|
||||
|
|
|
@ -5,12 +5,12 @@ use std::{
|
|||
|
||||
use fst::{self, Streamer};
|
||||
use ra_syntax::{
|
||||
SyntaxNodeRef, SourceFileNode, SmolStr, TextRange,
|
||||
SyntaxNodeRef, SourceFileNode, SmolStr,
|
||||
algo::visit::{visitor, Visitor},
|
||||
SyntaxKind::{self, *},
|
||||
ast::{self, NameOwner},
|
||||
};
|
||||
use ra_db::{SyntaxDatabase, SourceRootId, FilesDatabase};
|
||||
use ra_db::{SyntaxDatabase, SourceRootId, FilesDatabase, LocalSyntaxPtr};
|
||||
use salsa::ParallelDatabase;
|
||||
use rayon::prelude::*;
|
||||
|
||||
|
@ -140,7 +140,7 @@ impl Query {
|
|||
let idx = indexed_value.value as usize;
|
||||
|
||||
let (file_id, symbol) = &file_symbols.symbols[idx];
|
||||
if self.only_types && !is_type(symbol.kind) {
|
||||
if self.only_types && !is_type(symbol.ptr.kind()) {
|
||||
continue;
|
||||
}
|
||||
if self.exact && symbol.name != self.query {
|
||||
|
@ -163,9 +163,7 @@ fn is_type(kind: SyntaxKind) -> bool {
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct FileSymbol {
|
||||
pub(crate) name: SmolStr,
|
||||
pub(crate) node_range: TextRange,
|
||||
pub(crate) kind: SyntaxKind,
|
||||
_x: (),
|
||||
pub(crate) ptr: LocalSyntaxPtr,
|
||||
}
|
||||
|
||||
fn to_symbol(node: SyntaxNodeRef) -> Option<FileSymbol> {
|
||||
|
@ -173,9 +171,7 @@ fn to_symbol(node: SyntaxNodeRef) -> Option<FileSymbol> {
|
|||
let name = node.name()?;
|
||||
Some(FileSymbol {
|
||||
name: name.text(),
|
||||
node_range: node.syntax().range(),
|
||||
kind: node.syntax().kind(),
|
||||
_x: (),
|
||||
ptr: LocalSyntaxPtr::new(node.syntax()),
|
||||
})
|
||||
}
|
||||
visitor()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue