From 684ed7dc02bd121dcacb00c261e3dc4402bbf882 Mon Sep 17 00:00:00 2001 From: James Westman Date: Sat, 3 May 2025 19:51:00 -0500 Subject: [PATCH] Fix crash on incomplete Adw.AlertDialog response --- blueprintcompiler/language/adw_response_dialog.py | 7 +++++-- blueprintcompiler/outputs/xml/__init__.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/blueprintcompiler/language/adw_response_dialog.py b/blueprintcompiler/language/adw_response_dialog.py index b1b43a4..7c307db 100644 --- a/blueprintcompiler/language/adw_response_dialog.py +++ b/blueprintcompiler/language/adw_response_dialog.py @@ -80,11 +80,14 @@ class ExtAdwResponseDialogResponse(AstNode): return not any(flag.flag == "disabled" for flag in self.flags) @property - def value(self) -> StringValue: + def value(self) -> T.Optional[StringValue]: return self.children[0] @property - def document_symbol(self) -> DocumentSymbol: + def document_symbol(self) -> T.Optional[DocumentSymbol]: + if self.value is None: + return None + return DocumentSymbol( self.id, SymbolKind.Field, diff --git a/blueprintcompiler/outputs/xml/__init__.py b/blueprintcompiler/outputs/xml/__init__.py index c8820aa..ee99777 100644 --- a/blueprintcompiler/outputs/xml/__init__.py +++ b/blueprintcompiler/outputs/xml/__init__.py @@ -364,6 +364,7 @@ class XmlOutput(OutputFormat): elif isinstance(extension, ExtAdwResponseDialog): xml.start_tag("responses") for response in extension.responses: + assert response.value is not None xml.start_tag( "response", id=response.id,