mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Option begone part 2
This commit is contained in:
parent
96a774261f
commit
a2a3fecae3
31 changed files with 113 additions and 152 deletions
|
@ -32,18 +32,18 @@ pub struct DeclarationLocation {
|
|||
}
|
||||
|
||||
impl DeclarationLocation {
|
||||
pub fn syntax<DB: HirDatabase>(&self, sema: &Semantics<'_, DB>) -> Option<SyntaxNode> {
|
||||
let root = sema.parse_or_expand(self.hir_file_id)?;
|
||||
Some(self.ptr.to_node(&root))
|
||||
pub fn syntax<DB: HirDatabase>(&self, sema: &Semantics<'_, DB>) -> SyntaxNode {
|
||||
let root = sema.parse_or_expand(self.hir_file_id);
|
||||
self.ptr.to_node(&root)
|
||||
}
|
||||
|
||||
pub fn original_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
|
||||
let node = resolve_node(db, self.hir_file_id, &self.ptr)?;
|
||||
Some(node.as_ref().original_file_range(db.upcast()))
|
||||
pub fn original_range(&self, db: &dyn HirDatabase) -> FileRange {
|
||||
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> {
|
||||
let node = resolve_node(db, self.hir_file_id, &self.name_ptr)?;
|
||||
let node = resolve_node(db, self.hir_file_id, &self.name_ptr);
|
||||
node.as_ref().original_file_range_opt(db.upcast())
|
||||
}
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ fn resolve_node(
|
|||
db: &dyn HirDatabase,
|
||||
file_id: HirFileId,
|
||||
ptr: &SyntaxNodePtr,
|
||||
) -> Option<InFile<SyntaxNode>> {
|
||||
let root = db.parse_or_expand(file_id)?;
|
||||
) -> InFile<SyntaxNode> {
|
||||
let root = db.parse_or_expand(file_id);
|
||||
let node = ptr.to_node(&root);
|
||||
Some(InFile::new(file_id, node))
|
||||
InFile::new(file_id, node)
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue