mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lsp: Fix crash when import version missing
The issue is specific to the language server, since it's trying to use an AST that contains errors. The test would not fail but was added anyway.
This commit is contained in:
parent
b9fdc5a5f1
commit
2da6be7618
5 changed files with 16 additions and 3 deletions
|
@ -31,16 +31,17 @@ class GtkDirective(AstNode):
|
|||
|
||||
@validate("version")
|
||||
def gtk_version(self):
|
||||
if self.tokens["version"] not in ["4.0"]:
|
||||
version = self.tokens["version"]
|
||||
if version not in ["4.0"]:
|
||||
err = CompileError("Only GTK 4 is supported")
|
||||
if self.tokens["version"].startswith("4"):
|
||||
if version and version.startswith("4"):
|
||||
err.hint("Expected the GIR version, not an exact version number. Use 'using Gtk 4.0;'.")
|
||||
else:
|
||||
err.hint("Expected 'using Gtk 4.0;'")
|
||||
raise err
|
||||
|
||||
try:
|
||||
gir.get_namespace("Gtk", self.tokens["version"])
|
||||
gir.get_namespace("Gtk", version)
|
||||
except CompileError as e:
|
||||
raise CompileError(
|
||||
"Could not find GTK 4 introspection files. Is gobject-introspection installed?",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue