mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Use cached module scopes for completion
This commit is contained in:
parent
9b88ec488b
commit
397c235086
5 changed files with 71 additions and 51 deletions
|
@ -3,7 +3,7 @@ pub(crate) mod scope;
|
|||
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, NameOwner},
|
||||
SmolStr, SyntaxNode,
|
||||
SmolStr, SyntaxNode, SyntaxNodeRef,
|
||||
};
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
|
@ -154,6 +154,16 @@ struct ModuleData {
|
|||
}
|
||||
|
||||
impl ModuleSource {
|
||||
pub(crate) fn for_node(file_id: FileId, node: SyntaxNodeRef) -> ModuleSource {
|
||||
for node in node.ancestors() {
|
||||
if let Some(m) = ast::Module::cast(node) {
|
||||
if !m.has_semi() {
|
||||
return ModuleSource::new_inline(file_id, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
ModuleSource::SourceFile(file_id)
|
||||
}
|
||||
pub(crate) fn new_inline(file_id: FileId, module: ast::Module) -> ModuleSource {
|
||||
assert!(!module.has_semi());
|
||||
let ptr = SyntaxPtr::new(file_id, module.syntax());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue