From 2e035fd0d1abc43d79f9df14698ffa926e525534 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 6 Mar 2024 13:26:09 +0100 Subject: [PATCH] compiler: Document function added in d0fc025bc81 ... and remove code needlessly added in that commit, too. --- internal/compiler/langtype.rs | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/internal/compiler/langtype.rs b/internal/compiler/langtype.rs index ac51aad6f85..7b2c059b2e2 100644 --- a/internal/compiler/langtype.rs +++ b/internal/compiler/langtype.rs @@ -481,27 +481,10 @@ impl ElementType { } } - pub fn can_have_child(&self, name: &str, tr: &TypeRegister) -> bool { - match self { - Self::Component(component) if component.child_insertion_point.borrow().is_none() => { - let base_type = component.root_element.borrow().base_type.clone(); - if base_type == tr.empty_type() { - false - } else { - base_type.can_have_child(name, tr) - } - } - Self::Builtin(builtin) => { - if builtin.additional_accepted_child_types.contains_key(name) { - true - } else { - !builtin.disallow_global_types_as_child_elements - } - } - _ => true, - } - } - + /// This function looks at the element and checks whether it can have Elements of type `name` as children. + /// It returns an Error if that is not possible or an Option of the ElementType if it is. + /// The option is unset when the compiler does not know the type well enough to avoid further + /// probing. pub fn accepts_child_element( &self, name: &str, @@ -537,6 +520,9 @@ impl ElementType { Ok(None) } + /// This function looks at the element and checks whether it can have Elements of type `name` as children. + /// In addition to what `accepts_child_element` does, this method also probes the type of `name`. + /// It returns an Error if that is not possible or an `ElementType` if it is. pub fn lookup_type_for_child_element( &self, name: &str,