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:
Ali Rezvani 2024-04-23 05:17:23 +03:30 committed by GitHub
parent ab445d6acd
commit ac1a40fb43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -787,6 +787,14 @@ pub struct 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 {
if self.arguments.len() != 1 {
return false;