internal: Don't parse files unnecessarily in scope_for_offset
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user