mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
compiler: Remove unnecessary StructName::User checks
The node check covers this already.
This commit is contained in:
parent
6f15cca650
commit
d2f294cf3d
7 changed files with 8 additions and 8 deletions
|
|
@ -114,7 +114,7 @@ impl JsComponentCompiler {
|
|||
pub fn structs(&self, env: Env) -> HashMap<String, JsUnknown> {
|
||||
fn convert_type(env: &Env, ty: &Type) -> Option<(String, JsUnknown)> {
|
||||
match ty {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
let name = s.name.slint_name().unwrap();
|
||||
let struct_instance = to_js_unknown(
|
||||
env,
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ impl CompilationResult {
|
|||
|
||||
for struct_or_enum in self.result.structs_and_enums(i_slint_core::InternalToken {}) {
|
||||
match struct_or_enum {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
let struct_instance =
|
||||
self.type_collection.struct_to_py(slint_interpreter::Struct::from_iter(
|
||||
s.fields.iter().map(|(name, field_type)| {
|
||||
|
|
|
|||
|
|
@ -921,7 +921,7 @@ pub fn generate_types(used_types: &[Type], config: &Config) -> File {
|
|||
|
||||
for ty in used_types {
|
||||
match ty {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
generate_struct(&mut file, &s.name, &s.fields, s.node.as_ref().unwrap());
|
||||
}
|
||||
Type::Enumeration(en) => {
|
||||
|
|
@ -4344,7 +4344,7 @@ pub fn generate_type_aliases(file: &mut File, doc: &Document) {
|
|||
Some((&export.0.name, component.id.clone()))
|
||||
}
|
||||
Either::Right(ty) => match &ty {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
Some((&export.0.name, s.name.cpp_type().unwrap()))
|
||||
}
|
||||
Type::Enumeration(en) => Some((&export.0.name, en.name.clone())),
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ fn convert_from_value_fn(ty: &Type) -> String {
|
|||
fn generate_value_conversions(file: &mut File, structs_and_enums: &[Type]) {
|
||||
for ty in structs_and_enums {
|
||||
match ty {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
let StructName::User(struct_name) = &s.name else {
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3645,7 +3645,7 @@ pub fn generate_named_exports(exports: &crate::object_tree::Exports) -> Vec<Toke
|
|||
}
|
||||
}
|
||||
Either::Right(ty) => match &ty {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
if let StructName::User(user_name) = &s.name
|
||||
&& *user_name == export.0.name
|
||||
{
|
||||
|
|
|
|||
|
|
@ -950,7 +950,7 @@ pub async fn load(
|
|||
Some((&export.0.name, &component.id))
|
||||
}
|
||||
Either::Right(ty) => match &ty {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
|
||||
Type::Struct(s) if s.node.is_some() => {
|
||||
if let StructName::User(user_name) = &s.name {
|
||||
Some((&export.0.name, user_name))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1253,7 +1253,7 @@ fn get_document_symbols(
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
r.extend(inner_types.iter().filter_map(|c| match c {
|
||||
Type::Struct(s) if s.name.is_some() && s.node.is_some() => Some(DocumentSymbol {
|
||||
Type::Struct(s) if s.node.is_some() => Some(DocumentSymbol {
|
||||
range: util::node_to_lsp_range(
|
||||
s.node.as_ref().unwrap().parent().as_ref()?,
|
||||
document_cache.format,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue