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):
|
def not_abstract(self):
|
||||||
pass # does not apply to templates
|
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):
|
def emit_xml(self, xml: XmlEmitter):
|
||||||
xml.start_tag(
|
xml.start_tag(
|
||||||
"template",
|
"template",
|
||||||
|
|
|
@ -71,16 +71,6 @@ class UI(AstNode):
|
||||||
raise MultipleErrors(self._gir_errors)
|
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()
|
@validate()
|
||||||
def unique_ids(self):
|
def unique_ids(self):
|
||||||
passed = {}
|
passed = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue