Fix template types

This commit is contained in:
James Westman 2023-03-28 10:41:42 -05:00
parent 64879491a1
commit 88f5b4f1c7
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
14 changed files with 120 additions and 21 deletions

View file

@ -37,7 +37,7 @@ from ..gir import (
FloatType,
GirType,
Enumeration,
UncheckedType,
ExternType,
)
from ..lsp_utils import Completion, CompletionItemKind, SemanticToken, SemanticTokenType
from ..parse_tree import *

View file

@ -141,7 +141,7 @@ class LookupOp(InfixExpr):
],
)
if isinstance(self.lhs.type, UncheckedType) or not self.lhs.type_complete:
if self.lhs.type.incomplete:
return
elif not isinstance(self.lhs.type, gir.Class) and not isinstance(

View file

@ -46,7 +46,7 @@ class Property(AstNode):
@property
def gir_property(self):
if self.gir_class is not None and not isinstance(self.gir_class, UncheckedType):
if self.gir_class is not None and not isinstance(self.gir_class, ExternType):
return self.gir_class.properties.get(self.tokens["name"])
@context(ValueTypeCtx)
@ -75,7 +75,7 @@ class Property(AstNode):
@validate("name")
def property_exists(self):
if self.gir_class is None or isinstance(self.gir_class, UncheckedType):
if self.gir_class is None or self.gir_class.incomplete:
# Objects that we have no gir data on should not be validated
# This happens for classes defined by the app itself
return

View file

@ -72,7 +72,7 @@ class Signal(AstNode):
@property
def gir_signal(self):
if self.gir_class is not None and not isinstance(self.gir_class, UncheckedType):
if self.gir_class is not None and not isinstance(self.gir_class, ExternType):
return self.gir_class.signals.get(self.tokens["name"])
@property
@ -90,7 +90,7 @@ class Signal(AstNode):
@validate("name")
def signal_exists(self):
if self.gir_class is None or isinstance(self.gir_class, UncheckedType):
if self.gir_class is None or self.gir_class.incomplete:
# Objects that we have no gir data on should not be validated
# This happens for classes defined by the app itself
return

View file

@ -50,11 +50,10 @@ class Template(Object):
@property
def gir_class(self):
# Templates might not have a parent class defined
if class_name := self.class_name:
return class_name.gir_type
if self.class_name is None:
return gir.TemplateType(self.id, None)
else:
return gir.UncheckedType(self.id)
return gir.TemplateType(self.id, self.class_name.gir_type)
@validate("id")
def unique_in_parent(self):

View file

@ -108,11 +108,7 @@ class PropertyBinding(AstNode):
gir_class = self.source_obj.gir_class
if (
isinstance(self.source_obj, Template)
or gir_class is None
or isinstance(gir_class, UncheckedType)
):
if gir_class is None or gir_class.incomplete:
# Objects that we have no gir data on should not be validated
# This happens for classes defined by the app itself
return

View file

@ -20,7 +20,7 @@
import typing as T
from .common import *
from ..gir import Class, Interface
from ..gir import Class, ExternType, Interface
class TypeName(AstNode):
@ -70,7 +70,7 @@ class TypeName(AstNode):
self.tokens["class_name"], self.tokens["namespace"]
)
return gir.UncheckedType(self.tokens["class_name"])
return gir.ExternType(self.tokens["class_name"])
@property
def glib_type_name(self) -> str:
@ -95,7 +95,7 @@ class ClassName(TypeName):
def gir_class_exists(self):
if (
self.gir_type is not None
and not isinstance(self.gir_type, UncheckedType)
and not isinstance(self.gir_type, ExternType)
and not isinstance(self.gir_type, Class)
):
if isinstance(self.gir_type, Interface):