mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Add warning for confusing object IDs
This commit is contained in:
parent
77dc9350e9
commit
43fbf8cf8e
2 changed files with 14 additions and 0 deletions
|
@ -26,6 +26,9 @@ from .response_id import ExtResponse
|
|||
from .types import ClassName, ConcreteClassName
|
||||
|
||||
|
||||
RESERVED_IDS = {"this", "self", "template", "true", "false", "null", "none"}
|
||||
|
||||
|
||||
class ObjectContent(AstNode):
|
||||
grammar = ["{", Until(OBJECT_CONTENT_HOOKS, "}")]
|
||||
|
||||
|
@ -73,6 +76,11 @@ class Object(AstNode):
|
|||
if child.response_id
|
||||
]
|
||||
|
||||
@validate("id")
|
||||
def object_id_not_reserved(self):
|
||||
if self.id in RESERVED_IDS:
|
||||
raise CompileWarning(f"{self.id} may be a confusing object ID")
|
||||
|
||||
|
||||
def validate_parent_type(node, ns: str, name: str, err_msg: str):
|
||||
parent = node.root.gir.get_type(name, ns)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue