mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-03 15:49:07 -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
9
CONTRIBUTING.md
Normal file
9
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
First of all, thank you for contributing to Blueprint.
|
||||
|
||||
If you learn something useful, please add it to this file.
|
||||
|
||||
# Run the test suite
|
||||
|
||||
```
|
||||
python -m unittest
|
||||
```
|
|
@ -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?",
|
||||
|
|
1
tests/sample_errors/no_import_version.blp
Normal file
1
tests/sample_errors/no_import_version.blp
Normal file
|
@ -0,0 +1 @@
|
|||
using Gtk
|
1
tests/sample_errors/no_import_version.err
Normal file
1
tests/sample_errors/no_import_version.err
Normal file
|
@ -0,0 +1 @@
|
|||
1,10,0,Expected a version number for GTK
|
|
@ -188,6 +188,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample_error("gtk_exact_version")
|
||||
self.assert_sample_error("invalid_bool")
|
||||
self.assert_sample_error("layout_in_non_widget")
|
||||
self.assert_sample_error("no_import_version")
|
||||
self.assert_sample_error("ns_not_imported")
|
||||
self.assert_sample_error("not_a_class")
|
||||
self.assert_sample_error("object_dne")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue