mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(ast): add callee_name method to the CallExpression. (#3076)
Adds a simple way to get the name of a given `CallExpression`.
This commit is contained in:
parent
ab445d6acd
commit
ac1a40fb43
1 changed files with 8 additions and 0 deletions
|
|
@ -787,6 +787,14 @@ pub struct CallExpression<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CallExpression<'a> {
|
impl<'a> CallExpression<'a> {
|
||||||
|
pub fn callee_name(&self) -> Option<&str> {
|
||||||
|
match &self.callee {
|
||||||
|
Expression::Identifier(ident) => Some(ident.name.as_str()),
|
||||||
|
Expression::MemberExpression(member) => member.static_property_name(),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_require_call(&self) -> bool {
|
pub fn is_require_call(&self) -> bool {
|
||||||
if self.arguments.len() != 1 {
|
if self.arguments.len() != 1 {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue