From c5f2e4ed4b06cdea568cb57f71968b27ada1705a Mon Sep 17 00:00:00 2001 From: James Westman Date: Fri, 24 Jun 2022 17:16:51 -0500 Subject: [PATCH] gir: Gracefully handle missing .gir files They aren't required for compilation anymore, and not being able to show documentation on hover is probably not worth crashing the language server over. --- blueprintcompiler/gir.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blueprintcompiler/gir.py b/blueprintcompiler/gir.py index 1085222..2515ab1 100644 --- a/blueprintcompiler/gir.py +++ b/blueprintcompiler/gir.py @@ -214,9 +214,14 @@ class GirNode: if self.signature: sections.append("```\n" + self.signature + "\n```") - el = self.xml.get_elements("doc") - if len(el) == 1: - sections.append(el[0].cdata.strip()) + try: + el = self.xml.get_elements("doc") + if len(el) == 1: + sections.append(el[0].cdata.strip()) + except: + # Not a huge deal, but if you want docs in the language server you + # should ensure .gir files are installed + pass return "\n\n---\n\n".join(sections)