mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
internal: Don't parse files unnecessarily in scope_for_offset
This commit is contained in:
parent
84a6fac37a
commit
cb6703fe06
4 changed files with 10 additions and 6 deletions
|
@ -14,6 +14,8 @@ use std::{
|
|||
marker::PhantomData,
|
||||
};
|
||||
|
||||
use rowan::TextRange;
|
||||
|
||||
use crate::{syntax_node::RustLanguage, AstNode, SyntaxNode};
|
||||
|
||||
/// A "pointer" to a [`SyntaxNode`], via location in the source code.
|
||||
|
@ -60,6 +62,10 @@ impl<N: AstNode> AstPtr<N> {
|
|||
self.raw.clone()
|
||||
}
|
||||
|
||||
pub fn text_range(&self) -> TextRange {
|
||||
self.raw.text_range()
|
||||
}
|
||||
|
||||
pub fn cast<U: AstNode>(self) -> Option<AstPtr<U>> {
|
||||
if !U::can_cast(self.raw.kind()) {
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue