luaur_analysis/functions/
maybe_string.rs1use crate::functions::follow_type::follow_type_id;
2use crate::functions::get_type_alt_j::get_type_id;
3use crate::functions::is_prim::is_prim;
4use crate::records::any_type::AnyType;
5use crate::records::primitive_type::PrimitiveType;
6use crate::records::union_type::UnionType;
7use crate::type_aliases::type_id::TypeId;
8
9pub fn maybe_string(ty: TypeId) -> bool {
10 let ty = unsafe { follow_type_id(ty) };
11
12 if is_prim(ty, PrimitiveType::String) || unsafe { !get_type_id::<AnyType>(ty).is_null() } {
13 return true;
14 }
15
16 if let Some(utv) = unsafe { get_type_id::<UnionType>(ty).as_ref() } {
17 for &part in &utv.options {
18 if maybe_string(part) {
19 return true;
20 }
21 }
22 }
23
24 false
25}