fn add_keep_substring_prefix_suffixes()

in amzn-smt-string-transformer/src/transpiler.rs [523:565]


    fn add_keep_substring_prefix_suffixes(&mut self) {
        if !self.char_to_char {
            let mut suffix_prefixes: HashMap<String, StringSetProperties> = HashMap::new();
            for (string_lit, props) in &self.string_lit_props {
                if matches!(
                    props,
                    StringSetProperties::Some {
                        len: _,
                        ranges: _,
                        keep_ints: _,
                        keep_substrings: _,
                        keep_prefix_suffix: true,
                    }
                ) {
                    for (sub_string_lit, sub_props) in &self.string_lit_props {
                        if matches!(
                            sub_props,
                            StringSetProperties::Some {
                                len: _,
                                ranges: _,
                                keep_ints: _,
                                keep_substrings: _,
                                keep_prefix_suffix: true,
                            }
                        ) && string_lit != sub_string_lit
                        {
                            if let Some(new_rel_string) =
                                Self::get_prefix_suffix(string_lit, sub_string_lit)
                            {
                                if !new_rel_string.is_empty() {
                                    suffix_prefixes.insert(
                                        new_rel_string.to_string(),
                                        sub_props.clone().update_with_truths(props.clone()),
                                    );
                                }
                            }
                        }
                    }
                }
            }
            self.string_lit_props.extend(suffix_prefixes);
        }
    }