1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crate::nodes::{Arguments, Expression, Prefix};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FunctionCall {
prefix: Box<Prefix>,
arguments: Arguments,
method: Option<String>,
}
impl FunctionCall {
pub fn new(prefix: Prefix, arguments: Arguments, method: Option<String>) -> Self {
Self {
prefix: Box::new(prefix),
arguments,
method,
}
}
pub fn from_name<T: Into<String>>(name: T) -> Self {
Self {
prefix: Box::new(Prefix::Identifier(name.into())),
arguments: Arguments::Tuple(Vec::new()),
method: None,
}
}
pub fn from_prefix<T: Into<Prefix>>(prefix: T) -> Self {
Self {
prefix: Box::new(prefix.into()),
arguments: Arguments::Tuple(Vec::new()),
method: None,
}
}
pub fn with_arguments<A: Into<Arguments>>(mut self, arguments: A) -> Self {
self.arguments = arguments.into();
self
}
pub fn append_argument<T: Into<Expression>>(mut self, argument: T) -> Self {
self.arguments = self.arguments.append_argument(argument);
self
}
pub fn with_method<IntoString: Into<String>>(mut self, method: IntoString) -> Self {
self.method.replace(method.into());
self
}
#[inline]
pub fn get_arguments(&self) -> &Arguments {
&self.arguments
}
#[inline]
pub fn get_method(&self) -> Option<&String> {
self.method.as_ref()
}
#[inline]
pub fn get_prefix(&self) -> &Prefix {
&self.prefix
}
#[inline]
pub fn take_method(&mut self) -> Option<String> {
self.method.take()
}
#[inline]
pub fn set_arguments(&mut self, arguments: Arguments) {
self.arguments = arguments;
}
#[inline]
pub fn set_method(&mut self, method: String) {
self.method.replace(method);
}
#[inline]
pub fn mutate_arguments(&mut self) -> &mut Arguments {
&mut self.arguments
}
#[inline]
pub fn mutate_prefix(&mut self) -> &mut Prefix {
&mut self.prefix
}
}