mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
sema parse_or_expand
This commit is contained in:
parent
0447be7589
commit
a69af9daa3
2 changed files with 11 additions and 2 deletions
|
@ -143,6 +143,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
||||||
self.imp.parse(file_id)
|
self.imp.parse(file_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parse_or_expand(&self, file_id: HirFileId) -> Option<SyntaxNode> {
|
||||||
|
self.imp.parse_or_expand(file_id)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
|
pub fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
|
||||||
self.imp.expand(macro_call)
|
self.imp.expand(macro_call)
|
||||||
}
|
}
|
||||||
|
@ -416,6 +420,12 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
tree
|
tree
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_or_expand(&self, file_id: HirFileId) -> Option<SyntaxNode> {
|
||||||
|
let node = self.db.parse_or_expand(file_id)?;
|
||||||
|
self.cache(node.clone(), file_id);
|
||||||
|
Some(node)
|
||||||
|
}
|
||||||
|
|
||||||
fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
|
fn expand(&self, macro_call: &ast::MacroCall) -> Option<SyntaxNode> {
|
||||||
let sa = self.analyze(macro_call.syntax());
|
let sa = self.analyze(macro_call.syntax());
|
||||||
let file_id = sa.expand(self.db, InFile::new(sa.file_id, macro_call))?;
|
let file_id = sa.expand(self.db, InFile::new(sa.file_id, macro_call))?;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
//! are located in different caches, with different APIs.
|
//! are located in different caches, with different APIs.
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir::{
|
use hir::{
|
||||||
db::AstDatabase,
|
|
||||||
import_map::{self, ImportKind},
|
import_map::{self, ImportKind},
|
||||||
AsAssocItem, Crate, ItemInNs, Semantics,
|
AsAssocItem, Crate, ItemInNs, Semantics,
|
||||||
};
|
};
|
||||||
|
@ -136,7 +135,7 @@ fn get_name_definition(
|
||||||
let _p = profile::span("get_name_definition");
|
let _p = profile::span("get_name_definition");
|
||||||
let file_id = import_candidate.file_id;
|
let file_id = import_candidate.file_id;
|
||||||
|
|
||||||
let candidate_node = import_candidate.ptr.to_node(&sema.db.parse_or_expand(file_id)?);
|
let candidate_node = import_candidate.ptr.to_node(&sema.parse_or_expand(file_id)?);
|
||||||
let candidate_name_node = if candidate_node.kind() != NAME {
|
let candidate_name_node = if candidate_node.kind() != NAME {
|
||||||
candidate_node.children().find(|it| it.kind() == NAME)?
|
candidate_node.children().find(|it| it.kind() == NAME)?
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue