mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Add completions for response IDs
This commit is contained in:
parent
866092ccf7
commit
b26433d865
16 changed files with 123 additions and 42 deletions
|
@ -34,9 +34,16 @@ from .gtk_scale import ExtScaleMarks
|
|||
from .gtk_size_group import ExtSizeGroupWidgets
|
||||
from .gtk_string_list import ExtStringListStrings
|
||||
from .gtk_styles import ExtStyles
|
||||
from .gtkbuilder_child import Child, ChildExtension, ChildInternal, ChildType
|
||||
from .gtkbuilder_child import (
|
||||
Child,
|
||||
ChildAnnotation,
|
||||
ChildExtension,
|
||||
ChildInternal,
|
||||
ChildType,
|
||||
)
|
||||
from .gtkbuilder_template import Template
|
||||
from .imports import GtkDirective, Import
|
||||
from .response_id import ExtResponse
|
||||
from .types import ClassName
|
||||
from .ui import UI
|
||||
from .values import (
|
||||
|
|
|
@ -140,7 +140,7 @@ class ExtAdwResponseDialog(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Adw", "MessageDialog"),
|
||||
applies_in_subclass=[("Adw", "AlertDialog"), ("Adw", "MessageDialog")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def complete_adw_message_dialog(_ctx: CompletionContext):
|
||||
|
@ -149,20 +149,6 @@ def complete_adw_message_dialog(_ctx: CompletionContext):
|
|||
)
|
||||
|
||||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Adw", "AlertDialog"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def complete_adw_alert_dialog(_ctx: CompletionContext):
|
||||
yield Completion(
|
||||
"responses",
|
||||
CompletionItemKind.Keyword,
|
||||
snippet="responses [\n\t$0\n]",
|
||||
sort_text=get_sort_key(CompletionPriority.OBJECT_MEMBER, "responses"),
|
||||
)
|
||||
|
||||
|
||||
@decompiler("responses")
|
||||
def decompile_responses(ctx, gir):
|
||||
ctx.print(f"responses [")
|
||||
|
|
|
@ -91,7 +91,7 @@ class ExtComboBoxItems(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "ComboBoxText"),
|
||||
applies_in_subclass=[("Gtk", "ComboBoxText")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def items_completer(_ctx: CompletionContext):
|
||||
|
|
|
@ -98,7 +98,7 @@ ext_file_filter_suffixes = create_node("suffixes", "suffix")
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "FileFilter"),
|
||||
applies_in_subclass=[("Gtk", "FileFilter")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def file_filter_completer(_ctx: CompletionContext):
|
||||
|
|
|
@ -90,7 +90,7 @@ class ExtLayout(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "Widget"),
|
||||
applies_in_subclass=[("Gtk", "Widget")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def layout_completer(_ctx: CompletionContext):
|
||||
|
|
|
@ -134,7 +134,7 @@ class ExtScaleMarks(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "Scale"),
|
||||
applies_in_subclass=[("Gtk", "Scale")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def complete_marks(_ctx: CompletionContext):
|
||||
|
|
|
@ -101,7 +101,7 @@ class ExtSizeGroupWidgets(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "SizeGroup"),
|
||||
applies_in_subclass=[("Gtk", "SizeGroup")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def size_group_completer(_ctx: CompletionContext):
|
||||
|
|
|
@ -72,7 +72,7 @@ class ExtStringListStrings(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "StringList"),
|
||||
applies_in_subclass=[("Gtk", "StringList")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def strings_completer(_ctx: CompletionContext):
|
||||
|
|
|
@ -77,7 +77,7 @@ class ExtStyles(AstNode):
|
|||
|
||||
@completer(
|
||||
applies_in=[ObjectContent],
|
||||
applies_in_subclass=("Gtk", "Widget"),
|
||||
applies_in_subclass=[("Gtk", "Widget")],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def style_completer(_ctx: CompletionContext):
|
||||
|
|
|
@ -31,7 +31,12 @@ ALLOWED_PARENTS: T.List[T.Tuple[str, str]] = [
|
|||
|
||||
|
||||
class ChildInternal(AstNode):
|
||||
grammar = ["internal-child", UseIdent("internal_child")]
|
||||
grammar = [
|
||||
"[",
|
||||
"internal-child",
|
||||
UseIdent("internal_child").expected("internal child name"),
|
||||
Match("]").expected(),
|
||||
]
|
||||
|
||||
@property
|
||||
def internal_child(self) -> str:
|
||||
|
@ -39,7 +44,7 @@ class ChildInternal(AstNode):
|
|||
|
||||
|
||||
class ChildType(AstNode):
|
||||
grammar = UseIdent("child_type").expected("a child type")
|
||||
grammar = ["[", UseIdent("child_type").expected("a child type"), "]"]
|
||||
|
||||
@property
|
||||
def child_type(self) -> str:
|
||||
|
@ -59,7 +64,7 @@ class ChildExtension(AstNode):
|
|||
|
||||
|
||||
class ChildAnnotation(AstNode):
|
||||
grammar = ["[", AnyOf(ChildInternal, ChildExtension, ChildType), "]"]
|
||||
grammar = AnyOf(ChildInternal, ChildExtension, ChildType)
|
||||
|
||||
@property
|
||||
def child(self) -> T.Union[ChildInternal, ChildExtension, ChildType]:
|
||||
|
|
|
@ -28,19 +28,21 @@ class ExtResponse(AstNode):
|
|||
|
||||
ALLOWED_PARENTS: T.List[T.Tuple[str, str]] = [("Gtk", "Dialog"), ("Gtk", "InfoBar")]
|
||||
|
||||
grammar = [
|
||||
grammar = Statement(
|
||||
"[",
|
||||
Keyword("action"),
|
||||
Keyword("response"),
|
||||
"=",
|
||||
Match("=").expected(),
|
||||
AnyOf(
|
||||
UseIdent("response_id"),
|
||||
[
|
||||
Optional(UseExact("sign", "-")),
|
||||
UseNumber("response_id"),
|
||||
],
|
||||
),
|
||||
).expected("response ID"),
|
||||
Optional([Keyword("default"), UseLiteral("is_default", True)]),
|
||||
]
|
||||
end="]",
|
||||
)
|
||||
|
||||
@validate()
|
||||
def parent_has_action_widgets(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue