mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Emit deprecation warnings
This commit is contained in:
parent
8fab7c1706
commit
94db929f74
9 changed files with 102 additions and 2 deletions
|
@ -41,9 +41,11 @@ class Property(AstNode):
|
|||
return self.parent.parent.gir_class
|
||||
|
||||
@property
|
||||
def gir_property(self):
|
||||
def gir_property(self) -> T.Optional[gir.Property]:
|
||||
if self.gir_class is not None and not isinstance(self.gir_class, ExternType):
|
||||
return self.gir_class.properties.get(self.tokens["name"])
|
||||
else:
|
||||
return None
|
||||
|
||||
@validate()
|
||||
def binding_valid(self):
|
||||
|
@ -91,6 +93,17 @@ class Property(AstNode):
|
|||
check=lambda child: child.tokens["name"] == self.tokens["name"],
|
||||
)
|
||||
|
||||
@validate("name")
|
||||
def deprecated(self) -> None:
|
||||
if self.gir_property is not None and self.gir_property.deprecated:
|
||||
hints = []
|
||||
if self.gir_property.deprecated_doc:
|
||||
hints.append(self.gir_property.deprecated_doc)
|
||||
raise CompileWarning(
|
||||
f"{self.gir_property.signature} is deprecated",
|
||||
hints=hints,
|
||||
)
|
||||
|
||||
@docs("name")
|
||||
def property_docs(self):
|
||||
if self.gir_property is not None:
|
||||
|
|
|
@ -95,9 +95,11 @@ class Signal(AstNode):
|
|||
return any(x.flag == "after" for x in self.flags)
|
||||
|
||||
@property
|
||||
def gir_signal(self):
|
||||
def gir_signal(self) -> T.Optional[gir.Signal]:
|
||||
if self.gir_class is not None and not isinstance(self.gir_class, ExternType):
|
||||
return self.gir_class.signals.get(self.tokens["name"])
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def gir_class(self):
|
||||
|
@ -134,6 +136,17 @@ class Signal(AstNode):
|
|||
if self.context[ScopeCtx].objects.get(object_id) is None:
|
||||
raise CompileError(f"Could not find object with ID '{object_id}'")
|
||||
|
||||
@validate("name")
|
||||
def deprecated(self) -> None:
|
||||
if self.gir_signal is not None and self.gir_signal.deprecated:
|
||||
hints = []
|
||||
if self.gir_signal.deprecated_doc:
|
||||
hints.append(self.gir_signal.deprecated_doc)
|
||||
raise CompileWarning(
|
||||
f"{self.gir_signal.signature} is deprecated",
|
||||
hints=hints,
|
||||
)
|
||||
|
||||
@docs("name")
|
||||
def signal_docs(self):
|
||||
if self.gir_signal is not None:
|
||||
|
|
|
@ -57,6 +57,17 @@ class TypeName(AstNode):
|
|||
if not self.tokens["extern"]:
|
||||
self.root.gir.validate_ns(self.tokens["namespace"])
|
||||
|
||||
@validate()
|
||||
def deprecated(self) -> None:
|
||||
if self.gir_type and self.gir_type.deprecated:
|
||||
hints = []
|
||||
if self.gir_type.deprecated_doc:
|
||||
hints.append(self.gir_type.deprecated_doc)
|
||||
raise CompileWarning(
|
||||
f"{self.gir_type.full_name} is deprecated",
|
||||
hints=hints,
|
||||
)
|
||||
|
||||
@property
|
||||
def gir_ns(self):
|
||||
if not self.tokens["extern"]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue