mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Merge branch blueprint-compiler:main into main
This commit is contained in:
commit
c1fbcef6d0
94 changed files with 850 additions and 232 deletions
4
tests/formatting/comment_in.blp
Normal file
4
tests/formatting/comment_in.blp
Normal file
|
@ -0,0 +1,4 @@
|
|||
using Gtk 4.0;
|
||||
//comment
|
||||
// Trailing whitespace:
|
||||
//
|
4
tests/formatting/comment_out.blp
Normal file
4
tests/formatting/comment_out.blp
Normal file
|
@ -0,0 +1,4 @@
|
|||
using Gtk 4.0;
|
||||
// comment
|
||||
// Trailing whitespace:
|
||||
//
|
21
tests/formatting/lists_in.blp
Normal file
21
tests/formatting/lists_in.blp
Normal file
|
@ -0,0 +1,21 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Box {
|
||||
styles []
|
||||
}
|
||||
|
||||
Box {
|
||||
styles ["a"]
|
||||
}
|
||||
|
||||
Box {
|
||||
styles ["a",]
|
||||
}
|
||||
|
||||
Box {
|
||||
styles ["a", "b"]
|
||||
}
|
||||
|
||||
Box {
|
||||
styles ["a", "b",]
|
||||
}
|
31
tests/formatting/lists_out.blp
Normal file
31
tests/formatting/lists_out.blp
Normal file
|
@ -0,0 +1,31 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Box {
|
||||
styles []
|
||||
}
|
||||
|
||||
Box {
|
||||
styles [
|
||||
"a",
|
||||
]
|
||||
}
|
||||
|
||||
Box {
|
||||
styles [
|
||||
"a",
|
||||
]
|
||||
}
|
||||
|
||||
Box {
|
||||
styles [
|
||||
"a",
|
||||
"b",
|
||||
]
|
||||
}
|
||||
|
||||
Box {
|
||||
styles [
|
||||
"a",
|
||||
"b",
|
||||
]
|
||||
}
|
|
@ -11,7 +11,7 @@ Overlay {
|
|||
notify::icon-name => $on_icon_name_changed(label) swapped;
|
||||
|
||||
styles [
|
||||
"destructive"
|
||||
"destructive",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
5
tests/sample_errors/expr_item_not_cast.blp
Normal file
5
tests/sample_errors/expr_item_not_cast.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr item.visible;
|
||||
}
|
1
tests/sample_errors/expr_item_not_cast.err
Normal file
1
tests/sample_errors/expr_item_not_cast.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,20,4,"item" must be cast to its object type
|
5
tests/sample_errors/expr_value_assignment.blp
Normal file
5
tests/sample_errors/expr_value_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: expr 1;
|
||||
}
|
1
tests/sample_errors/expr_value_assignment.err
Normal file
1
tests/sample_errors/expr_value_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,4,Cannot convert Gtk.Expression to string
|
5
tests/sample_errors/expr_value_closure_arg.blp
Normal file
5
tests/sample_errors/expr_value_closure_arg.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr $closure(item as <Entry>) as <bool>;
|
||||
}
|
1
tests/sample_errors/expr_value_closure_arg.err
Normal file
1
tests/sample_errors/expr_value_closure_arg.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,29,4,"item" can only be used for looking up properties
|
5
tests/sample_errors/expr_value_item.blp
Normal file
5
tests/sample_errors/expr_value_item.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr item as <Label>;
|
||||
}
|
1
tests/sample_errors/expr_value_item.err
Normal file
1
tests/sample_errors/expr_value_item.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,20,4,"item" can only be used for looking up properties
|
5
tests/sample_errors/float_to_int_assignment.blp
Normal file
5
tests/sample_errors/float_to_int_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Entry {
|
||||
margin-bottom: 10.5;
|
||||
}
|
1
tests/sample_errors/float_to_int_assignment.err
Normal file
1
tests/sample_errors/float_to_int_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,18,4,Cannot convert 10.5 to integer
|
5
tests/sample_errors/incomplete_signal.blp
Normal file
5
tests/sample_errors/incomplete_signal.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
notify::
|
||||
}
|
2
tests/sample_errors/incomplete_signal.err
Normal file
2
tests/sample_errors/incomplete_signal.err
Normal file
|
@ -0,0 +1,2 @@
|
|||
5,1,0,Expected a signal detail name
|
||||
4,9,3,Unexpected tokens
|
3
tests/sample_errors/int_object.blp
Normal file
3
tests/sample_errors/int_object.blp
Normal file
|
@ -0,0 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
int {}
|
1
tests/sample_errors/int_object.err
Normal file
1
tests/sample_errors/int_object.err
Normal file
|
@ -0,0 +1 @@
|
|||
3,1,3,int is not a class
|
7
tests/sample_errors/menu_assignment.blp
Normal file
7
tests/sample_errors/menu_assignment.blp
Normal file
|
@ -0,0 +1,7 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Overlay {
|
||||
child: my_menu;
|
||||
}
|
||||
|
||||
menu my_menu {}
|
1
tests/sample_errors/menu_assignment.err
Normal file
1
tests/sample_errors/menu_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,7,Cannot assign Gio.Menu to Gtk.Widget
|
5
tests/sample_errors/signal_exclusive_flags.blp
Normal file
5
tests/sample_errors/signal_exclusive_flags.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
$MyObject obj {
|
||||
signal1 => $handler() swapped not-swapped;
|
||||
}
|
1
tests/sample_errors/signal_exclusive_flags.err
Normal file
1
tests/sample_errors/signal_exclusive_flags.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,33,11,'swapped' and 'not-swapped' flags cannot be used together
|
6
tests/sample_errors/signal_unnecessary_flags.blp
Normal file
6
tests/sample_errors/signal_unnecessary_flags.blp
Normal file
|
@ -0,0 +1,6 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
$MyObject obj {
|
||||
signal1 => $handler() not-swapped;
|
||||
signal2 => $handler(obj) swapped;
|
||||
}
|
2
tests/sample_errors/signal_unnecessary_flags.err
Normal file
2
tests/sample_errors/signal_unnecessary_flags.err
Normal file
|
@ -0,0 +1,2 @@
|
|||
4,25,11,'not-swapped' is the default for handlers that do not specify an object
|
||||
5,28,7,'swapped' is the default for handlers that specify an object
|
5
tests/sample_errors/single_quoted_translated.blp
Normal file
5
tests/sample_errors/single_quoted_translated.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: _('Hello, World!');
|
||||
}
|
1
tests/sample_errors/single_quoted_translated.err
Normal file
1
tests/sample_errors/single_quoted_translated.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,12,15,gettext may not recognize single-quoted strings
|
5
tests/sample_errors/string_to_num_assignment.blp
Normal file
5
tests/sample_errors/string_to_num_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Entry {
|
||||
margin-bottom: "10";
|
||||
}
|
1
tests/sample_errors/string_to_num_assignment.err
Normal file
1
tests/sample_errors/string_to_num_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,18,4,Cannot convert string to number
|
5
tests/sample_errors/string_to_object_assignment.blp
Normal file
5
tests/sample_errors/string_to_object_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
child: "Click me";
|
||||
}
|
1
tests/sample_errors/string_to_object_assignment.err
Normal file
1
tests/sample_errors/string_to_object_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,10,Cannot convert string to Gtk.Widget
|
6
tests/sample_errors/string_to_type_assignment.blp
Normal file
6
tests/sample_errors/string_to_type_assignment.blp
Normal file
|
@ -0,0 +1,6 @@
|
|||
using Gtk 4.0;
|
||||
using Gio 2.0;
|
||||
|
||||
Gio.ListStore {
|
||||
item-type: "Button";
|
||||
}
|
1
tests/sample_errors/string_to_type_assignment.err
Normal file
1
tests/sample_errors/string_to_type_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
5,14,8,Cannot convert string to GType
|
5
tests/sample_errors/translated_assignment.blp
Normal file
5
tests/sample_errors/translated_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
child: _("Click me");
|
||||
}
|
1
tests/sample_errors/translated_assignment.err
Normal file
1
tests/sample_errors/translated_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,13,Cannot convert translated string to Gtk.Widget
|
7
tests/sample_errors/translated_string_array.blp
Normal file
7
tests/sample_errors/translated_string_array.blp
Normal file
|
@ -0,0 +1,7 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
StringList {
|
||||
strings: [
|
||||
_("Test")
|
||||
];
|
||||
}
|
1
tests/sample_errors/translated_string_array.err
Normal file
1
tests/sample_errors/translated_string_array.err
Normal file
|
@ -0,0 +1 @@
|
|||
5,5,9,Arrays can't contain translated strings
|
5
tests/sample_errors/typeof_assignment.blp
Normal file
5
tests/sample_errors/typeof_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
label: typeof<Button>;
|
||||
}
|
1
tests/sample_errors/typeof_assignment.err
Normal file
1
tests/sample_errors/typeof_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,14,Cannot convert GType to string
|
1
tests/sample_errors/unrecognized_syntax.blp
Normal file
1
tests/sample_errors/unrecognized_syntax.blp
Normal file
|
@ -0,0 +1 @@
|
|||
~
|
1
tests/sample_errors/unrecognized_syntax.err
Normal file
1
tests/sample_errors/unrecognized_syntax.err
Normal file
|
@ -0,0 +1 @@
|
|||
1,1,0,Could not determine what kind of syntax is meant here
|
5
tests/sample_errors/upgrade_sync_create.blp
Normal file
5
tests/sample_errors/upgrade_sync_create.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button btn {
|
||||
label: bind btn.label sync-create;
|
||||
}
|
1
tests/sample_errors/upgrade_sync_create.err
Normal file
1
tests/sample_errors/upgrade_sync_create.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,25,11,'sync-create' is now the default. Use 'no-sync-create' if this is not wanted.
|
5
tests/sample_errors/upgrade_template_list_item.blp
Normal file
5
tests/sample_errors/upgrade_template_list_item.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BuilderListItemFactory {
|
||||
template {}
|
||||
}
|
1
tests/sample_errors/upgrade_template_list_item.err
Normal file
1
tests/sample_errors/upgrade_template_list_item.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,3,8,Expected type name after 'template' keyword
|
9
tests/samples/bind_expr_prop.blp
Normal file
9
tests/samples/bind_expr_prop.blp
Normal file
|
@ -0,0 +1,9 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter filter1 {
|
||||
expression: expr true;
|
||||
}
|
||||
|
||||
BoolFilter filter2 {
|
||||
expression: bind filter1.expression;
|
||||
}
|
17
tests/samples/bind_expr_prop.ui
Normal file
17
tests/samples/bind_expr_prop.ui
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkBoolFilter" id="filter1">
|
||||
<property name="expression">
|
||||
<constant type="gboolean">true</constant>
|
||||
</property>
|
||||
</object>
|
||||
<object class="GtkBoolFilter" id="filter2">
|
||||
<property name="expression" bind-source="filter1" bind-property="expression" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/bind_literal.blp
Normal file
5
tests/samples/bind_literal.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: bind "Hello, world!";
|
||||
}
|
14
tests/samples/bind_literal.ui
Normal file
14
tests/samples/bind_literal.ui
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkLabel">
|
||||
<binding name="label">
|
||||
<constant type="gchararray">Hello, world!</constant>
|
||||
</binding>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/expr_value.blp
Normal file
5
tests/samples/expr_value.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr item as <Entry>.visible;
|
||||
}
|
14
tests/samples/expr_value.ui
Normal file
14
tests/samples/expr_value.ui
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkBoolFilter">
|
||||
<property name="expression">
|
||||
<lookup name="visible" type="GtkEntry"></lookup>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/expr_value_closure.blp
Normal file
5
tests/samples/expr_value_closure.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr $closure(item as <Entry>.visible) as <bool>;
|
||||
}
|
16
tests/samples/expr_value_closure.ui
Normal file
16
tests/samples/expr_value_closure.ui
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkBoolFilter">
|
||||
<property name="expression">
|
||||
<closure function="closure" type="gboolean">
|
||||
<lookup name="visible" type="GtkEntry"></lookup>
|
||||
</closure>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/expr_value_literal.blp
Normal file
5
tests/samples/expr_value_literal.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr true;
|
||||
}
|
14
tests/samples/expr_value_literal.ui
Normal file
14
tests/samples/expr_value_literal.ui
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkBoolFilter">
|
||||
<property name="expression">
|
||||
<constant type="gboolean">true</constant>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
|
@ -4,6 +4,7 @@ Box {
|
|||
visible: bind box2.visible inverted;
|
||||
orientation: bind box2.orientation;
|
||||
spacing: bind box2.spacing no-sync-create;
|
||||
tooltip-text: bind box2.tooltip-text bidirectional;
|
||||
}
|
||||
|
||||
Box box2 {
|
||||
|
|
|
@ -10,6 +10,7 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
|
|||
<property name="visible" bind-source="box2" bind-property="visible" bind-flags="sync-create|invert-boolean"/>
|
||||
<property name="orientation" bind-source="box2" bind-property="orientation" bind-flags="sync-create"/>
|
||||
<property name="spacing" bind-source="box2" bind-property="spacing"/>
|
||||
<property name="tooltip-text" bind-source="box2" bind-property="tooltip-text" bind-flags="sync-create|bidirectional"/>
|
||||
</object>
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="spacing">6</property>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Box {
|
||||
visible: bind box2.visible inverted;
|
||||
orientation: bind box2.orientation;
|
||||
spacing: bind box2.spacing no-sync-create;
|
||||
}
|
||||
|
||||
Box box2 {
|
||||
spacing: 6;
|
||||
}
|
5
tests/samples/signal_not_swapped.blp
Normal file
5
tests/samples/signal_not_swapped.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button obj {
|
||||
clicked => $handler(obj) not-swapped;
|
||||
}
|
12
tests/samples/signal_not_swapped.ui
Normal file
12
tests/samples/signal_not_swapped.ui
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkButton" id="obj">
|
||||
<signal name="clicked" handler="handler" swapped="False" object="obj"/>
|
||||
</object>
|
||||
</interface>
|
|
@ -5,6 +5,6 @@ AboutDialog about {
|
|||
|
||||
authors: [
|
||||
"Jane doe <jane-doe@email.com>",
|
||||
"Jhonny D <jd@email.com>"
|
||||
"Jhonny D <jd@email.com>",
|
||||
];
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@ using Gtk 4.0;
|
|||
Label {
|
||||
styles [
|
||||
"class-1",
|
||||
"class-2"
|
||||
"class-2",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -46,3 +46,5 @@ class TestFormatter(unittest.TestCase):
|
|||
self.assert_format_test("in2.blp", "out.blp")
|
||||
self.assert_format_test("correct1.blp", "correct1.blp")
|
||||
self.assert_format_test("string_in.blp", "string_out.blp")
|
||||
self.assert_format_test("comment_in.blp", "comment_out.blp")
|
||||
self.assert_format_test("lists_in.blp", "lists_out.blp")
|
||||
|
|
|
@ -28,6 +28,7 @@ gi.require_version("Gtk", "4.0")
|
|||
from gi.repository import Gtk
|
||||
|
||||
from blueprintcompiler import decompiler, parser, tokenizer, utils
|
||||
from blueprintcompiler.ast_utils import AstNode
|
||||
from blueprintcompiler.completions import complete
|
||||
from blueprintcompiler.errors import (
|
||||
CompileError,
|
||||
|
@ -61,11 +62,14 @@ class TestSamples(unittest.TestCase):
|
|||
except:
|
||||
pass
|
||||
|
||||
def assert_ast_doesnt_crash(self, text, tokens, ast):
|
||||
def assert_ast_doesnt_crash(self, text, tokens, ast: AstNode):
|
||||
lsp = LanguageServer()
|
||||
for i in range(len(text)):
|
||||
ast.get_docs(i)
|
||||
for i in range(len(text)):
|
||||
list(complete(LanguageServer(), ast, tokens, i))
|
||||
list(complete(lsp, ast, tokens, i))
|
||||
for i in range(len(text)):
|
||||
ast.get_reference(i)
|
||||
ast.get_document_symbols()
|
||||
|
||||
def assert_sample(self, name, skip_run=False):
|
||||
|
@ -194,8 +198,10 @@ class TestSamples(unittest.TestCase):
|
|||
"adw_breakpoint_template",
|
||||
"expr_closure",
|
||||
"expr_closure_args",
|
||||
"expr_value_closure",
|
||||
"parseable",
|
||||
"signal",
|
||||
"signal_not_swapped",
|
||||
"template",
|
||||
"template_binding",
|
||||
"template_binding_extern",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue