hashicorp / hcl-lang

Schema and decoder to be used as building blocks for an HCL2-based language server.
https://pkg.go.dev/github.com/hashicorp/hcl-lang
Mozilla Public License 2.0
84 stars 24 forks source link

Provider completion for namespaced functions after single colon #385

Open ansgarm opened 8 months ago

ansgarm commented 8 months ago

Background

Namespaced functions in HCL that are not complete (e.g. provider::aws, a::, or a::b) return a ExprSyntaxError expression as long as there are no parentheses. However, if there's only one colon (e.g. a::b: or see gif below), hcl parses this differently and does not return an ExprSyntaxError for the position after the single colon.

fns-recovery-stuck2

Proposal

Either try to do some better recovery for these cases (tbd how) or find a fix in hcl that could catch these cases and allow looking for single colons when already parsing a namespaced function (this might only work after the first double colon though).