hcl-lang icon indicating copy to clipboard operation
hcl-lang copied to clipboard

Provide completion in "invalid" `ConditionalExpr`

Open radeksimko opened this issue 1 year ago • 0 comments

Background

While implementing support for ConditionalExpr in https://github.com/hashicorp/hcl-lang/pull/326 a few edge cases surfaced around completion:

  • incomplete ConditionalExpr
    • attr = /*HERE*/ ? var.foo : var.bar
    • attr = var.foo ? /*HERE*/ : var.bar
    • attr = var.foo ? var.bar : /*HERE*/
    • attr = var.foo ? /*HERE*/
  • "impeding" incomplete Traversal (with trailing dot) inside otherwise complete ConditionalExpr
    • attr = var. ? var.foo : var.bar
    • attr = var.foo ? var. : var.bar
    • attr = 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

radeksimko avatar Nov 27 '23 16:11 radeksimko