lsp: Add docs for Adw.Breakpoint

This commit is contained in:
James Westman 2023-07-06 21:29:13 -05:00
parent cb1eb9ba44
commit abc4e5de65

View file

@ -24,12 +24,26 @@ from .values import Value
class AdwBreakpointCondition(AstNode): class AdwBreakpointCondition(AstNode):
grammar = ["condition", "(", UseQuoted("condition"), Match(")").expected()] grammar = [
UseExact("kw", "condition"),
"(",
UseQuoted("condition"),
Match(")").expected(),
]
@property @property
def condition(self) -> str: def condition(self) -> str:
return self.tokens["condition"] return self.tokens["condition"]
@docs("kw")
def keyword_docs(self):
klass = self.root.gir.get_type("Breakpoint", "Adw")
if klass is None:
return None
prop = klass.properties.get("condition")
assert isinstance(prop, gir.Property)
return prop.doc
@validate() @validate()
def unique(self): def unique(self):
self.validate_unique_in_parent("Duplicate condition statement") self.validate_unique_in_parent("Duplicate condition statement")
@ -68,9 +82,16 @@ class AdwBreakpointSetter(AstNode):
return None return None
@property @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): if (
self.gir_class is not None
and not isinstance(self.gir_class, ExternType)
and self.property_name is not None
):
assert isinstance(self.gir_class, gir.Class)
return self.gir_class.properties.get(self.property_name) return self.gir_class.properties.get(self.property_name)
else:
return None
@context(ValueTypeCtx) @context(ValueTypeCtx)
def value_type(self) -> ValueTypeCtx: def value_type(self) -> ValueTypeCtx:
@ -81,6 +102,20 @@ class AdwBreakpointSetter(AstNode):
return ValueTypeCtx(type, allow_null=True) return ValueTypeCtx(type, allow_null=True)
@docs("object")
def object_docs(self):
if self.object is not None:
return f"```\n{self.object.signature}\n```"
else:
return None
@docs("property")
def property_docs(self):
if self.gir_property is not None:
return self.gir_property.doc
else:
return None
@validate("object") @validate("object")
def object_exists(self): def object_exists(self):
if self.object is None: if self.object is None: