Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide completion in unterminated ForExpr #370

Open
Tracked by #368
radeksimko opened this issue Feb 6, 2024 · 0 comments
Open
Tracked by #368

Provide completion in unterminated ForExpr #370

radeksimko opened this issue Feb 6, 2024 · 0 comments

Comments

@radeksimko
Copy link
Member

Background

While implementing support for ForExpr in #368 a few edge cases surfaced around completion:

  • incomplete ForExpr
    • attr = [ for k, v in /*HERE*/ ]
    • attr = [ for k, v in coll if /*HERE*/ ]
    • attr = { for k, v in /*HERE*/ }
    • attr = { for k, v in coll if /*HERE*/ }
  • "impeding" incomplete Traversal (with trailing dot) inside otherwise complete ForExpr
    • attr = [ for k, v in var./*HERE*/ ]
    • attr = [ for k, v in coll if var./*HERE*/ ]
    • attr = { for k, v in var./*HERE*/ }
    • attr = { for k, v in coll if var./*HERE*/ }

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 which causes it to return "empty literal value expression" such as the one below:

&hclsyntax.LiteralValueExpr{
    Val: cty.Value{
        ty: cty.Type{},
        v:  &cty.unknownType{},
    },
    SrcRange: hcl.Range{
        Filename: "test.hcl",
        Start:    hcl.Pos{Line:1, Column:8, Byte:7},
        End:      hcl.Pos{Line:1, Column:24, Byte:23},
    },
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant