dioxus_rsx/
diagnostics.rs1use proc_macro2_diagnostics::Diagnostic;
2use quote::ToTokens;
3
4#[derive(Debug, Clone, Default)]
9pub struct Diagnostics {
10 pub diagnostics: Vec<Diagnostic>,
11}
12
13impl Diagnostics {
14 pub fn new() -> Self {
15 Self {
16 diagnostics: vec![],
17 }
18 }
19
20 pub fn push(&mut self, diagnostic: Diagnostic) {
21 self.diagnostics.push(diagnostic);
22 }
23
24 pub fn extend(&mut self, diagnostics: Vec<Diagnostic>) {
25 self.diagnostics.extend(diagnostics);
26 }
27
28 pub fn is_empty(&self) -> bool {
29 self.diagnostics.is_empty()
30 }
31
32 pub fn into_diagnostics(self) -> Vec<Diagnostic> {
33 self.diagnostics
34 }
35
36 pub fn len(&self) -> usize {
37 self.diagnostics.len()
38 }
39}
40
41impl PartialEq for Diagnostics {
42 fn eq(&self, _other: &Self) -> bool {
43 true
44 }
45}
46
47impl Eq for Diagnostics {}
48
49impl ToTokens for Diagnostics {
50 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
51 for diagnostic in &self.diagnostics {
52 tokens.extend(diagnostic.clone().emit_as_expr_tokens());
53 }
54 }
55}