hcl-lang
hcl-lang copied to clipboard
Provide completion in "invalid" `ConditionalExpr`
Background
While implementing support for ConditionalExpr in https://github.com/hashicorp/hcl-lang/pull/326 a few edge cases surfaced around completion:
- incomplete
ConditionalExprattr = /*HERE*/ ? var.foo : var.barattr = var.foo ? /*HERE*/ : var.barattr = var.foo ? var.bar : /*HERE*/attr = var.foo ? /*HERE*/
- "impeding" incomplete
Traversal(with trailing dot) inside otherwise completeConditionalExprattr = var. ? var.foo : var.barattr = var.foo ? var. : var.barattr = var.foo ? var.bar : var.
In all of the above cases we're unable to provide any completion primarily because the upstream HCL parser is thrown off by the invalid stuff so much that it does not return the attribute at all, let alone partial expression.
Proposal
Investigate either changes upstream in HCL or some form of recovery downstream here in hcl-lang that would enable completion in the above contexts.
Upstream Issue
https://github.com/hashicorp/hcl/issues/643