---
source: crates/laburnum-syntax-macro/src/tests/cst_tests.rs
expression: "use laburnum_syntax_macro::tests::cst_tests::test_cst_with_field_types"
snapshot_kind: text
---
Input: >
  #[laburnum_syntax(CST)]
  pub struct ComplexCST {
      span: Span,
      start_token: NodeId<crate::Token>,
      children: Vec<NodeId>,
      end_token: Option<NodeId<crate::Token>>,
      trivia: Vec<crate::Trivia>,
  }

Output: >
  #[derive(Clone, PartialEq)]
  pub struct ComplexCST {
      pub span: laburnum::Span,
      pub start_token: NodeId<crate::Token>,
      pub children: Vec<NodeId>,
      pub end_token: Option<NodeId<crate::Token>>,
      pub trivia: Vec<crate::Trivia>,
  }
  impl ComplexCST {
      pub fn span(&self) -> laburnum::Span {
          self.span
      }
  }
  #[allow(unused)]
  impl std::fmt::Display for ComplexCST {
      fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          f.debug_struct(
                  &format!(
                      "{}::{}", { let __mp = module_path!(); let __stripped = __mp
                      .find("::").map(| i | & __mp[i + 2..]).unwrap_or(__mp); if let
                      Some(__last_sep) = __stripped.rfind("::") { let __last_seg = &
                      __stripped[__last_sep + 2..]; let __name = stringify!(ComplexCST);
                      let __seg_norm : std::string::String = __last_seg.chars().filter(| c
                      | * c != '_').collect(); let __name_norm : std::string::String =
                      __name.chars().filter(| c | * c != '_').collect(); if __seg_norm
                      .eq_ignore_ascii_case(& __name_norm) { & __stripped[..__last_sep] }
                      else { __stripped } } else { __stripped } }, stringify!(ComplexCST)
                  ),
              )
              .field("span", &self.span)
              .finish()
      }
  }
  #[allow(unused)]
  impl std::fmt::Debug for ComplexCST {
      fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          f.debug_struct(
                  &format!(
                      "{}::{}", { let __mp = module_path!(); let __stripped = __mp
                      .find("::").map(| i | & __mp[i + 2..]).unwrap_or(__mp); if let
                      Some(__last_sep) = __stripped.rfind("::") { let __last_seg = &
                      __stripped[__last_sep + 2..]; let __name = stringify!(ComplexCST);
                      let __seg_norm : std::string::String = __last_seg.chars().filter(| c
                      | * c != '_').collect(); let __name_norm : std::string::String =
                      __name.chars().filter(| c | * c != '_').collect(); if __seg_norm
                      .eq_ignore_ascii_case(& __name_norm) { & __stripped[..__last_sep] }
                      else { __stripped } } else { __stripped } }, stringify!(ComplexCST)
                  ),
              )
              .field("span", &self.span)
              .finish()
      }
  }
  #[allow(unused)]
  impl bluegum::Bluegum for ComplexCST {
      fn node(&self, b: &mut bluegum::Builder) {
          use owo_colors::OwoColorize;
          b.name(
                  &format!(
                      "{}::{}", { let __mp = module_path!(); let __stripped = __mp
                      .find("::").map(| i | & __mp[i + 2..]).unwrap_or(__mp); if let
                      Some(__last_sep) = __stripped.rfind("::") { let __last_seg = &
                      __stripped[__last_sep + 2..]; let __name = stringify!(ComplexCST);
                      let __seg_norm : std::string::String = __last_seg.chars().filter(| c
                      | * c != '_').collect(); let __name_norm : std::string::String =
                      __name.chars().filter(| c | * c != '_').collect(); if __seg_norm
                      .eq_ignore_ascii_case(& __name_norm) { & __stripped[..__last_sep] }
                      else { __stripped } } else { __stripped } }, stringify!(ComplexCST)
                  ),
              )
              .debug("span", self.span);
      }
  }
  #[allow(unused)]
  impl bluegum::BluegumWithState<crate::Printer<'_>> for ComplexCST {
      fn node_with_state(&self, b: &mut bluegum::Builder, state: &crate::Printer<'_>) {
          use owo_colors::OwoColorize;
          use unicode_width::UnicodeWidthStr;
          b.name(
                  &format!(
                      "{}::{}", { let __mp = module_path!(); let __stripped = __mp
                      .find("::").map(| i | & __mp[i + 2..]).unwrap_or(__mp); if let
                      Some(__last_sep) = __stripped.rfind("::") { let __last_seg = &
                      __stripped[__last_sep + 2..]; let __name = stringify!(ComplexCST);
                      let __seg_norm : std::string::String = __last_seg.chars().filter(| c
                      | * c != '_').collect(); let __name_norm : std::string::String =
                      __name.chars().filter(| c | * c != '_').collect(); if __seg_norm
                      .eq_ignore_ascii_case(& __name_norm) { & __stripped[..__last_sep] }
                      else { __stripped } } else { __stripped } }, stringify!(ComplexCST)
                  ),
              )
              .debug("span", self.span);
          {
              let start_token = &self.start_token;
              let mut t = bluegum::Builder::new();
              t.name("Literal");
              let s = format!("{}", start_token);
              if s.width() > 80 {
                  t.alt(format!("{:.80}...", s).bright_green());
              } else {
                  t.alt(format!("{:.80}", s).bright_green());
              };
              b.add_named_builder(stringify!(start_token), t);
              let children = &self.children;
              let mut t = bluegum::Builder::new();
              t.name("Literal");
              let s = format!("{}", children);
              if s.width() > 80 {
                  t.alt(format!("{:.80}...", s).bright_green());
              } else {
                  t.alt(format!("{:.80}", s).bright_green());
              };
              b.add_named_builder(stringify!(children), t);
              if let Some(ref end_token) = self.end_token {
                  let mut t = bluegum::Builder::new();
                  t.name("Literal");
                  let s = format!("{}", end_token);
                  if s.width() > 80 {
                      t.alt(format!("{:.80}...", s).bright_green());
                  } else {
                      t.alt(format!("{:.80}", s).bright_green());
                  };
                  b.add_named_builder(stringify!(end_token), t);
              }
              let trivia = &self.trivia;
              let mut t = bluegum::Builder::new();
              t.name("Literal");
              let s = format!("{}", trivia);
              if s.width() > 80 {
                  t.alt(format!("{:.80}...", s).bright_green());
              } else {
                  t.alt(format!("{:.80}", s).bright_green());
              };
              b.add_named_builder(stringify!(trivia), t);
          };
      }
  }
