Rename derive-specific APIs
This commit is contained in:
parent
a627377949
commit
54c78c96db
@ -673,7 +673,7 @@ fn macro_call_as_call_id(
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_attr_as_call_id(
|
fn derive_macro_as_call_id(
|
||||||
item_attr: &AstIdWithPath<ast::Item>,
|
item_attr: &AstIdWithPath<ast::Item>,
|
||||||
db: &dyn db::DefDatabase,
|
db: &dyn db::DefDatabase,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
@ -685,7 +685,7 @@ fn item_attr_as_call_id(
|
|||||||
.as_lazy_macro(
|
.as_lazy_macro(
|
||||||
db.upcast(),
|
db.upcast(),
|
||||||
krate,
|
krate,
|
||||||
MacroCallKind::Attr(item_attr.ast_id, last_segment.to_string()),
|
MacroCallKind::Derive(item_attr.ast_id, last_segment.to_string()),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
Ok(res)
|
Ok(res)
|
||||||
|
@ -575,7 +575,7 @@ mod diagnostics {
|
|||||||
let node = ast.to_node(db.upcast());
|
let node = ast.to_node(db.upcast());
|
||||||
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)), None)
|
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)), None)
|
||||||
}
|
}
|
||||||
MacroCallKind::Attr(ast, name) => {
|
MacroCallKind::Derive(ast, name) => {
|
||||||
let node = ast.to_node(db.upcast());
|
let node = ast.to_node(db.upcast());
|
||||||
|
|
||||||
// Compute the precise location of the macro name's token in the derive
|
// Compute the precise location of the macro name's token in the derive
|
||||||
@ -631,7 +631,7 @@ mod diagnostics {
|
|||||||
let node = ast.to_node(db.upcast());
|
let node = ast.to_node(db.upcast());
|
||||||
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
|
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
|
||||||
}
|
}
|
||||||
MacroCallKind::Attr(ast, _) => {
|
MacroCallKind::Derive(ast, _) => {
|
||||||
let node = ast.to_node(db.upcast());
|
let node = ast.to_node(db.upcast());
|
||||||
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
|
(ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ use syntax::ast;
|
|||||||
use crate::{
|
use crate::{
|
||||||
attr::Attrs,
|
attr::Attrs,
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
item_attr_as_call_id,
|
derive_macro_as_call_id,
|
||||||
item_scope::{ImportType, PerNsGlobImports},
|
item_scope::{ImportType, PerNsGlobImports},
|
||||||
item_tree::{
|
item_tree::{
|
||||||
self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroRules, Mod, ModItem, ModKind,
|
self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroRules, Mod, ModItem, ModKind,
|
||||||
@ -820,8 +820,8 @@ impl DefCollector<'_> {
|
|||||||
true
|
true
|
||||||
});
|
});
|
||||||
attribute_macros.retain(|directive| {
|
attribute_macros.retain(|directive| {
|
||||||
match item_attr_as_call_id(&directive.ast_id, self.db, self.def_map.krate, |path| {
|
match derive_macro_as_call_id(&directive.ast_id, self.db, self.def_map.krate, |path| {
|
||||||
self.resolve_attribute_macro(&directive, &path)
|
self.resolve_derive_macro(&directive, &path)
|
||||||
}) {
|
}) {
|
||||||
Ok(call_id) => {
|
Ok(call_id) => {
|
||||||
resolved.push((directive.module_id, call_id, 0));
|
resolved.push((directive.module_id, call_id, 0));
|
||||||
@ -844,7 +844,7 @@ impl DefCollector<'_> {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_attribute_macro(
|
fn resolve_derive_macro(
|
||||||
&self,
|
&self,
|
||||||
directive: &DeriveDirective,
|
directive: &DeriveDirective,
|
||||||
path: &ModPath,
|
path: &ModPath,
|
||||||
|
@ -317,7 +317,7 @@ $0
|
|||||||
local_inner: false,
|
local_inner: false,
|
||||||
},
|
},
|
||||||
krate: CrateId(0),
|
krate: CrateId(0),
|
||||||
kind: MacroCallKind::Attr(attr_id, name.to_string()),
|
kind: MacroCallKind::Derive(attr_id, name.to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let id: MacroCallId = db.intern_macro(loc).into();
|
let id: MacroCallId = db.intern_macro(loc).into();
|
||||||
|
@ -271,21 +271,21 @@ pub struct MacroCallLoc {
|
|||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum MacroCallKind {
|
pub enum MacroCallKind {
|
||||||
FnLike(AstId<ast::MacroCall>),
|
FnLike(AstId<ast::MacroCall>),
|
||||||
Attr(AstId<ast::Item>, String),
|
Derive(AstId<ast::Item>, String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MacroCallKind {
|
impl MacroCallKind {
|
||||||
fn file_id(&self) -> HirFileId {
|
fn file_id(&self) -> HirFileId {
|
||||||
match self {
|
match self {
|
||||||
MacroCallKind::FnLike(ast_id) => ast_id.file_id,
|
MacroCallKind::FnLike(ast_id) => ast_id.file_id,
|
||||||
MacroCallKind::Attr(ast_id, _) => ast_id.file_id,
|
MacroCallKind::Derive(ast_id, _) => ast_id.file_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node(&self, db: &dyn db::AstDatabase) -> InFile<SyntaxNode> {
|
fn node(&self, db: &dyn db::AstDatabase) -> InFile<SyntaxNode> {
|
||||||
match self {
|
match self {
|
||||||
MacroCallKind::FnLike(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()),
|
MacroCallKind::FnLike(ast_id) => ast_id.with_value(ast_id.to_node(db).syntax().clone()),
|
||||||
MacroCallKind::Attr(ast_id, _) => {
|
MacroCallKind::Derive(ast_id, _) => {
|
||||||
ast_id.with_value(ast_id.to_node(db).syntax().clone())
|
ast_id.with_value(ast_id.to_node(db).syntax().clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ impl MacroCallKind {
|
|||||||
MacroCallKind::FnLike(ast_id) => {
|
MacroCallKind::FnLike(ast_id) => {
|
||||||
Some(ast_id.to_node(db).token_tree()?.syntax().clone())
|
Some(ast_id.to_node(db).token_tree()?.syntax().clone())
|
||||||
}
|
}
|
||||||
MacroCallKind::Attr(ast_id, _) => Some(ast_id.to_node(db).syntax().clone()),
|
MacroCallKind::Derive(ast_id, _) => Some(ast_id.to_node(db).syntax().clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user