internal: Don't parse files unnecessarily in scope_for_offset
This commit is contained in:
parent
84a6fac37a
commit
cb6703fe06
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1318,9 +1318,9 @@ checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||
|
||||
[[package]]
|
||||
name = "rowan"
|
||||
version = "0.15.5"
|
||||
version = "0.15.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce1f383129e417a6265b16ed78e6e9307748f0863b2ba75f78ff14717db5b017"
|
||||
checksum = "e88acf7b001007e9e8c989fe7449f6601d909e5dd2c56399fc158977ad6c56e8"
|
||||
dependencies = [
|
||||
"countme",
|
||||
"hashbrown",
|
||||
|
@ -650,9 +650,7 @@ fn scope_for_offset(
|
||||
.filter_map(|(id, scope)| {
|
||||
let InFile { file_id, value } = source_map.expr_syntax(*id).ok()?;
|
||||
if from_file == file_id {
|
||||
let root = db.parse_or_expand(file_id)?;
|
||||
let node = value.to_node(&root);
|
||||
return Some((node.syntax().text_range(), scope));
|
||||
return Some((value.text_range(), scope));
|
||||
}
|
||||
|
||||
// FIXME handle attribute expansion
|
||||
|
@ -13,7 +13,7 @@ doctest = false
|
||||
[dependencies]
|
||||
cov-mark = "2.0.0-pre.1"
|
||||
itertools = "0.10.3"
|
||||
rowan = "0.15.5"
|
||||
rowan = "0.15.8"
|
||||
rustc_lexer = { version = "725.0.0", package = "rustc-ap-rustc_lexer" }
|
||||
rustc-hash = "1.1.0"
|
||||
once_cell = "1.12.0"
|
||||
|
@ -14,6 +14,8 @@
|
||||
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 @@ pub fn syntax_node_ptr(&self) -> SyntaxNodePtr {
|
||||
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…
Reference in New Issue
Block a user