Add errors for duplicate properties and blocks

This commit is contained in:
James Westman 2022-05-27 13:27:18 -05:00
parent f18c8b7a2d
commit 824476bda1
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
12 changed files with 122 additions and 0 deletions

View file

@ -31,6 +31,13 @@ class LayoutProperty(BaseAttribute):
# there isn't really a way to validate these
return None
@validate("name")
def unique_in_parent(self):
self.validate_unique_in_parent(
f"Duplicate layout property '{self.name}'",
check=lambda child: child.name == self.name,
)
layout_prop = Group(
LayoutProperty,
@ -53,6 +60,9 @@ class Layout(AstNode):
def container_is_widget(self):
validate_parent_type(self, "Gtk", "Widget", "layout properties")
@validate("layout")
def unique_in_parent(self):
self.validate_unique_in_parent("Duplicate layout block")
def emit_xml(self, xml: XmlEmitter):
xml.start_tag("layout")