completions: Don't suggest "null" where not allowed

This commit is contained in:
James Westman 2025-05-03 14:44:13 -05:00
parent 67983aee2e
commit 72319b29c6
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6

View file

@ -32,6 +32,7 @@ from .completions_utils import (
get_sort_key,
new_statement_patterns,
)
from .language.contexts import ValueTypeCtx
from .language.types import ClassName
from .lsp_utils import Completion, CompletionItemKind, TextEdit, get_docs_section
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:
assert isinstance(vt, ValueTypeCtx)
if isinstance(vt.value_type, gir.Enumeration):
for name, member in vt.value_type.members.items():
yield Completion(
@ -345,6 +348,7 @@ def prop_value_completer(ctx: CompletionContext):
elif isinstance(vt.value_type, gir.Class) or isinstance(
vt.value_type, gir.Interface
):
if vt.allow_null:
yield Completion(
"null",
CompletionItemKind.Constant,