mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
New node: String Split (#3304)
* Add two nodes for substring * fix: number convention * Remove unnecessay allocations and add support for \n in patterns * Make split node return Vec<String> and remove count_elements node * Add Cache implementations for Vec<String> * Code review --------- Co-authored-by: daniil.loban <daniil.loban@gmail.com> Co-authored-by: Dennis Kobert <dennis@kobert.dev> Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -88,7 +88,15 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
.iter()
|
||||
.map(|field| match &field.ty {
|
||||
ParsedFieldType::Regular(RegularParsedField { value_source, .. }) => match value_source {
|
||||
ParsedValueSource::Default(data) => quote!(RegistryValueSource::Default(stringify!(#data))),
|
||||
ParsedValueSource::Default(data) => {
|
||||
// Check if the data is a string literal by parsing the token stream
|
||||
let data_str = data.to_string();
|
||||
if data_str.starts_with('"') && data_str.ends_with('"') && data_str.len() >= 2 {
|
||||
quote!(RegistryValueSource::Default(#data))
|
||||
} else {
|
||||
quote!(RegistryValueSource::Default(stringify!(#data)))
|
||||
}
|
||||
}
|
||||
ParsedValueSource::Scope(data) => quote!(RegistryValueSource::Scope(#data)),
|
||||
_ => quote!(RegistryValueSource::None),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user