Change template syntax

Templates now use a TypeName instead of an identifier, which makes it
clearer that it's an extern symbol (or that it's a Gtk.ListItem).
This commit is contained in:
James Westman 2023-05-09 19:42:33 -05:00
parent aebf8be278
commit 04509e4b2e
31 changed files with 175 additions and 55 deletions

View file

@ -260,6 +260,8 @@ class IdentLiteral(AstNode):
return gir.BoolType()
elif object := self.context[ScopeCtx].objects.get(self.ident):
return object.gir_class
elif self.root.is_legacy_template(self.ident):
return self.root.template.class_name.gir_type
else:
return None
@ -277,6 +279,12 @@ class IdentLiteral(AstNode):
did_you_mean=(self.ident, list(expected_type.members.keys())),
)
elif self.root.is_legacy_template(self.ident):
raise UpgradeWarning(
"Use 'template' instead of the class name (introduced in 0.8.0)",
actions=[CodeAction("Use 'template'", "template")],
)
elif expected_type is not None:
object = self.context[ScopeCtx].objects.get(self.ident)
if object is None: