feat: param_value context — enum/allowed completions for principalType, environmentType etc.
All checks were successful
Build and Deploy iLSP / test (push) Successful in 20s
Build and Deploy iLSP / build-and-deploy (push) Successful in 1m20s

- Add _KNOWN_ENUMS dict (principalType, principalObjectType, environmentType fallbacks)
- Add param_value_completion_items() to BicepModuleCatalog
- Detect 'param_value' context in _detect_context() (cursor after 'param: ' inside params block)
- Wire param_value into _inject_completions()
- 9 new unit tests (context detection, catalog allowed, known enum fallback, injection)
- Fix modules.py edit regression (param_completion_items was orphaned)
- All 35 tests pass
This commit is contained in:
Henrik Jess Nielsen
2026-05-10 15:30:31 +02:00
parent bf24b5677f
commit b93aa84737
4 changed files with 507 additions and 3 deletions

View File

@@ -127,10 +127,25 @@ class _ProxySession:
if params_m:
text_in_params = text_after_mod[params_m.start():]
if text_in_params.count("{") > text_in_params.count("}"):
mod_name = last_mod.group(1)
mod_ver = last_mod.group(2)
# Check if cursor is after 'paramname: ' on the current line
# (value context — inject enum/allowed values)
value_m = re.search(r"^\s*(\w+):\s*('?)([^'{}]*)$", current)
if value_m and value_m.group(1) not in {"params", "name", "module", "resource"}:
return {
"type": "param_value",
"module": mod_name,
"version": mod_ver,
"param": value_m.group(1),
"has_open_quote": bool(value_m.group(2)),
}
return {
"type": "param",
"module": last_mod.group(1),
"version": last_mod.group(2),
"module": mod_name,
"version": mod_ver,
}
return {"type": "unknown"}
@@ -175,6 +190,13 @@ def _inject_completions(msg: dict[str, Any], context: dict | None = None) -> byt
lru_items = BicepModuleCatalog.param_completion_items(
context["module"], context["version"]
)
elif ctx_type == "param_value":
lru_items = BicepModuleCatalog.param_value_completion_items(
context["module"],
context["version"],
context["param"],
context.get("has_open_quote", False),
)
else:
# Default: module name completions
lru_items = BicepModuleCatalog.as_completion_items()