mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lsp: Add docs for Adw.Breakpoint
This commit is contained in:
parent
cb1eb9ba44
commit
abc4e5de65
1 changed files with 38 additions and 3 deletions
|
@ -24,12 +24,26 @@ from .values import Value
|
|||
|
||||
|
||||
class AdwBreakpointCondition(AstNode):
|
||||
grammar = ["condition", "(", UseQuoted("condition"), Match(")").expected()]
|
||||
grammar = [
|
||||
UseExact("kw", "condition"),
|
||||
"(",
|
||||
UseQuoted("condition"),
|
||||
Match(")").expected(),
|
||||
]
|
||||
|
||||
@property
|
||||
def condition(self) -> str:
|
||||
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()
|
||||
def unique(self):
|
||||
self.validate_unique_in_parent("Duplicate condition statement")
|
||||
|
@ -68,9 +82,16 @@ class AdwBreakpointSetter(AstNode):
|
|||
return None
|
||||
|
||||
@property
|
||||
def gir_property(self):
|
||||
if self.gir_class is not None and not isinstance(self.gir_class, ExternType):
|
||||
def gir_property(self) -> T.Optional[gir.Property]:
|
||||
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)
|
||||
else:
|
||||
return None
|
||||
|
||||
@context(ValueTypeCtx)
|
||||
def value_type(self) -> ValueTypeCtx:
|
||||
|
@ -81,6 +102,20 @@ class AdwBreakpointSetter(AstNode):
|
|||
|
||||
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")
|
||||
def object_exists(self):
|
||||
if self.object is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue