mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
remove not that useful indirection
This commit is contained in:
parent
b8b7969bfb
commit
7de6eaa58a
4 changed files with 8 additions and 18 deletions
|
@ -465,7 +465,7 @@ where
|
||||||
|
|
||||||
if let Some(path) = e.path().and_then(|path| self.parse_path(path)) {
|
if let Some(path) = e.path().and_then(|path| self.parse_path(path)) {
|
||||||
if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) {
|
if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) {
|
||||||
let call_id = MacroCallLoc { def: def.id, ast_id }.id(self.db);
|
let call_id = self.db.intern_macro(MacroCallLoc { def: def.id, ast_id });
|
||||||
let file_id = call_id.as_file(MacroFileKind::Expr);
|
let file_id = call_id.as_file(MacroFileKind::Expr);
|
||||||
if let Some(node) = self.db.parse_or_expand(file_id) {
|
if let Some(node) = self.db.parse_or_expand(file_id) {
|
||||||
if let Some(expr) = ast::Expr::cast(node) {
|
if let Some(expr) = ast::Expr::cast(node) {
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl ModuleImplBlocks {
|
||||||
{
|
{
|
||||||
if let Some(def) = self.module.resolver(db).resolve_path_as_macro(db, &path)
|
if let Some(def) = self.module.resolver(db).resolve_path_as_macro(db, &path)
|
||||||
{
|
{
|
||||||
let call_id = MacroCallLoc { def: def.id, ast_id }.id(db);
|
let call_id = db.intern_macro(MacroCallLoc { def: def.id, ast_id });
|
||||||
let file_id = call_id.as_file(MacroFileKind::Items);
|
let file_id = call_id.as_file(MacroFileKind::Items);
|
||||||
if let Some(item_list) =
|
if let Some(item_list) =
|
||||||
db.parse_or_expand(file_id).and_then(ast::MacroItems::cast)
|
db.parse_or_expand(file_id).and_then(ast::MacroItems::cast)
|
||||||
|
|
|
@ -448,7 +448,7 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(def) = resolved_res.resolved_def.get_macros() {
|
if let Some(def) = resolved_res.resolved_def.get_macros() {
|
||||||
let call_id = MacroCallLoc { def: def.id, ast_id: *ast_id }.id(self.db);
|
let call_id = self.db.intern_macro(MacroCallLoc { def: def.id, ast_id: *ast_id });
|
||||||
resolved.push((*module_id, call_id, def.id));
|
resolved.push((*module_id, call_id, def.id));
|
||||||
res = ReachedFixedPoint::No;
|
res = ReachedFixedPoint::No;
|
||||||
return false;
|
return false;
|
||||||
|
@ -690,7 +690,7 @@ where
|
||||||
self.def_collector.def_map[self.module_id].scope.get_legacy_macro(&name)
|
self.def_collector.def_map[self.module_id].scope.get_legacy_macro(&name)
|
||||||
}) {
|
}) {
|
||||||
let def = macro_def.id;
|
let def = macro_def.id;
|
||||||
let macro_call_id = MacroCallLoc { def, ast_id }.id(self.def_collector.db);
|
let macro_call_id = self.def_collector.db.intern_macro(MacroCallLoc { def, ast_id });
|
||||||
|
|
||||||
self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, def);
|
self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, def);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//! `ra_hir_def` contains initial "phases" of the compiler. Roughly, everything
|
//! `ra_hir_expand` deals with macro expansion.
|
||||||
//! before types.
|
|
||||||
//!
|
//!
|
||||||
//! Note that we are in the process of moving parts of `ra_hir` into
|
//! Specifically, it implements a concept of `MacroFile` -- a file whose syntax
|
||||||
//! `ra_hir_def`, so this crates doesn't contain a lot at the moment.
|
//! tree originates not from the text of some `FileId`, but from some macro
|
||||||
|
//! expansion.
|
||||||
|
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod ast_id_map;
|
pub mod ast_id_map;
|
||||||
|
@ -116,22 +116,12 @@ pub struct MacroCallLoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MacroCallId {
|
impl MacroCallId {
|
||||||
pub fn loc(self, db: &impl AstDatabase) -> MacroCallLoc {
|
|
||||||
db.lookup_intern_macro(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_file(self, kind: MacroFileKind) -> HirFileId {
|
pub fn as_file(self, kind: MacroFileKind) -> HirFileId {
|
||||||
let macro_file = MacroFile { macro_call_id: self, macro_file_kind: kind };
|
let macro_file = MacroFile { macro_call_id: self, macro_file_kind: kind };
|
||||||
macro_file.into()
|
macro_file.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MacroCallLoc {
|
|
||||||
pub fn id(self, db: &impl AstDatabase) -> MacroCallId {
|
|
||||||
db.intern_macro(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `AstId` points to an AST node in any file.
|
/// `AstId` points to an AST node in any file.
|
||||||
///
|
///
|
||||||
/// It is stable across reparses, and can be used as salsa key/value.
|
/// It is stable across reparses, and can be used as salsa key/value.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue