mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Use the new duplicate validator for templates
This commit is contained in:
parent
22edcf0c67
commit
d319cb11c1
2 changed files with 4 additions and 10 deletions
|
@ -37,6 +37,10 @@ class Template(Object):
|
|||
def not_abstract(self):
|
||||
pass # does not apply to templates
|
||||
|
||||
@validate("name")
|
||||
def unique_in_parent(self):
|
||||
self.validate_unique_in_parent(f"Only one template may be defined per file, but this file contains {len(self.parent.children[Template])}",)
|
||||
|
||||
def emit_xml(self, xml: XmlEmitter):
|
||||
xml.start_tag(
|
||||
"template",
|
||||
|
|
|
@ -71,16 +71,6 @@ class UI(AstNode):
|
|||
raise MultipleErrors(self._gir_errors)
|
||||
|
||||
|
||||
@validate()
|
||||
def at_most_one_template(self):
|
||||
if len(self.children[Template]) > 1:
|
||||
for template in self.children[Template][1:]:
|
||||
raise CompileError(
|
||||
f"Only one template may be defined per file, but this file contains {len(self.children[Template])}",
|
||||
template.group.tokens["name"].start, template.group.tokens["name"].end,
|
||||
)
|
||||
|
||||
|
||||
@validate()
|
||||
def unique_ids(self):
|
||||
passed = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue