MCPcopy Create free account
hub / github.com/hashintel/hash / generate

Function generate

libs/@local/hashql/macros/src/sym.rs:74–107  ·  view source on GitHub ↗
(entries: &[SymbolEntry])

Source from the content-addressed store, hash-verified

72}
73
74fn generate(entries: &[SymbolEntry]) -> TokenStream {
75 let mut output = TokenStream::new();
76
77 // 1. SYMBOLS array
78 let mut symbol_values = Vec::new();
79 for entry in entries {
80 collect_symbol_values(entry, &mut symbol_values);
81 }
82 output.extend(quote! {
83 pub(crate) static SYMBOLS: &[&str] = &[
84 #(#symbol_values),*
85 ];
86 });
87
88 // 2. Constants and modules
89 let mut counter = 0;
90 for entry in entries {
91 generate_entry_constants(entry, &mut counter, &mut output);
92 }
93
94 // 3. LOOKUP
95 let mut lookup_entries = Vec::new();
96 let mut module_path = Vec::new();
97 for entry in entries {
98 generate_lookup_entry(entry, &mut module_path, &mut lookup_entries);
99 }
100 output.extend(quote! {
101 pub(crate) static LOOKUP: &[(&'static str, super::repr::Repr)] = &[
102 #(#lookup_entries),*
103 ];
104 });
105
106 output
107}
108
109fn collect_symbol_values(entry: &SymbolEntry, values: &mut Vec<TokenStream>) {
110 match entry {

Callers 9

expandFunction · 0.70
runFunction · 0.50
generateMethod · 0.50
instantiateFunction · 0.50
user_web_permissionsFunction · 0.50
org_web_permissionsFunction · 0.50
executeMethod · 0.50

Calls 4

collect_symbol_valuesFunction · 0.85
generate_entry_constantsFunction · 0.85
generate_lookup_entryFunction · 0.85
extendMethod · 0.45

Tested by 6

generateMethod · 0.40
instantiateFunction · 0.40
user_web_permissionsFunction · 0.40
org_web_permissionsFunction · 0.40