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

hclsyntax: Recovery of incomplete parenthesis #649

Open
radeksimko opened this issue Jan 16, 2024 · 0 comments
Open

hclsyntax: Recovery of incomplete parenthesis #649

radeksimko opened this issue Jan 16, 2024 · 0 comments

Comments

@radeksimko
Copy link
Member

Context

Similar to some earlier issues, we ran into an edge case while implementing support for operators and parenthesis (ParenthesesExpr) in the Terraform language server.

attr = (

This is parsed as following:

hclsyntax.Attribute{
  Name: "attr",
  Expr: &hclsyntax.LiteralValueExpr{
    SrcRange: hcl.Range{
      Start: hcl.Pos {Line: 2, Column: 1, Byte: 9},
      End:   hcl.Pos {Line: 2, Column: 1, Byte: 9}
    }
  },
  SrcRange: hcl.Range{
    Start: hcl.Pos {Line: 1, Column: 1, Byte: 0},
    End:   hcl.Pos {Line: 2, Column: 1, Byte: 9}
  }
}

So while we can tell we are inside of an attribute and that the expression is part of the attribute - i.e. within its range, it remains awkward/difficult to figure out whether we are inside of the expression.

As with other reports related to recovery from incomplete configuration, the context is - again - enabling completion. Users would reasonably expect to be offered relevant completion in the above context, because it is exactly the nature of completion to complete the incomplete configuration.

Proposal

Report/parse the above incomplete expression with the following range:

hcl.Range{
     Start: hcl.Pos {Line: 1, Column: 8, Byte: 7},
     End:   hcl.Pos {Line: 2, Column: 1, Byte: 9}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant