use crate::ast::node::expression::Expression; use crate::ast::node::generics::GenericArguments; #[derive(Debug)] pub struct CallExpression { callee: Box, turbo_fish: Option>, arguments: Box, } impl CallExpression { pub fn new( callee: Box, turbo_fish: Option>, arguments: Box, ) -> Self { Self { callee, turbo_fish, arguments, } } pub fn callee(&self) -> &Expression { &self.callee } pub fn callee_mut(&mut self) -> &mut Expression { &mut self.callee } pub fn turbo_fish(&self) -> Option<&TurboFish> { if let Some(turbo_fish) = &self.turbo_fish { Some(turbo_fish.as_ref()) } else { None } } pub fn turbo_fish_mut(&mut self) -> Option<&mut TurboFish> { if let Some(turbo_fish) = &mut self.turbo_fish { Some(turbo_fish.as_mut()) } else { None } } pub fn arguments(&self) -> &CallArguments { &self.arguments } pub fn arguments_mut(&mut self) -> &mut CallArguments { &mut self.arguments } } #[derive(Debug)] pub struct TurboFish(Box); impl TurboFish { pub fn new(generics: Box) -> Self { Self(generics) } pub fn generics(&self) -> &GenericArguments { &self.0 } pub fn generics_mut(&mut self) -> &mut GenericArguments { &mut self.0 } } #[derive(Debug)] pub struct CallArguments(Vec>); impl CallArguments { pub fn new(arguments: Vec>) -> Self { Self(arguments) } pub fn arguments(&self) -> Vec<&CallArgument> { self.0.iter().map(Box::as_ref).collect() } pub fn arguments_mut(&mut self) -> Vec<&mut CallArgument> { self.0.iter_mut().map(Box::as_mut).collect() } } #[derive(Debug)] pub struct CallArgument(Box); impl CallArgument { pub fn new(expression: Box) -> Self { Self(expression) } pub fn expression(&self) -> &Expression { &self.0 } pub fn expression_mut(&mut self) -> &mut Expression { &mut self.0 } }