mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Don't suggest "null" where not allowed
This commit is contained in:
parent
67983aee2e
commit
72319b29c6
1 changed files with 9 additions and 5 deletions
|
@ -32,6 +32,7 @@ from .completions_utils import (
|
||||||
get_sort_key,
|
get_sort_key,
|
||||||
new_statement_patterns,
|
new_statement_patterns,
|
||||||
)
|
)
|
||||||
|
from .language.contexts import ValueTypeCtx
|
||||||
from .language.types import ClassName
|
from .language.types import ClassName
|
||||||
from .lsp_utils import Completion, CompletionItemKind, TextEdit, get_docs_section
|
from .lsp_utils import Completion, CompletionItemKind, TextEdit, get_docs_section
|
||||||
from .parser import SKIP_TOKENS
|
from .parser import SKIP_TOKENS
|
||||||
|
@ -320,6 +321,8 @@ def prop_value_completer(ctx: CompletionContext):
|
||||||
)
|
)
|
||||||
|
|
||||||
if (vt := ctx.ast_node.value_type) is not None:
|
if (vt := ctx.ast_node.value_type) is not None:
|
||||||
|
assert isinstance(vt, ValueTypeCtx)
|
||||||
|
|
||||||
if isinstance(vt.value_type, gir.Enumeration):
|
if isinstance(vt.value_type, gir.Enumeration):
|
||||||
for name, member in vt.value_type.members.items():
|
for name, member in vt.value_type.members.items():
|
||||||
yield Completion(
|
yield Completion(
|
||||||
|
@ -345,11 +348,12 @@ def prop_value_completer(ctx: CompletionContext):
|
||||||
elif isinstance(vt.value_type, gir.Class) or isinstance(
|
elif isinstance(vt.value_type, gir.Class) or isinstance(
|
||||||
vt.value_type, gir.Interface
|
vt.value_type, gir.Interface
|
||||||
):
|
):
|
||||||
yield Completion(
|
if vt.allow_null:
|
||||||
"null",
|
yield Completion(
|
||||||
CompletionItemKind.Constant,
|
"null",
|
||||||
sort_text=get_sort_key(CompletionPriority.KEYWORD, "null"),
|
CompletionItemKind.Constant,
|
||||||
)
|
sort_text=get_sort_key(CompletionPriority.KEYWORD, "null"),
|
||||||
|
)
|
||||||
|
|
||||||
yield from get_object_id_completions(ctx, vt.value_type)
|
yield from get_object_id_completions(ctx, vt.value_type)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue