microcad_lang/syntax/call/
method_call.rs1use microcad_lang_base::{SrcRef, SrcReferrer, TreeDisplay, TreeState};
7
8use crate::syntax::*;
9
10#[derive(Clone)]
12pub struct MethodCall {
13 pub name: QualifiedName,
15 pub argument_list: ArgumentList,
17 pub src_ref: SrcRef,
19}
20
21impl SrcReferrer for MethodCall {
22 fn src_ref(&self) -> SrcRef {
23 self.src_ref.clone()
24 }
25}
26
27impl std::fmt::Display for MethodCall {
28 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
29 write!(f, "{}({})", self.name, self.argument_list)
30 }
31}
32
33impl std::fmt::Debug for MethodCall {
34 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
35 write!(f, "{:?}({:?})", self.name, self.argument_list)
36 }
37}
38
39impl TreeDisplay for MethodCall {
40 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
41 writeln!(f, "{:depth$}MethodCall '{}':", "", self.name)?;
42 depth.indent();
43 self.argument_list.tree_print(f, depth)
44 }
45}