mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lsp: Fix completions when editing existing item
Many completion snippets insert more than just the name. For example, the object completer inserts the braces and places your cursor inside them automatically, to save some typing. However, if you're changing the class of an existing object, this isn't what you want. Changed so that if the next token is '{', only the name is inserted. Made similar changes to the property and signal completers.
This commit is contained in:
parent
29e4a56bfc
commit
461fe25316
13 changed files with 122 additions and 97 deletions
|
@ -143,7 +143,7 @@ class ExtAdwResponseDialog(AstNode):
|
|||
applies_in_subclass=("Adw", "MessageDialog"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def complete_adw_message_dialog(lsp, ast_node, match_variables):
|
||||
def complete_adw_message_dialog(_ctx: CompletionContext):
|
||||
yield Completion(
|
||||
"responses", CompletionItemKind.Keyword, snippet="responses [\n\t$0\n]"
|
||||
)
|
||||
|
@ -154,7 +154,7 @@ def complete_adw_message_dialog(lsp, ast_node, match_variables):
|
|||
applies_in_subclass=("Adw", "AlertDialog"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def complete_adw_alert_dialog(lsp, ast_node, match_variables):
|
||||
def complete_adw_alert_dialog(_ctx: CompletionContext):
|
||||
yield Completion(
|
||||
"responses", CompletionItemKind.Keyword, snippet="responses [\n\t$0\n]"
|
||||
)
|
||||
|
|
|
@ -232,7 +232,7 @@ class ExtAccessibility(AstNode):
|
|||
applies_in=[ObjectContent],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def a11y_completer(lsp, ast_node, match_variables):
|
||||
def a11y_completer(_ctx: CompletionContext):
|
||||
yield Completion(
|
||||
"accessibility", CompletionItemKind.Snippet, snippet="accessibility {\n $0\n}"
|
||||
)
|
||||
|
@ -242,12 +242,12 @@ def a11y_completer(lsp, ast_node, match_variables):
|
|||
applies_in=[ExtAccessibility],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def a11y_name_completer(lsp, ast_node, match_variables):
|
||||
for name, type in get_types(ast_node.root.gir).items():
|
||||
def a11y_name_completer(ctx: CompletionContext):
|
||||
for name, type in get_types(ctx.ast_node.root.gir).items():
|
||||
yield Completion(
|
||||
name,
|
||||
CompletionItemKind.Property,
|
||||
docs=_get_docs(ast_node.root.gir, type.name),
|
||||
docs=_get_docs(ctx.ast_node.root.gir, type.name),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class ExtComboBoxItems(AstNode):
|
|||
applies_in_subclass=("Gtk", "ComboBoxText"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def items_completer(lsp, ast_node, match_variables):
|
||||
def items_completer(_ctx: CompletionContext):
|
||||
yield Completion("items", CompletionItemKind.Snippet, snippet="items [$0]")
|
||||
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ ext_file_filter_suffixes = create_node("suffixes", "suffix")
|
|||
applies_in_subclass=("Gtk", "FileFilter"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def file_filter_completer(lsp, ast_node, match_variables):
|
||||
def file_filter_completer(_ctx: CompletionContext):
|
||||
yield Completion(
|
||||
"mime-types", CompletionItemKind.Snippet, snippet='mime-types ["$0"]'
|
||||
)
|
||||
|
|
|
@ -93,7 +93,7 @@ class ExtLayout(AstNode):
|
|||
applies_in_subclass=("Gtk", "Widget"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def layout_completer(lsp, ast_node, match_variables):
|
||||
def layout_completer(_ctx: CompletionContext):
|
||||
yield Completion("layout", CompletionItemKind.Snippet, snippet="layout {\n $0\n}")
|
||||
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ from .ui import UI
|
|||
applies_in=[UI],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def menu_completer(lsp, ast_node, match_variables):
|
||||
def menu_completer(_ctx: CompletionContext):
|
||||
yield Completion("menu", CompletionItemKind.Snippet, snippet="menu {\n $0\n}")
|
||||
|
||||
|
||||
|
@ -251,7 +251,7 @@ def menu_completer(lsp, ast_node, match_variables):
|
|||
applies_in=[Menu],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def menu_content_completer(lsp, ast_node, match_variables):
|
||||
def menu_content_completer(_ctx: CompletionContext):
|
||||
yield Completion(
|
||||
"submenu", CompletionItemKind.Snippet, snippet="submenu {\n $0\n}"
|
||||
)
|
||||
|
|
|
@ -137,14 +137,14 @@ class ExtScaleMarks(AstNode):
|
|||
applies_in_subclass=("Gtk", "Scale"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def complete_marks(lsp, ast_node, match_variables):
|
||||
def complete_marks(_ctx: CompletionContext):
|
||||
yield Completion("marks", CompletionItemKind.Keyword, snippet="marks [\n\t$0\n]")
|
||||
|
||||
|
||||
@completer(
|
||||
applies_in=[ExtScaleMarks],
|
||||
)
|
||||
def complete_mark(lsp, ast_node, match_variables):
|
||||
def complete_mark(_ctx: CompletionContext):
|
||||
yield Completion("mark", CompletionItemKind.Keyword, snippet="mark ($0),")
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class ExtSizeGroupWidgets(AstNode):
|
|||
applies_in_subclass=("Gtk", "SizeGroup"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def size_group_completer(lsp, ast_node, match_variables):
|
||||
def size_group_completer(_ctx: CompletionContext):
|
||||
yield Completion("widgets", CompletionItemKind.Snippet, snippet="widgets [$0]")
|
||||
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class ExtStringListStrings(AstNode):
|
|||
applies_in_subclass=("Gtk", "StringList"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def strings_completer(lsp, ast_node, match_variables):
|
||||
def strings_completer(_ctx: CompletionContext):
|
||||
yield Completion("strings", CompletionItemKind.Snippet, snippet="strings [$0]")
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class ExtStyles(AstNode):
|
|||
applies_in_subclass=("Gtk", "Widget"),
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def style_completer(lsp, ast_node, match_variables):
|
||||
def style_completer(_ctx: CompletionContext):
|
||||
yield Completion("styles", CompletionItemKind.Keyword, snippet='styles ["$0"]')
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue