Rename BuiltinExpander to BuiltinFnLikeExpander

This commit is contained in:
Edwin Cheng 2019-11-23 21:54:39 +08:00
parent 720ab0bef8
commit 6940ae9eab
3 changed files with 14 additions and 14 deletions

View file

@ -9,7 +9,7 @@ use crate::{
use crate::quote; use crate::quote;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum BuiltinExpander { pub enum BuiltinFnLikeExpander {
Column, Column,
File, File,
Line, Line,
@ -18,7 +18,7 @@ pub enum BuiltinExpander {
struct BuiltInMacroInfo { struct BuiltInMacroInfo {
name: name::Name, name: name::Name,
kind: BuiltinExpander, kind: BuiltinFnLikeExpander,
expand: fn( expand: fn(
db: &dyn AstDatabase, db: &dyn AstDatabase,
id: MacroCallId, id: MacroCallId,
@ -29,7 +29,7 @@ struct BuiltInMacroInfo {
macro_rules! register_builtin { macro_rules! register_builtin {
( $(($name:ident, $kind: ident) => $expand:ident),* ) => { ( $(($name:ident, $kind: ident) => $expand:ident),* ) => {
const BUILTIN_MACROS: &[BuiltInMacroInfo] = &[ const BUILTIN_MACROS: &[BuiltInMacroInfo] = &[
$(BuiltInMacroInfo { name: name::$name, kind: BuiltinExpander::$kind, expand: $expand }),* $(BuiltInMacroInfo { name: name::$name, kind: BuiltinFnLikeExpander::$kind, expand: $expand }),*
]; ];
}; };
} }
@ -41,7 +41,7 @@ register_builtin! {
(STRINGIFY_MACRO, Stringify) => stringify_expand (STRINGIFY_MACRO, Stringify) => stringify_expand
} }
impl BuiltinExpander { impl BuiltinFnLikeExpander {
pub fn expand( pub fn expand(
&self, &self,
db: &dyn AstDatabase, db: &dyn AstDatabase,
@ -195,7 +195,7 @@ mod tests {
use crate::{test_db::TestDB, MacroCallLoc}; use crate::{test_db::TestDB, MacroCallLoc};
use ra_db::{fixture::WithFixture, SourceDatabase}; use ra_db::{fixture::WithFixture, SourceDatabase};
fn expand_builtin_macro(s: &str, expander: BuiltinExpander) -> String { fn expand_builtin_macro(s: &str, expander: BuiltinFnLikeExpander) -> String {
let (db, file_id) = TestDB::with_single_file(&s); let (db, file_id) = TestDB::with_single_file(&s);
let parsed = db.parse(file_id); let parsed = db.parse(file_id);
let macro_calls: Vec<_> = let macro_calls: Vec<_> =
@ -229,7 +229,7 @@ mod tests {
macro_rules! column {() => {}} macro_rules! column {() => {}}
column!() column!()
"#, "#,
BuiltinExpander::Column, BuiltinFnLikeExpander::Column,
); );
assert_eq!(expanded, "9"); assert_eq!(expanded, "9");
@ -243,7 +243,7 @@ mod tests {
macro_rules! line {() => {}} macro_rules! line {() => {}}
line!() line!()
"#, "#,
BuiltinExpander::Line, BuiltinFnLikeExpander::Line,
); );
assert_eq!(expanded, "4"); assert_eq!(expanded, "4");
@ -257,7 +257,7 @@ mod tests {
macro_rules! stringify {() => {}} macro_rules! stringify {() => {}}
stringify!(a b c) stringify!(a b c)
"#, "#,
BuiltinExpander::Stringify, BuiltinFnLikeExpander::Stringify,
); );
assert_eq!(expanded, "\"a b c\""); assert_eq!(expanded, "\"a b c\"");
@ -271,7 +271,7 @@ mod tests {
macro_rules! file {() => {}} macro_rules! file {() => {}}
file!() file!()
"#, "#,
BuiltinExpander::File, BuiltinFnLikeExpander::File,
); );
assert_eq!(expanded, "\"\""); assert_eq!(expanded, "\"\"");

View file

@ -9,14 +9,14 @@ use ra_prof::profile;
use ra_syntax::{AstNode, Parse, SyntaxNode}; use ra_syntax::{AstNode, Parse, SyntaxNode};
use crate::{ use crate::{
ast_id_map::AstIdMap, BuiltinExpander, HirFileId, HirFileIdRepr, MacroCallId, MacroCallLoc, ast_id_map::AstIdMap, BuiltinFnLikeExpander, HirFileId, HirFileIdRepr, MacroCallId,
MacroDefId, MacroDefKind, MacroFile, MacroFileKind, MacroCallLoc, MacroDefId, MacroDefKind, MacroFile, MacroFileKind,
}; };
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
pub enum TokenExpander { pub enum TokenExpander {
MacroRules(mbe::MacroRules), MacroRules(mbe::MacroRules),
Builtin(BuiltinExpander), Builtin(BuiltinFnLikeExpander),
} }
impl TokenExpander { impl TokenExpander {

View file

@ -24,7 +24,7 @@ use ra_syntax::{
}; };
use crate::ast_id_map::FileAstId; use crate::ast_id_map::FileAstId;
use crate::builtin_macro::BuiltinExpander; use crate::builtin_macro::BuiltinFnLikeExpander;
#[cfg(test)] #[cfg(test)]
mod test_db; mod test_db;
@ -138,7 +138,7 @@ pub struct MacroDefId {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MacroDefKind { pub enum MacroDefKind {
Declarative, Declarative,
BuiltIn(BuiltinExpander), BuiltIn(BuiltinFnLikeExpander),
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]