Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/symbols.rs')
-rw-r--r--crates/hir/src/symbols.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/crates/hir/src/symbols.rs b/crates/hir/src/symbols.rs
index ca7874c368..03112f6de5 100644
--- a/crates/hir/src/symbols.rs
+++ b/crates/hir/src/symbols.rs
@@ -9,7 +9,7 @@ use hir_def::{
};
use hir_expand::{HirFileId, InFile};
use hir_ty::db::HirDatabase;
-use syntax::{ast::HasName, AstNode, SmolStr, SyntaxNode, SyntaxNodePtr};
+use syntax::{ast::HasName, AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr};
use crate::{Module, ModuleDef, Semantics};
@@ -32,7 +32,7 @@ pub struct DeclarationLocation {
/// This points to the whole syntax node of the declaration.
pub ptr: SyntaxNodePtr,
/// This points to the [`syntax::ast::Name`] identifier of the declaration.
- pub name_ptr: SyntaxNodePtr,
+ pub name_ptr: AstPtr<syntax::ast::Name>,
}
impl DeclarationLocation {
@@ -49,15 +49,6 @@ impl DeclarationLocation {
let node = resolve_node(db, self.hir_file_id, &self.ptr);
node.as_ref().original_file_range(db.upcast())
}
-
- pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
- if let Some(file_id) = self.hir_file_id.file_id() {
- // fast path to prevent parsing
- return Some(FileRange { file_id, range: self.name_ptr.text_range() });
- }
- let node = resolve_node(db, self.hir_file_id, &self.name_ptr);
- node.as_ref().original_file_range_opt(db.upcast())
- }
}
fn resolve_node(
@@ -190,7 +181,7 @@ impl<'a> SymbolCollector<'a> {
let dec_loc = DeclarationLocation {
hir_file_id: source.file_id,
ptr: SyntaxNodePtr::new(use_tree_src.syntax()),
- name_ptr: SyntaxNodePtr::new(name.syntax()),
+ name_ptr: AstPtr::new(&name),
};
self.symbols.push(FileSymbol {
@@ -294,7 +285,7 @@ impl<'a> SymbolCollector<'a> {
let dec_loc = DeclarationLocation {
hir_file_id: source.file_id,
ptr: SyntaxNodePtr::new(source.value.syntax()),
- name_ptr: SyntaxNodePtr::new(name_node.syntax()),
+ name_ptr: AstPtr::new(&name_node),
};
if let Some(attrs) = def.attrs(self.db) {
@@ -327,7 +318,7 @@ impl<'a> SymbolCollector<'a> {
let dec_loc = DeclarationLocation {
hir_file_id: declaration.file_id,
ptr: SyntaxNodePtr::new(module.syntax()),
- name_ptr: SyntaxNodePtr::new(name_node.syntax()),
+ name_ptr: AstPtr::new(&name_node),
};
let def = ModuleDef::Module(module_id.into());