adw_breakpoint: Fix crash in language server

Fix a crash that happened when an AdwBreakpointSetter rule was
incomplete, such as when you're still typing it. Fixes #189.
This commit is contained in:
James Westman 2025-04-01 19:27:59 -05:00
parent cc09f3d3bb
commit f50b898e4c
2 changed files with 9 additions and 3 deletions

View file

@ -81,8 +81,8 @@ class AdwBreakpointSetter(AstNode):
return self.tokens["property"]
@property
def value(self) -> Value:
return self.children[Value][0]
def value(self) -> T.Optional[Value]:
return self.children[Value][0] if len(self.children[Value]) > 0 else None
@property
def gir_class(self) -> T.Optional[GirType]:
@ -106,7 +106,10 @@ class AdwBreakpointSetter(AstNode):
return None
@property
def document_symbol(self) -> DocumentSymbol:
def document_symbol(self) -> T.Optional[DocumentSymbol]:
if self.value is None:
return None
return DocumentSymbol(
f"{self.object_id}.{self.property_name}",
SymbolKind.Property,

View file

@ -308,6 +308,9 @@ class XmlOutput(OutputFormat):
elif isinstance(extension, AdwBreakpointSetters):
for setter in extension.setters:
if setter.value is None:
continue
attrs = {}
if isinstance(setter.value.child, Translated):