Improved validation

This commit is contained in:
James Westman 2021-11-12 18:01:56 -06:00
parent 981c2e3b7d
commit f1e1811e1f
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
13 changed files with 51 additions and 13 deletions

View file

@ -72,6 +72,12 @@ class AstNode:
else:
return self.parent.parent_by_type(type)
def validate_parent_type(self, ns: str, name: str, err_msg: str):
parent = self.root.gir.get_type(name, ns)
container_type = self.parent_by_type(ast.Object).gir_class
if container_type and not container_type.assignable_to(parent):
raise CompileError(f"{container_type.full_name} is not a {parent.full_name}, so it doesn't have {err_msg}")
@lazy_prop
def errors(self):
return list(self._get_errors())